From 1939d2969ec1e641e39a5a4a61d1bef0ad934f09 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Wed, 21 Aug 2013 19:30:25 +0530 Subject: [PATCH] CRM-13216 fix ---------------------------------------- * CRM-13216: Advanced Search shows deleted contacts http://issues.civicrm.org/jira/browse/CRM-13216 --- CRM/Contact/BAO/Query.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 0485f70ff0..a93c1fb192 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -4198,17 +4198,6 @@ civicrm_relationship.start_date > {$today} } $this->generatePermissionClause($onlyDeleted, $count); - if (empty($where)) { - $where = "WHERE $this->_permissionWhereClause"; - } - else { - $where = "$where AND $this->_permissionWhereClause"; - } - - if ($additionalWhereClause) { - $where = $where . ' AND ' . $additionalWhereClause; - } - // building the query string $groupBy = NULL; if (!$count) { @@ -4310,7 +4299,20 @@ civicrm_relationship.start_date > {$today} list($select, $from, $where, $having) = $this->query($count, $sortByChar, $groupContacts); - //additional from clause should be w/ proper joins. + if(!empty($this->_permissionWhereClause)){ + if (empty($where)) { + $where = "WHERE $this->_permissionWhereClause"; + } + else { + $where = "$where AND $this->_permissionWhereClause"; + } + } + + if ($additionalWhereClause) { + $where = $where . ' AND ' . $additionalWhereClause; + } + + //additional from clause should be w/ proper joins. if ($additionalFromClause) { $from .= "\n" . $additionalFromClause; } -- 2.25.1