From 7e98675f0cddf24e1460218ff23c401de70be717 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 17 Mar 2015 00:29:29 +1300 Subject: [PATCH] CRM-16055 removing an IF with 2 effects, 1) per discussion with Coleman - relationships should inherit membership independent of the logged in user permission 2) the check for duplicate means that if ANY duplicates are present then do not create any relationships - this going to miss valid relationships --- CRM/Contact/Form/Relationship.php | 45 +++++++++++++++---------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/CRM/Contact/Form/Relationship.php b/CRM/Contact/Form/Relationship.php index 684ce7e804..5891df88f4 100644 --- a/CRM/Contact/Form/Relationship.php +++ b/CRM/Contact/Form/Relationship.php @@ -443,7 +443,7 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { 'Relationship' ); - // Save relationships + // Save the relationships. $outcome = CRM_Contact_BAO_Relationship::createMultiple($params, $relationshipTypeParts[1]); $relationshipIds = $outcome['relationship_ids']; $this->setMessage($outcome); @@ -476,31 +476,28 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { } } - // Membership for related contacts CRM-1657 - // @todo this belongs in the BAO. - // DOES THIS REALLY MEAN MEMBERSHIPS ARE NOT CREATED IF LOGGED IN USER DOESN'T HAVE PERMISSION!! - if (CRM_Core_Permission::access('CiviMember') && (!$duplicate)) { - $params['relationship_ids'] = $relationshipIds; - if ($this->_action & CRM_Core_Action::ADD && !empty($params['is_active'])) { - CRM_Contact_BAO_Relationship::relatedMemberships($this->_contactId, - $params, $ids, - $this->_action - ); - } - elseif ($this->_action & CRM_Core_Action::UPDATE) { - //fixes for CRM-7985 - //only if the relationship has been toggled to enable /disable - if (CRM_Utils_Array::value('is_active', $params) != $this->_enabled) { - $active = !empty($params['is_active']) ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE; - CRM_Contact_BAO_Relationship::disableEnableRelationship($this->_relationshipId, $active); - } - } - // Refresh contact tabs which might have been affected - $this->ajaxResponse['updateTabs'] = array( - '#tab_member' => CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId), - '#tab_contribute' => CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId), + $params['relationship_ids'] = $relationshipIds; + + if ($this->_action & CRM_Core_Action::ADD && !empty($params['is_active'])) { + CRM_Contact_BAO_Relationship::relatedMemberships($this->_contactId, + $params, $ids, + $this->_action ); } + elseif ($this->_action & CRM_Core_Action::UPDATE) { + //fixes for CRM-7985 + //only if the relationship has been toggled to enable /disable + if (CRM_Utils_Array::value('is_active', $params) != $this->_enabled) { + $active = !empty($params['is_active']) ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE; + CRM_Contact_BAO_Relationship::disableEnableRelationship($this->_relationshipId, $active); + } + } + // Refresh contact tabs which might have been affected + $this->ajaxResponse['updateTabs'] = array( + '#tab_member' => CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId), + '#tab_contribute' => CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId), + ); + // Set current employee/employer relationship, CRM-3532 if ($params['is_current_employer'] && $this->_allRelationshipNames[$params['relationship_type_id']]["name_a_b"] == 'Employee of') { -- 2.25.1