From: monishdeb Date: Mon, 5 Oct 2015 04:54:41 +0000 (+0530) Subject: Relationship count fix X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a93664c8494bb0601b297bafc3fb540e1a9cecb4;p=civicrm-core.git Relationship count fix --- diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 6dc4da615b..ea564123be 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -2553,9 +2553,11 @@ AND civicrm_openid.is_primary = 1"; case 'rel': $result = CRM_Contact_BAO_Relationship::getRelationship($contactId, CRM_Contact_BAO_Relationship::CURRENT, - 0, 1 + 0, 0, 0, + NULL, NULL, + TRUE ); - return $result; + return count($result); case 'group': diff --git a/CRM/Contact/BAO/Contact/Permission.php b/CRM/Contact/BAO/Contact/Permission.php index 2bd730008a..45a363b0f8 100644 --- a/CRM/Contact/BAO/Contact/Permission.php +++ b/CRM/Contact/BAO/Contact/Permission.php @@ -253,7 +253,9 @@ AND $operationClause LIMIT 1"; return FALSE; } } - if ($contactID == $selectedContactID && CRM_Core_Permission::check('edit my contact')) { + if ($contactID == $selectedContactID && + (CRM_Core_Permission::check('edit my contact') || CRM_Core_Permission::check('view my contact')) + ) { return TRUE; } else { diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index 9eec868793..5e0c5739a8 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -1232,8 +1232,9 @@ LEFT JOIN civicrm_country ON (civicrm_address.country_id = civicrm_country.id) while ($relationship->fetch()) { $rid = $relationship->civicrm_relationship_id; $cid = $relationship->civicrm_contact_id; + if ($permissionedContact && - (!CRM_Contact_BAO_Contact_Permission::relationship($cid, $contactId)) + (!CRM_Contact_BAO_Contact_Permission::allow($cid)) ) { continue; } @@ -1939,13 +1940,12 @@ AND cc.sort_name LIKE '%$name%'"; } $mask = CRM_Core_Action::mask($permissions); + $permissionedContacts = TRUE; if ($params['context'] != 'user') { $links = CRM_Contact_Page_View_Relationship::links(); - $permissionedContacts = FALSE; } else { $links = CRM_Contact_Page_View_UserDashBoard::links(); - $permissionedContacts = TRUE; $mask = NULL; } // get contact relationships @@ -1961,12 +1961,13 @@ AND cc.sort_name LIKE '%$name%'"; $params['total'] = 0; if (!empty($relationships)) { // FIXME: we cannot directly determine total permissioned relationship, hence re-fire query - $params['total'] = $permissionedRelationships = CRM_Contact_BAO_Relationship::getRelationship($params['contact_id'], + $permissionedRelationships = CRM_Contact_BAO_Relationship::getRelationship($params['contact_id'], $relationshipStatus, - 0, 1, 0, + 0, 0, 0, NULL, NULL, $permissionedContacts ); + $params['total'] = count($permissionedRelationships); // format params foreach ($relationships as $relationshipId => $values) {