Skip to content

Commit

Permalink
Issue 53 (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapjansma committed Apr 8, 2021
1 parent a88dc14 commit 4f4fb80
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -5792,7 +5792,7 @@ public function filterRelatedContacts(&$from, &$where, &$having) {
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
";
}
Expand All @@ -5813,7 +5813,7 @@ public function filterRelatedContacts(&$from, &$where, &$having) {
";
}
$qcache['where'] = "
WHERE displayRelType.relationship_type_id = $relType
AND displayRelType.relationship_type_id = $relType
AND displayRelType.is_active = 1
";
}
Expand All @@ -5837,10 +5837,11 @@ public function filterRelatedContacts(&$from, &$where, &$having) {
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')) {
Expand Down

0 comments on commit 4f4fb80

Please sign in to comment.