From 0619ff2f467ad28637e231caea5cb5c324bb6d60 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Mon, 23 Mar 2015 20:34:56 +0530 Subject: [PATCH] CRM-16151 fix - Deleted contacts are included in advanced search results when using Display As - Related Contacts option https://issues.civicrm.org/jira/browse/CRM-16151 --- CRM/Contact/BAO/Query.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 1cd5f00faf..4a439ae97e 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -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) -- 2.25.1