CRM-15306: Adding hook to alter mail templates
authoryashodha <yashodha.chaku@webaccessglobal.com>
Thu, 19 Nov 2015 10:44:02 +0000 (16:14 +0530)
committeryashodha <yashodha.chaku@webaccessglobal.com>
Thu, 19 Nov 2015 10:44:02 +0000 (16:14 +0530)
----------------------------------------
* CRM-15306: Adding hook to alter mail templates
  https://issues.civicrm.org/jira/browse/CRM-15306

CRM/Mailing/BAO/Mailing.php
CRM/Utils/Hook.php

index 7b2b0b910fd4bf061fa0ee04c2658c4c983232dd..4b36fc453b9d4aaa173e922b6e7184fd8231c2fb 100644 (file)
@@ -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;
   }
index 78d7a5c874f50b53505422a631b7fbc3974c6fc2..af9744cb55a64955840aa23539a61e6cfa992fbb 100644 (file)
@@ -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.
    *