CRM-16087 Failing test fix
authoratif-shaikh <shaikh388@gmail.com>
Tue, 31 Mar 2015 13:27:25 +0000 (18:57 +0530)
committeratif-shaikh <shaikh388@gmail.com>
Tue, 31 Mar 2015 13:27:25 +0000 (18:57 +0530)
----------------------------------------
* CRM-16087: Changes in relationship status are not invoking updates to membership status
  https://issues.civicrm.org/jira/browse/CRM-16087

CRM/Contact/BAO/Relationship.php

index efa0dfd758c8e9227b798c4cff44d4459b48260e..973e870841522d39af6e2372b21188bb1eba2ba9 100644 (file)
@@ -67,7 +67,15 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
 
       //CRM-16087 removed additional call to function relatedMemberships which is already called by disableEnableRelationship
       //resulting in memership being created twice
-      self::disableEnableRelationship($params['id'], $action, $params, $ids);
+      if (array_key_exists('is_active', $params) && empty($params['is_active'])) {
+        $action = CRM_Core_Action::DISABLE;
+        $active = FALSE;
+      }
+      else {
+        $action = CRM_Core_Action::ENABLE;
+        $active = TRUE;
+      }
+      self::disableEnableRelationship($params['id'], $action, $params, $ids, $active);
     }
 
     self::addRecent($params, $relationship);
@@ -685,15 +693,6 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
           'contact_check' => array($relationship->contact_id_b => 1),
         );
       }
-      else {
-        if (array_key_exists('is_active', $params) && empty($params['is_active'])) {
-          $action = CRM_Core_Action::DISABLE;
-        }
-        else {
-          $action = CRM_Core_Action::ENABLE;
-          $active = TRUE;
-        }
-      }
       $contact_id_a = empty($params['contact_id_a']) ? $relationship->contact_id_a : $params['contact_id_a'];
       // calling relatedMemberships to delete/add the memberships of
       // related contacts.