From: Dave Greenberg Date: Mon, 6 Jan 2014 22:15:54 +0000 (-0800) Subject: CRM-14501 - Fix CRM_Contact_BAO_Relationship::getPermissionedContacts so it can handl... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f9f0eff92a7a15f6db33a8d37b69d62e335c8342;p=civicrm-core.git CRM-14501 - Fix CRM_Contact_BAO_Relationship::getPermissionedContacts so it can handle a list of one or more relationshipTypeIDs. ---------------------------------------- * CRM-14501: http://issues.civicrm.org/jira/browse/CRM-14501 --- diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index 4f40d5015a..2085564ad3 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -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()) { diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index e92bdf45c1..f4d409e18a 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -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;