Skip to content
Snippets Groups Projects
Commit f9f0eff9 authored by Dave Greenberg's avatar Dave Greenberg
Browse files

CRM-14501 - Fix CRM_Contact_BAO_Relationship::getPermissionedContacts so it...

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
parent b546f34d
No related branches found
No related tags found
No related merge requests found
......@@ -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()) {
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment