From bca8dc9b82c154e10a80f6dc74e6b286e41f260b Mon Sep 17 00:00:00 2001 From: samuelsov Date: Thu, 26 Feb 2015 09:11:03 -0500 Subject: [PATCH] Add hook_civicrm_pre / hook_civicrm_post for Campaign --- CRM/Campaign/BAO/Campaign.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/CRM/Campaign/BAO/Campaign.php b/CRM/Campaign/BAO/Campaign.php index 2261f3a15b..876d92683e 100644 --- a/CRM/Campaign/BAO/Campaign.php +++ b/CRM/Campaign/BAO/Campaign.php @@ -65,12 +65,23 @@ class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign { if (!(CRM_Utils_Array::value('name', $params))) { $params['name'] = CRM_Utils_String::titleToVar($params['title'], 64); } + + CRM_Utils_Hook::pre('create', 'Campaign', NULL, $params); + } else { + CRM_Utils_Hook::pre('edit', 'Campaign', $params['id'], $params); } $campaign = new CRM_Campaign_DAO_Campaign(); $campaign->copyValues($params); $campaign->save(); + if (!empty($params['id'])) { + CRM_Utils_Hook::post('edit', 'Campaign', $campaign->id, $campaign); + } + else { + CRM_Utils_Hook::post('create', 'Campaign', $campaign->id, $campaign); + } + /* Create the campaign group record */ $groupTableName = CRM_Contact_BAO_Group::getTableName(); @@ -109,9 +120,16 @@ class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign { if (!$id) { return FALSE; } + + CRM_Utils_Hook::pre('delete', 'Campaign', $id, CRM_Core_DAO::$_nullArray); + $dao = new CRM_Campaign_DAO_Campaign(); $dao->id = $id; - return $dao->delete(); + $result = $dao->delete(); + + CRM_Utils_Hook::post('delete', 'Campaign', $id, $dao); + + return $result; } /** -- 2.25.1