CRM-14501 - Fix CRM_Contact_BAO_Relationship::getPermissionedContacts so it can handl...
authorDave Greenberg <dave@civicrm.org>
Mon, 6 Jan 2014 22:15:54 +0000 (14:15 -0800)
committerDave Greenberg <dave@civicrm.org>
Mon, 6 Jan 2014 22:15:54 +0000 (14:15 -0800)
----------------------------------------
* CRM-14501:
  http://issues.civicrm.org/jira/browse/CRM-14501

CRM/Contact/BAO/Relationship.php
CRM/Contribute/Form/ContributionBase.php

index 4f40d5015a2a501fe7db78e8dcb9a044534e5109..2085564ad34920047c25af67883983c38c8016d6 100644 (file)
@@ -1449,7 +1449,7 @@ WHERE id IN ( {$contacts} )
   * Function to return list of permissioned contacts for a given contact and relationship type
   *
   * @param $contactID int contact id whose permissioned contacts are to be found.
-  * @param $relTypeId relationship type id
+  * @param $relTypeId string one or more relationship type id's
   * @param $name string
   *
   * @static
@@ -1465,7 +1465,7 @@ SELECT cc.id as id, cc.sort_name as name
 FROM civicrm_relationship cr, civicrm_contact cc
 WHERE
 cr.contact_id_a         = %1 AND
-cr.relationship_type_id = %2 AND
+cr.relationship_type_id IN (%2) AND
 cr.is_permission_a_b    = 1 AND
 IF(cr.end_date IS NULL, 1, (DATEDIFF( CURDATE( ), cr.end_date ) <= 0)) AND
 cr.is_active = 1 AND
@@ -1477,7 +1477,7 @@ cc.id = cr.contact_id_b";
 AND cc.sort_name LIKE '%$name%'";
       }
 
-      $args = array(1 => array($contactID, 'Integer'), 2 => array($relTypeId, 'Integer'));
+      $args = array(1 => array($contactID, 'Integer'), 2 => array($relTypeId, 'String'));
       $dao  = CRM_Core_DAO::executeQuery($query, $args);
 
       while ($dao->fetch()) {
index e92bdf45c1cd341035654df73d3788d05a488ab5..f4d409e18ad368f4324fdb130ba5e8af667510c4 100644 (file)
@@ -230,6 +230,9 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
               $membershipType = new CRM_Member_BAO_MembershipType();
               $membershipType->id = $membership->membership_type_id;
               if ($membershipType->find(TRUE)) {
+                // CRM-14051 - membership_type.relationship_type_id is a CTRL-A padded string w one or more ID values.
+                // Convert to commma separated list.
+                $inheritedRelTypes = implode(CRM_Utils_Array::explodePadded($membershipType->relationship_type_id), ',');
                 $permContacts = CRM_Contact_BAO_Relationship::getPermissionedContacts($this->_userID, $membershipType->relationship_type_id);
                 if (array_key_exists($membership->contact_id, $permContacts)) {
                   $this->_membershipContactID = $membership->contact_id;