From 882b2baf8f20f96fee1839e2f678c0d4321171a9 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Mon, 16 Feb 2015 20:04:19 +0530 Subject: [PATCH] CRM-15889 fix - Relationship enable/disable through API & the UI - does not take care of inherited memberships https://issues.civicrm.org/jira/browse/CRM-15889 --- CRM/Contact/Page/View/Relationship.php | 12 ------------ api/v3/Relationship.php | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CRM/Contact/Page/View/Relationship.php b/CRM/Contact/Page/View/Relationship.php index b93dfa3e1a..6299d10f90 100644 --- a/CRM/Contact/Page/View/Relationship.php +++ b/CRM/Contact/Page/View/Relationship.php @@ -214,18 +214,6 @@ class CRM_Contact_Page_View_Relationship extends CRM_Core_Page { elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) { $this->edit(); } - elseif ($this->_action & CRM_Core_Action::DISABLE) { - CRM_Contact_BAO_Relationship::disableEnableRelationship($this->_id, CRM_Core_Action::DISABLE); - CRM_Contact_BAO_Relationship::setIsActive($this->_id, 0); - $session = CRM_Core_Session::singleton(); - CRM_Utils_System::redirect($session->popUserContext()); - } - elseif ($this->_action & CRM_Core_Action::ENABLE) { - CRM_Contact_BAO_Relationship::disableEnableRelationship($this->_id, CRM_Core_Action::ENABLE); - CRM_Contact_BAO_Relationship::setIsActive($this->_id, 1); - $session = CRM_Core_Session::singleton(); - CRM_Utils_System::redirect($session->popUserContext()); - } // if this is called from case view, suppress browse relationships form else { diff --git a/api/v3/Relationship.php b/api/v3/Relationship.php index b4e20a2558..fcaed329c4 100644 --- a/api/v3/Relationship.php +++ b/api/v3/Relationship.php @@ -146,3 +146,17 @@ function _civicrm_api3_handle_relationship_type(&$params) { } } } + +function civicrm_api3_relationship_setvalue($params) { + require_once 'api/v3/Generic/Setvalue.php'; + $result = civicrm_api3_generic_setValue(array("entity" => 'Relationship', 'params' => $params)); + + if (empty($result['is_error']) && CRM_Utils_String::munge($params['field']) == 'is_active') { + $action = CRM_Core_Action::DISABLE; + if ($params['value'] == TRUE) { + $action = CRM_Core_Action::ENABLE; + } + CRM_Contact_BAO_Relationship::disableEnableRelationship($params['id'], $action); + } + return $result; +} -- 2.25.1