CRM-16151 fix - Deleted contacts are included in advanced search results when using...
authormonishdeb <monish.deb@webaccessglobal.com>
Mon, 23 Mar 2015 15:04:56 +0000 (20:34 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Mon, 23 Mar 2015 15:04:56 +0000 (20:34 +0530)
https://issues.civicrm.org/jira/browse/CRM-16151

CRM/Contact/BAO/Query.php

index 1cd5f00faf030879778b298fd032424f99246699..4a439ae97efc040ffcc2e91df08ac51832a054ac 100644 (file)
@@ -1375,7 +1375,7 @@ class CRM_Contact_BAO_Query {
       $where = "WHERE {$this->_whereClause}";
     }
 
-    if (!empty($this->_permissionWhereClause)) {
+    if (!empty($this->_permissionWhereClause) && empty($this->_displayRelationshipType)) {
       if (empty($where)) {
         $where = "WHERE $this->_permissionWhereClause";
       }
@@ -5331,6 +5331,10 @@ AND   displayRelType.is_active = 1
       $this->_qill[0][] = $qillMessage . "'" . $relationshipTypeLabel . "'";
     }
 
+    if (!empty($this->_permissionWhereClause)) {
+      $_rTypeWhere .= "AND $this->_permissionWhereClause";
+    }
+
     if (strpos($from, $_rTypeFrom) === FALSE) {
       // lets replace all the INNER JOIN's in the $from so we dont exclude other data
       // this happens when we have an event_type in the quert (CRM-7969)