Merge pull request #3476 from eileenmcnaughton/CRM-14838
[civicrm-core.git] / CRM / Utils / Hook.php
index 85f7e9b859b046d938c02abc3ad5b4cdd3572df1..bed5f0dfcdf5a2240b7396dc31d751759bd0a00c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -561,9 +561,12 @@ abstract class CRM_Utils_Hook {
    * This hook is called when a contact unsubscribes from a mailing.  It allows modules
    * to override what the contacts are removed from.
    *
+   * @param string $op      - ignored for now
    * @param int $mailing_id - the id of the mailing to unsub from
    * @param int $contact_id - the id of the contact who is unsubscribing
    * @param array / int $groups - array of groups the contact will be removed from
+   * @param array / int $baseGroups - array of base groups (used in smart mailings) the contact will be removed from
+   *
    **/
   static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
     return self::singleton()->invoke(5, $op, $mailingId, $contactId, $groups, $baseGroups, 'civicrm_unsubscribeGroups');
@@ -748,6 +751,16 @@ abstract class CRM_Utils_Hook {
     );
   }
 
+  /**
+   * This hook is called when locating CiviCase types.
+   *
+   * @param array $caseTypes
+   * @return void
+   */
+  static function caseTypes(&$caseTypes) {
+    return self::singleton()->invoke(1, $caseTypes, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_caseTypes');
+  }
+
   /**
    * This hook is called soon after the CRM_Core_Config object has ben initialized.
    * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
@@ -1056,6 +1069,23 @@ abstract class CRM_Utils_Hook {
     );
   }
 
+  /**
+   * This hooks allows alteration of the tpl file used to generate content. It differs from the
+   * altercontent hook as the content has already been rendered through the tpl at that point
+   *
+   * @param $formName  previously generated content
+   * @param $form reference to the form object
+   * @param $context  context of content - page or form
+   * @param $tplName reference the file name of the tpl
+   *
+   * @access public
+   */
+  static function alterTemplateFile($formName, &$form, $context, &$tplName) {
+    return self::singleton()->invoke(4, $formName, $form, $context, $tplName,
+      self::$_nullObject,
+      'civicrm_alterTemplateFile'
+    );
+  }
   /**
    * This hook collects the trigger definition from all components
    *
@@ -1198,6 +1228,21 @@ abstract class CRM_Utils_Hook {
     );
   }
 
+  /**
+   * This hook is called before running an api call.
+   *
+   * @param $wrappers array of implements API_Wrapper(see CRM/Utils/API/ReloadOption.php as an example)
+   *
+   * @return null the return value is ignored
+   * @access public
+   */
+  static function apiWrappers(&$wrappers, $apiRequest) {
+    return self::singleton()
+      ->invoke(2, $wrappers, $apiRequest, self::$_nullObject, self::$_nullObject, self::$_nullObject,
+      'civicrm_apiWrappers'
+    );
+  }
+
   /**
    * This hook is called before running pending cron jobs.
    *
@@ -1317,6 +1362,22 @@ abstract class CRM_Utils_Hook {
       self::$_nullObject, 'civicrm_alterBarcode');
   }
 
+  /**
+   * Modify or replace the Mailer object used for outgoing mail.
+   *
+   * @param object $mailer
+   *   The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
+   * @param string $driver
+   *   The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
+   * @param array $params
+   *   The default mailer config options
+   * @see Mail::factory
+   */
+  static function alterMail(&$mailer, $driver, $params) {
+    return self::singleton()
+      ->invoke(3, $mailer, $driver, $params, self::$_nullObject, self::$_nullObject, 'civicrm_alterMailer');
+  }
+
   /**
    * This hook is called while building the core search query,
    * so hook implementers can provide their own query objects which alters/extends core search.
@@ -1324,7 +1385,17 @@ abstract class CRM_Utils_Hook {
    * @param Array $queryObjects
    * @return void
    */
-  static function queryObjects(&$queryObjects) {
-    return self::singleton()->invoke(1, $queryObjects, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_queryObjects');
+  static function queryObjects(&$queryObjects, $type = 'Contact') {
+    return self::singleton()->invoke(2, $queryObjects, $type, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_queryObjects');
+  }
+
+  /**
+   * This hook is called while viewing contact dashboard
+   *
+   * @param array $availableDashlets list of dashlets; each is formatted per api/v3/Dashboard
+   * @param array $activeDashlets list of dashlets; each is formatted per api/v3/DashboardContact
+   */
+  static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
+    return self::singleton()->invoke(2, $availableDashlets, $defaultDashlets, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_dashboard_defaults');
   }
 }