From d04a3a9be4a4ec3b681a9e909cdaa149a0234288 Mon Sep 17 00:00:00 2001 From: yashodha Date: Thu, 19 Nov 2015 16:14:02 +0530 Subject: [PATCH] CRM-15306: Adding hook to alter mail templates ---------------------------------------- * CRM-15306: Adding hook to alter mail templates https://issues.civicrm.org/jira/browse/CRM-15306 --- CRM/Mailing/BAO/Mailing.php | 2 ++ CRM/Utils/Hook.php | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index 7b2b0b910f..4b36fc453b 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -802,6 +802,8 @@ ORDER BY i.contact_id, i.{$tempColumn} $template[] = $this->subject; $this->templates['subject'] = implode("\n", $template); } + + CRM_Utils_Hook::alterMailTemplates($this->templates); } return $this->templates; } diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 78d7a5c874..af9744cb55 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -998,6 +998,21 @@ abstract class CRM_Utils_Hook { ); } + /** + * This hook is called after getting the content of the mail and before tokenizing it. + * + * @param array $templates + * Array fields include: html, text, subject + * + * @return mixed + */ + public static function alterMailTemplates(&$templates) { + return self::singleton()->invoke(1, $templates, + self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, + 'civicrm_alterMailTemplates' + ); + } + /** * This hook is called when rendering the Manage Case screen. * -- 2.25.1