From eec8d770f9ef8e30ec3290673cb32d3631965e2e Mon Sep 17 00:00:00 2001 From: atif-shaikh Date: Tue, 7 Apr 2015 18:32:23 +0530 Subject: [PATCH] On edit / save the main contact edit form for a contact who has an inherited membership (by relationship), their (inherited) membership is deleted and recreated --- CRM/Contact/BAO/Relationship.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index 7a923c7fac..93ed52260d 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -1554,6 +1554,10 @@ SELECT relationship_type_id, relationship_direction } if ($action & CRM_Core_Action::UPDATE) { + //if updated relationship is already related to contact don't delete existing inherited membership + if (in_array($relTypeId, $relTypeIds) && !empty($values[$relatedContactId]['memberships'])) { + continue; + } //delete the membership record for related //contact before creating new membership record. CRM_Member_BAO_Membership::deleteRelatedMemberships($membershipId, $relatedContactId); @@ -1600,7 +1604,7 @@ SELECT count(*) */ public static function isDeleteRelatedMembership($relTypeIds, $contactId, $mainRelatedContactId, $relTypeId, $relIds) { if (in_array($relTypeId, $relTypeIds)) { - return TRUE; + return FALSE; } if (empty($relIds)) { -- 2.25.1