Relationship count fix
authormonishdeb <monish.deb@webaccessglobal.com>
Mon, 5 Oct 2015 04:54:41 +0000 (10:24 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Mon, 5 Oct 2015 20:33:10 +0000 (02:03 +0530)
CRM/Contact/BAO/Contact.php
CRM/Contact/BAO/Contact/Permission.php
CRM/Contact/BAO/Relationship.php

index 6dc4da615bac278df9b0de972260bb85d05d0b8e..ea564123be0a51bbf751777619a37e26b18cb510 100644 (file)
@@ -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':
 
index 2bd730008a8809cb9b161db663195073b155302e..45a363b0f80f732f65e5284663dda2fab87a4476 100644 (file)
@@ -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 {
index 9eec868793bee8a26c8fe6a81526bf86fa6be5a8..5e0c5739a87acea2720109da135d43f5a28f947a 100644 (file)
@@ -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) {