From 2f5aa3cd8b954593f9f3e40e63ad2916f1ac769f Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Wed, 4 Jul 2018 12:04:10 +0100 Subject: [PATCH] Fix a bug in second degree permssions where the a_b, b_a combination was mishandled We need to check for: first_degree_relationship.contact_id_a = second_degree_relationship.contact_id_a first_degree_relationship.contact_id_a = second_degree_relationship.contact_id_b first_degree_relationship.contact_id_b = second_degree_relationship.contact_id_a first_degree_relationship.contact_id_b = second_degree_relationship.contact_id_b but the last one was mishandled. --- CRM/Contact/BAO/Contact/Permission.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/BAO/Contact/Permission.php b/CRM/Contact/BAO/Contact/Permission.php index 883b39922f..c8ddb50a1f 100644 --- a/CRM/Contact/BAO/Contact/Permission.php +++ b/CRM/Contact/BAO/Contact/Permission.php @@ -354,7 +354,7 @@ AND ac.user_id IS NULL $queries = array(); $contact_id_list = implode(',', $contact_ids); - // add a select statement for each direection + // add a select statement for each direction $directions = array(array('from' => 'a', 'to' => 'b'), array('from' => 'b', 'to' => 'a')); // CRM_Core_Permission::VIEW is satisfied by either CRM_Contact_BAO_Relationship::VIEW or CRM_Contact_BAO_Relationship::EDIT @@ -402,7 +402,7 @@ SELECT civicrm_relationship.{$contact_id_column} AS contact_id $queries[] = " SELECT second_degree_relationship.contact_id_{$second_direction['to']} AS contact_id FROM civicrm_relationship first_degree_relationship - LEFT JOIN civicrm_relationship second_degree_relationship ON first_degree_relationship.contact_id_{$first_direction['to']} = second_degree_relationship.contact_id_{$first_direction['from']} + LEFT JOIN civicrm_relationship second_degree_relationship ON first_degree_relationship.contact_id_{$first_direction['to']} = second_degree_relationship.contact_id_{$second_direction['from']} {$LEFT_JOIN_DELETED} WHERE first_degree_relationship.contact_id_{$first_direction['from']} = {$contactID} AND second_degree_relationship.contact_id_{$second_direction['to']} IN ({$contact_id_list}) -- 2.25.1