From 4f4fb809a77cdfb7876d662f331d524fb2eeb1b3 Mon Sep 17 00:00:00 2001 From: Jaap Jansma Date: Thu, 8 Apr 2021 13:20:40 +0200 Subject: [PATCH] Issue 53 (2) --- CRM/Contact/BAO/Query.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index f581fe2558..76686c7848 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -5792,7 +5792,7 @@ INNER JOIN civicrm_relationship displayRelType ON ( displayRelType.contact_id_a INNER JOIN $tableName transform_temp ON ( transform_temp.contact_id = displayRelType.contact_id_a OR transform_temp.contact_id = displayRelType.contact_id_b ) "; $qcache['where'] = " -WHERE displayRelType.relationship_type_id = {$this->_displayRelationshipType} +AND displayRelType.relationship_type_id = {$this->_displayRelationshipType} AND displayRelType.is_active = 1 "; } @@ -5813,7 +5813,7 @@ INNER JOIN $tableName transform_temp ON ( transform_temp.contact_id = displayRel "; } $qcache['where'] = " -WHERE displayRelType.relationship_type_id = $relType +AND displayRelType.relationship_type_id = $relType AND displayRelType.is_active = 1 "; } @@ -5837,10 +5837,11 @@ AND displayRelType.is_active = 1 else { $from .= $qcache['from']; } - $where = $qcache['where']; + $where .= $qcache['where']; if (!empty($this->_tables['civicrm_case'])) { // Change the join on CiviCRM case so that it joins on the right contac from the relationship. $from = str_replace("ON civicrm_case_contact.contact_id = contact_a.id", "ON civicrm_case_contact.contact_id = transform_temp.contact_id", $from); + $where = str_replace("AND civicrm_case_contact.contact_id = contact_a.id", "AND civicrm_case_contact.contact_id = transform_temp.contact_id", $where); $where .= " AND displayRelType.case_id = civicrm_case_contact.case_id "; } if (!empty($this->_permissionFromClause) && !stripos($from, 'aclContactCache')) { -- 2.25.1