alter related membership if the is_active param is changed
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 27 Feb 2015 13:03:19 +0000 (18:33 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 27 Feb 2015 13:03:19 +0000 (18:33 +0530)
CRM/Contact/BAO/Relationship.php

index 62f2ae86a5ef01e66168767d6c0c8dd089af6277..58b05f78ee40ba8014fa8552c90ad9ad5493bdbe 100644 (file)
@@ -64,6 +64,15 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
       $ids = array('contactTarget' => $relationship->contact_id_b, 'contact' => $params['contact_id_a']);
       CRM_Contact_BAO_Relationship::relatedMemberships($params['contact_id_a'], $values, $ids, (empty($params['id']) ? CRM_Core_Action::ADD : CRM_Core_Action::UPDATE));
     }
+
+    //alter related membership if the is_active param is changed
+    if (!empty($params['id'])) {
+      $action = CRM_Core_Action::DISABLE;
+      if (!empty($params['is_active'])) {
+        $action = CRM_Core_Action::ENABLE;
+      }
+      CRM_Contact_BAO_Relationship::disableEnableRelationship($params['id'], $action);
+    }
     self::addRecent($params, $relationship);
     return $relationship;
   }