From 07cd5b4a2e8824c099e2cec297f8da26ffa44b6f Mon Sep 17 00:00:00 2001 From: Omar abu hussein Date: Fri, 3 Apr 2020 15:21:03 +0100 Subject: [PATCH] BASW-123: Prevent cancelling membership when cancelling linked offline installment contribution Included in CiviCRM-Core PR: https://github.com/civicrm/civicrm-core/pull/12253 --- CRM/Core/DAO.php | 4 ++++ CRM/Utils/Hook.php | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 11a990b52db8..df6da41de517 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -597,6 +597,10 @@ public function table() { * @return CRM_Core_DAO */ public function save($hook = TRUE) { + if ($hook) { + CRM_Utils_Hook::preSave($this); + } + if (!empty($this->id)) { if ($hook) { $preEvent = new \Civi\Core\DAO\Event\PreUpdate($this); diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 38c1da128e0d..6acd0afca05f 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -1524,6 +1524,19 @@ public static function alterAPIPermissions($entity, $action, &$params, &$permiss ); } + /** + * @param CRM_Core_DAO $dao + * + * @return mixed + */ + public static function preSave(&$dao) { + $hookName = 'civicrm_preSave_' . $dao->getTableName(); + return self::singleton()->invoke(array('dao'), $dao, + self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, + $hookName + ); + } + /** * @param CRM_Core_DAO $dao *