3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
30 * @package CiviCRM_Hook
31 * @copyright CiviCRM LLC (c) 2004-2019
33 abstract class CRM_Utils_Hook
{
35 // Allowed values for dashboard hook content placement
36 // Default - place content below activity list
37 const DASHBOARD_BELOW
= 1;
38 // Place content above activity list
39 const DASHBOARD_ABOVE
= 2;
40 // Don't display activity list at all
41 const DASHBOARD_REPLACE
= 3;
43 // by default - place content below existing content
44 const SUMMARY_BELOW
= 1;
45 // place hook content above
46 const SUMMARY_ABOVE
= 2;
48 *create your own summaries
50 const SUMMARY_REPLACE
= 3;
53 * Object to pass when an object is required to be passed by params.
55 * This is supposed to be a convenience but note that it is a bad
56 * pattern as it can get contaminated & result in hard-to-diagnose bugs.
60 public static $_nullObject = NULL;
63 * We only need one instance of this object. So we use the singleton
64 * pattern and cache the instance in this variable
68 static private $_singleton = NULL;
73 private $commonIncluded = FALSE;
78 private $commonCiviModules = [];
81 * @var CRM_Utils_Cache_Interface
86 * Constructor and getter for the singleton instance.
90 * @return CRM_Utils_Hook
91 * An instance of $config->userHookClass
93 public static function singleton($fresh = FALSE) {
94 if (self
::$_singleton == NULL ||
$fresh) {
95 $config = CRM_Core_Config
::singleton();
96 $class = $config->userHookClass
;
97 self
::$_singleton = new $class();
99 return self
::$_singleton;
103 * CRM_Utils_Hook constructor.
105 * @throws \CRM_Core_Exception
107 public function __construct() {
108 $this->cache
= CRM_Utils_Cache
::create([
110 'type' => ['ArrayCache'],
116 * Invoke a hook through the UF/CMS hook system and the extension-hook
119 * @param int $numParams
120 * Number of parameters to pass to the hook.
122 * Parameter to be passed to the hook.
124 * Parameter to be passed to the hook.
126 * Parameter to be passed to the hook.
128 * Parameter to be passed to the hook.
130 * Parameter to be passed to the hook.
132 * Parameter to be passed to the hook.
133 * @param string $fnSuffix
134 * Function suffix, this is effectively the hook name.
138 abstract public function invokeViaUF(
140 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
147 * This is a transitional adapter. It supports the legacy syntax
148 * but also accepts enough information to support Symfony Event
151 * @param array|int $names
152 * (Recommended) Array of parameter names, in order.
153 * Using an array is recommended because it enables full
154 * event-broadcasting behaviors.
155 * (Legacy) Number of parameters to pass to the hook.
156 * This is provided for transitional purposes.
163 * @param mixed $fnSuffix
166 public function invoke(
168 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
171 // Per https://github.com/civicrm/civicrm-core/pull/13551 we have had ongoing significant problems where hooks from modules are
172 // invoked during upgrade but not those from extensions. The issues are both that an incorrect module list & settings are cached and that
173 // some hooks REALLY need to run during upgrade - the loss of triggers during upgrade causes significant loss of data
174 // whereas loss of logTable hooks means that log tables are created for tables specifically excluded - e.g due to large
175 // quantities of low-importance data or the table not having an id field, which could cause a fatal error.
176 // Instead of not calling any hooks we only call those we know to be frequently important - if a particular extension wanted
177 // to avoid this they could do an early return on CRM_Core_Config::singleton()->isUpgradeMode
178 $upgradeFriendlyHooks = ['civicrm_alterSettingsFolders', 'civicrm_alterSettingsMetaData', 'civicrm_triggerInfo', 'civicrm_alterLogTables', 'civicrm_container'];
179 if (CRM_Core_Config
::singleton()->isUpgradeMode() && !in_array($fnSuffix, $upgradeFriendlyHooks)) {
182 if (is_array($names) && !defined('CIVICRM_FORCE_LEGACY_HOOK') && \Civi\Core\Container
::isContainerBooted()) {
183 $event = \Civi\Core\Event\GenericHookEvent
::createOrdered(
185 array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6)
187 \Civi
::dispatcher()->dispatch('hook_' . $fnSuffix, $event);
188 return $event->getReturnValues();
191 // We need to ensure tht we will still run known bootstrap related hooks even if the container is not booted.
192 $prebootContainerHooks = array_merge($upgradeFriendlyHooks, ['civicrm_entityTypes', 'civicrm_config']);
193 if (!\Civi\Core\Container
::isContainerBooted() && !in_array($fnSuffix, $prebootContainerHooks)) {
196 $count = is_array($names) ?
count($names) : $names;
197 return $this->invokeViaUF($count, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $fnSuffix);
202 * @param array $numParams
214 public function commonInvoke(
216 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
220 $this->commonBuildModuleList($fnPrefix);
222 return $this->runHooks($this->commonCiviModules
, $fnSuffix,
223 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
228 * Build the list of modules to be processed for hooks.
230 * @param string $fnPrefix
232 public function commonBuildModuleList($fnPrefix) {
233 if (!$this->commonIncluded
) {
234 // include external file
235 $this->commonIncluded
= TRUE;
237 $config = CRM_Core_Config
::singleton();
238 if (!empty($config->customPHPPathDir
)) {
239 $civicrmHooksFile = CRM_Utils_File
::addTrailingSlash($config->customPHPPathDir
) . 'civicrmHooks.php';
240 if (file_exists($civicrmHooksFile)) {
241 @include_once
$civicrmHooksFile;
245 if (!empty($fnPrefix)) {
246 $this->commonCiviModules
[$fnPrefix] = $fnPrefix;
249 $this->requireCiviModules($this->commonCiviModules
);
256 * @param array $civiModules
257 * @param string $fnSuffix
258 * @param int $numParams
269 public function runHooks(
270 $civiModules, $fnSuffix, $numParams,
271 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
273 // $civiModules is *not* passed by reference because runHooks
274 // must be reentrant. PHP is finicky about running
275 // multiple loops over the same variable. The circumstances
276 // to reproduce the issue are pretty intricate.
279 $fnNames = $this->cache
->get($fnSuffix);
280 if (!is_array($fnNames)) {
282 if ($civiModules !== NULL) {
283 foreach ($civiModules as $module) {
284 $fnName = "{$module}_{$fnSuffix}";
285 if (function_exists($fnName)) {
286 $fnNames[] = $fnName;
289 $this->cache
->set($fnSuffix, $fnNames);
293 foreach ($fnNames as $fnName) {
295 switch ($numParams) {
297 $fResult = $fnName();
301 $fResult = $fnName($arg1);
305 $fResult = $fnName($arg1, $arg2);
309 $fResult = $fnName($arg1, $arg2, $arg3);
313 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
317 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
321 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
325 CRM_Core_Error
::fatal(ts('Invalid hook invocation'));
329 if (!empty($fResult) &&
332 $result = array_merge($result, $fResult);
336 return empty($result) ?
TRUE : $result;
342 public function requireCiviModules(&$moduleList) {
343 $civiModules = CRM_Core_PseudoConstant
::getModuleExtensions();
344 foreach ($civiModules as $civiModule) {
345 if (!file_exists($civiModule['filePath'])) {
346 CRM_Core_Session
::setStatus(
347 ts('Error loading module file (%1). Please restore the file or disable the module.',
348 [1 => $civiModule['filePath']]),
349 ts('Warning'), 'error');
352 include_once $civiModule['filePath'];
353 $moduleList[$civiModule['prefix']] = $civiModule['prefix'];
358 * This hook is called before a db write on some core objects.
359 * This hook does not allow the abort of the operation
362 * The type of operation being performed.
363 * @param string $objectName
364 * The name of the object.
366 * The object id if available.
367 * @param array $params
368 * The parameters used for object creation / editing.
371 * the return value is ignored
373 public static function pre($op, $objectName, $id, &$params) {
374 $event = new \Civi\Core\Event\
PreEvent($op, $objectName, $id, $params);
375 \Civi
::dispatcher()->dispatch('hook_civicrm_pre', $event);
376 return $event->getReturnValues();
380 * This hook is called after a db write on some core objects.
383 * The type of operation being performed.
384 * @param string $objectName
385 * The name of the object.
386 * @param int $objectId
387 * The unique identifier for the object.
388 * @param object $objectRef
389 * The reference to the object if available.
392 * based on op. pre-hooks return a boolean or
393 * an error message which aborts the operation
395 public static function post($op, $objectName, $objectId, &$objectRef = NULL) {
396 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
397 \Civi
::dispatcher()->dispatch('hook_civicrm_post', $event);
398 return $event->getReturnValues();
402 * This hook retrieves links from other modules and injects it into.
403 * the view contact tabs
406 * The type of operation being performed.
407 * @param string $objectName
408 * The name of the object.
409 * @param int $objectId
410 * The unique identifier for the object.
411 * @param array $links
412 * (optional) the links array (introduced in v3.2).
414 * (optional) the bitmask to show/hide links.
415 * @param array $values
416 * (optional) the values to fill the links.
419 * the return value is ignored
421 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = []) {
422 return self
::singleton()->invoke(['op', 'objectName', 'objectId', 'links', 'mask', 'values'], $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
426 * This hook is invoked during the CiviCRM form preProcess phase.
428 * @param string $formName
429 * The name of the form.
430 * @param CRM_Core_Form $form
431 * Reference to the form object.
434 * the return value is ignored
436 public static function preProcess($formName, &$form) {
437 return self
::singleton()
438 ->invoke(['formName', 'form'], $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_preProcess');
442 * This hook is invoked when building a CiviCRM form. This hook should also
443 * be used to set the default values of a form element
445 * @param string $formName
446 * The name of the form.
447 * @param CRM_Core_Form $form
448 * Reference to the form object.
451 * the return value is ignored
453 public static function buildForm($formName, &$form) {
454 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
455 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
461 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
462 * any form elements, this hook should save the values in the database
464 * @param string $formName
465 * The name of the form.
466 * @param CRM_Core_Form $form
467 * Reference to the form object.
470 * the return value is ignored
472 public static function postProcess($formName, &$form) {
473 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
474 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
475 'civicrm_postProcess'
480 * This hook is invoked during all CiviCRM form validation. An array of errors
481 * detected is returned. Else we assume validation succeeded.
483 * @param string $formName
484 * The name of the form.
485 * @param array &$fields the POST parameters as filtered by QF
486 * @param array &$files the FILES parameters as sent in by POST
487 * @param array &$form the form object
488 * @param array &$errors the array of errors.
491 * formRule hooks return a boolean or
492 * an array of error messages which display a QF Error
494 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
495 return self
::singleton()
496 ->invoke(['formName', 'fields', 'files', 'form', 'errors'],
497 $formName, $fields, $files, $form, $errors, self
::$_nullObject, 'civicrm_validateForm');
501 * This hook is called after a db write on a custom table.
504 * The type of operation being performed.
505 * @param string $groupID
506 * The custom group ID.
507 * @param object $entityID
508 * The entityID of the row in the custom table.
509 * @param array $params
510 * The parameters that were sent into the calling function.
513 * the return value is ignored
515 public static function custom($op, $groupID, $entityID, &$params) {
516 return self
::singleton()
517 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_custom');
521 * This hook is called when composing the ACL where clause to restrict
522 * visibility of contacts to the logged in user
525 * The type of permission needed.
526 * @param array $tables
527 * (reference ) add the tables that are needed for the select clause.
528 * @param array $whereTables
529 * (reference ) add the tables that are needed for the where clause.
530 * @param int $contactID
531 * The contactID for whom the check is made.
532 * @param string $where
533 * The currrent where clause.
536 * the return value is ignored
538 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
539 return self
::singleton()
540 ->invoke(['type', 'tables', 'whereTables', 'contactID', 'where'], $type, $tables, $whereTables, $contactID, $where, self
::$_nullObject, 'civicrm_aclWhereClause');
544 * This hook is called when composing the ACL where clause to restrict
545 * visibility of contacts to the logged in user
548 * The type of permission needed.
549 * @param int $contactID
550 * The contactID for whom the check is made.
551 * @param string $tableName
552 * The tableName which is being permissioned.
553 * @param array $allGroups
554 * The set of all the objects for the above table.
555 * @param array $currentGroups
556 * The set of objects that are currently permissioned for this contact.
559 * the return value is ignored
561 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
562 return self
::singleton()
563 ->invoke(['type', 'contactID', 'tableName', 'allGroups', 'currentGroups'], $type, $contactID, $tableName, $allGroups, $currentGroups, self
::$_nullObject, 'civicrm_aclGroup');
567 * @param string|CRM_Core_DAO $entity
568 * @param array $clauses
571 public static function selectWhereClause($entity, &$clauses) {
572 $entityName = is_object($entity) ?
_civicrm_api_get_entity_name_from_dao($entity) : $entity;
573 return self
::singleton()->invoke(['entity', 'clauses'], $entityName, $clauses,
574 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
575 'civicrm_selectWhereClause'
580 * This hook is called when building the menu table.
582 * @param array $files
583 * The current set of files to process.
586 * the return value is ignored
588 public static function xmlMenu(&$files) {
589 return self
::singleton()->invoke(['files'], $files,
590 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
596 * (Experimental) This hook is called when build the menu table.
598 * @param array $items
599 * List of records to include in menu table.
601 * the return value is ignored
603 public static function alterMenu(&$items) {
604 return self
::singleton()->invoke(['items'], $items,
605 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
611 * A theme is a set of CSS files which are loaded on CiviCRM pages. To register a new
612 * theme, add it to the $themes array. Use these properties:
614 * - ext: string (required)
615 * The full name of the extension which defines the theme.
616 * Ex: "org.civicrm.themes.greenwich".
617 * - title: string (required)
619 * - help: string (optional)
620 * Description of the theme's appearance.
621 * - url_callback: mixed (optional)
622 * A function ($themes, $themeKey, $cssExt, $cssFile) which returns the URL(s) for a CSS resource.
623 * Returns either an array of URLs or PASSTHRU.
624 * Ex: \Civi\Core\Themes\Resolvers::simple (default)
625 * Ex: \Civi\Core\Themes\Resolvers::none
626 * - prefix: string (optional)
627 * A prefix within the extension folder to prepend to the file name.
628 * - search_order: array (optional)
629 * A list of themes to search.
630 * Generally, the last theme should be "*fallback*" (Civi\Core\Themes::FALLBACK).
631 * - excludes: array (optional)
632 * A list of files (eg "civicrm:css/bootstrap.css" or "$ext:$file") which should never
633 * be returned (they are excluded from display).
635 * @param array $themes
636 * List of themes, keyed by name.
638 * the return value is ignored
640 public static function themes(&$themes) {
641 return self
::singleton()->invoke(1, $themes,
642 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
648 * The activeTheme hook determines which theme is active.
650 * @param string $theme
651 * The identifier for the theme. Alterable.
653 * @param array $context
654 * Information about the current page-request. Includes some mix of:
655 * - page: the relative path of the current Civi page (Ex: 'civicrm/dashboard').
656 * - themes: an instance of the Civi\Core\Themes service.
658 * the return value is ignored
660 public static function activeTheme(&$theme, $context) {
661 return self
::singleton()->invoke(array('theme', 'context'), $theme, $context,
662 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
663 'civicrm_activeTheme'
668 * This hook is called for declaring managed entities via API.
670 * @param array $entities
671 * List of pending entities. Each entity is an array with keys:
672 * + 'module': string; for module-extensions, this is the fully-qualifed name (e.g. "com.example.mymodule"); for CMS modules, the name is prefixed by the CMS (e.g. "drupal.mymodule")
673 * + 'name': string, a symbolic name which can be used to track this entity (Note: Each module creates its own namespace)
674 * + 'entity': string, an entity-type supported by the CiviCRM API (Note: this currently must be an entity which supports the 'is_active' property)
675 * + 'params': array, the entity data as supported by the CiviCRM API
676 * + 'update' (v4.5+): string, a policy which describes when to update records
677 * - 'always' (default): always update the managed-entity record; changes in $entities will override any local changes (eg by the site-admin)
678 * - 'never': never update the managed-entity record; changes made locally (eg by the site-admin) will override changes in $entities
679 * + 'cleanup' (v4.5+): string, a policy which describes whether to cleanup the record when it becomes orphaned (ie when $entities no longer references the record)
680 * - 'always' (default): always delete orphaned records
681 * - 'never': never delete orphaned records
682 * - 'unused': only delete orphaned records if there are no other references to it in the DB. (This is determined by calling the API's "getrefcount" action.)
685 * the return value is ignored
687 public static function managed(&$entities) {
688 return self
::singleton()->invoke(['entities'], $entities,
689 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
695 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
697 * @param int $contactID
698 * The contactID for whom the dashboard is being rendered.
699 * @param int $contentPlacement
700 * (output parameter) where should the hook content be displayed.
701 * relative to the activity list
704 * the html snippet to include in the dashboard
706 public static function dashboard($contactID, &$contentPlacement = self
::DASHBOARD_BELOW
) {
707 $retval = self
::singleton()->invoke(['contactID', 'contentPlacement'], $contactID, $contentPlacement,
708 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
713 * Note we need this seemingly unnecessary code because in the event that the implementation
714 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
715 * though we have a default value in this function's declaration above.
717 if (!isset($contentPlacement)) {
718 $contentPlacement = self
::DASHBOARD_BELOW
;
725 * This hook is called before storing recently viewed items.
727 * @param array $recentArray
728 * An array of recently viewed or processed items, for in place modification.
732 public static function recent(&$recentArray) {
733 return self
::singleton()->invoke(['recentArray'], $recentArray,
734 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
740 * Determine how many other records refer to a given record.
742 * @param CRM_Core_DAO $dao
743 * The item for which we want a reference count.
744 * @param array $refCounts
745 * Each item in the array is an Array with keys:
746 * - name: string, eg "sql:civicrm_email:contact_id"
747 * - type: string, eg "sql"
748 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
751 * Return is not really intended to be used.
753 public static function referenceCounts($dao, &$refCounts) {
754 return self
::singleton()->invoke(['dao', 'refCounts'], $dao, $refCounts,
755 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
756 'civicrm_referenceCounts'
761 * This hook is called when building the amount structure for a Contribution or Event Page.
763 * @param int $pageType
764 * Is this a contribution or event page.
765 * @param CRM_Core_Form $form
766 * Reference to the form object.
767 * @param array $amount
768 * The amount structure to be displayed.
772 public static function buildAmount($pageType, &$form, &$amount) {
773 return self
::singleton()->invoke(['pageType', 'form', 'amount'], $pageType, $form, $amount, self
::$_nullObject,
774 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildAmount');
778 * This hook is called when building the state list for a particular country.
780 * @param array $countryID
781 * The country id whose states are being selected.
786 public static function buildStateProvinceForCountry($countryID, &$states) {
787 return self
::singleton()->invoke(['countryID', 'states'], $countryID, $states,
788 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
789 'civicrm_buildStateProvinceForCountry'
794 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
797 * The array of tabs that will be displayed.
798 * @param int $contactID
799 * The contactID for whom the dashboard is being rendered.
802 * @deprecated Use tabset() instead.
804 public static function tabs(&$tabs, $contactID) {
805 return self
::singleton()->invoke(['tabs', 'contactID'], $tabs, $contactID,
806 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabs'
811 * This hook is called when rendering the tabs used for events and potentially
812 * contribution pages, etc.
814 * @param string $tabsetName
815 * Name of the screen or visual element.
817 * Tabs that will be displayed.
818 * @param array $context
819 * Extra data about the screen or context in which the tab is used.
823 public static function tabset($tabsetName, &$tabs, $context) {
824 return self
::singleton()->invoke(['tabsetName', 'tabs', 'context'], $tabsetName, $tabs,
825 $context, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabset'
830 * This hook is called when sending an email / printing labels
832 * @param array $tokens
833 * The list of tokens that can be used for the contact.
837 public static function tokens(&$tokens) {
838 return self
::singleton()->invoke(['tokens'], $tokens,
839 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tokens'
844 * This hook allows modification of the admin panels
846 * @param array $panels
847 * Associated array of admin panels
851 public static function alterAdminPanel(&$panels) {
852 return self
::singleton()->invoke(array('panels'), $panels,
853 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
854 'civicrm_alterAdminPanel'
859 * This hook is called when sending an email / printing labels to get the values for all the
860 * tokens returned by the 'tokens' hook
862 * @param array $details
863 * The array to store the token values indexed by contactIDs (unless it a single).
864 * @param array $contactIDs
865 * An array of contactIDs.
867 * The jobID if this is associated with a CiviMail mailing.
868 * @param array $tokens
869 * The list of tokens associated with the content.
870 * @param string $className
871 * The top level className from where the hook is invoked.
875 public static function tokenValues(
882 return self
::singleton()
883 ->invoke(['details', 'contactIDs', 'jobID', 'tokens', 'className'], $details, $contactIDs, $jobID, $tokens, $className, self
::$_nullObject, 'civicrm_tokenValues');
887 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
890 * @param object $page
891 * The page that will be rendered.
895 public static function pageRun(&$page) {
896 return self
::singleton()->invoke(['page'], $page,
897 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
903 * This hook is called after a copy of an object has been made. The current objects are
904 * Event, Contribution Page and UFGroup
906 * @param string $objectName
907 * Name of the object.
908 * @param object $object
909 * Reference to the copy.
913 public static function copy($objectName, &$object) {
914 return self
::singleton()->invoke(['objectName', 'object'], $objectName, $object,
915 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
921 * This hook is called when a contact unsubscribes from a mailing. It allows modules
922 * to override what the contacts are removed from.
926 * @param int $mailingId
927 * The id of the mailing to unsub from
928 * @param int $contactId
929 * The id of the contact who is unsubscribing
930 * @param array|int $groups
931 * Groups the contact will be removed from.
932 * @param array|int $baseGroups
933 * Base groups (used in smart mailings) the contact will be removed from.
938 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
939 return self
::singleton()
940 ->invoke(['op', 'mailingId', 'contactId', 'groups', 'baseGroups'], $op, $mailingId, $contactId, $groups, $baseGroups, self
::$_nullObject, 'civicrm_unsubscribeGroups');
944 * This hook is called when CiviCRM needs to edit/display a custom field with options
946 * @deprecated in favor of hook_civicrm_fieldOptions
948 * @param int $customFieldID
949 * The custom field ID.
950 * @param array $options
951 * The current set of options for that custom field.
952 * You can add/remove existing options.
953 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
954 * to be careful to not overwrite the array.
955 * Only add/edit/remove the specific field options you intend to affect.
956 * @param bool $detailedFormat
957 * If true, the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
958 * @param array $selectAttributes
959 * Contain select attribute(s) if any.
963 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = []) {
964 // Weird: $selectAttributes is inputted but not outputted.
965 return self
::singleton()->invoke(['customFieldID', 'options', 'detailedFormat'], $customFieldID, $options, $detailedFormat,
966 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
967 'civicrm_customFieldOptions'
972 * Hook for modifying field options
974 * @param string $entity
975 * @param string $field
976 * @param array $options
977 * @param array $params
981 public static function fieldOptions($entity, $field, &$options, $params) {
982 return self
::singleton()->invoke(['entity', 'field', 'options', 'params'], $entity, $field, $options, $params,
983 self
::$_nullObject, self
::$_nullObject,
984 'civicrm_fieldOptions'
990 * This hook is called to display the list of actions allowed after doing a search.
991 * This allows the module developer to inject additional actions or to remove existing actions.
993 * @param string $objectType
994 * The object type for this search.
995 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
996 * @param array $tasks
997 * The current set of tasks for that custom field.
998 * You can add/remove existing tasks.
999 * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class
1000 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
1001 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
1002 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
1003 * found in CRM/$objectType/Task.php.
1007 public static function searchTasks($objectType, &$tasks) {
1008 return self
::singleton()->invoke(['objectType', 'tasks'], $objectType, $tasks,
1009 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1010 'civicrm_searchTasks'
1015 * @param mixed $form
1016 * @param array $params
1020 public static function eventDiscount(&$form, &$params) {
1021 return self
::singleton()->invoke(['form', 'params'], $form, $params,
1022 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1023 'civicrm_eventDiscount'
1028 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
1030 * @param mixed $form
1031 * The form object for which groups / mailings being displayed
1032 * @param array $groups
1033 * The list of groups being included / excluded
1034 * @param array $mailings
1035 * The list of mailings being included / excluded
1039 public static function mailingGroups(&$form, &$groups, &$mailings) {
1040 return self
::singleton()->invoke(['form', 'groups', 'mailings'], $form, $groups, $mailings,
1041 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1042 'civicrm_mailingGroups'
1047 * (Experimental) Modify the list of template-types used for CiviMail composition.
1049 * @param array $types
1050 * Sequentially indexed list of template types. Each type specifies:
1052 * - editorUrl: string, Angular template URL
1053 * - weight: int, priority when picking a default value for new mailings
1056 public static function mailingTemplateTypes(&$types) {
1057 return self
::singleton()->invoke(['types'], $types, self
::$_nullObject, self
::$_nullObject,
1058 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1059 'civicrm_mailingTemplateTypes'
1064 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
1066 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
1067 * You can use it to alter the membership types when first loaded, or after submission
1068 * (for example if you want to gather data in the form and use it to alter the fees).
1070 * @param mixed $form
1071 * The form object that is presenting the page
1072 * @param array $membershipTypes
1073 * The array of membership types and their amount
1077 public static function membershipTypeValues(&$form, &$membershipTypes) {
1078 return self
::singleton()->invoke(['form', 'membershipTypes'], $form, $membershipTypes,
1079 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1080 'civicrm_membershipTypeValues'
1085 * This hook is called when rendering the contact summary.
1087 * @param int $contactID
1088 * The contactID for whom the summary is being rendered
1089 * @param mixed $content
1090 * @param int $contentPlacement
1091 * Specifies where the hook content should be displayed relative to the
1095 * The html snippet to include in the contact summary
1097 public static function summary($contactID, &$content, &$contentPlacement = self
::SUMMARY_BELOW
) {
1098 return self
::singleton()->invoke(['contactID', 'content', 'contentPlacement'], $contactID, $content, $contentPlacement,
1099 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1105 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
1106 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
1107 * If you want to limit the contacts returned to a specific group, or some other criteria
1108 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
1109 * The hook is called when the query is executed to get the list of contacts to display.
1111 * @param mixed $query
1112 * - the query that will be executed (input and output parameter);.
1113 * It's important to realize that the ACL clause is built prior to this hook being fired,
1114 * so your query will ignore any ACL rules that may be defined.
1115 * Your query must return two columns:
1116 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
1118 * @param string $queryText
1119 * The name string to execute the query against (this is the value being typed in by the user).
1120 * @param string $context
1121 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
1123 * The id of the object for which the call is being made.
1124 * For custom fields, it will be the custom field id
1128 public static function contactListQuery(&$query, $queryText, $context, $id) {
1129 return self
::singleton()->invoke(['query', 'queryText', 'context', 'id'], $query, $queryText, $context, $id,
1130 self
::$_nullObject, self
::$_nullObject,
1131 'civicrm_contactListQuery'
1136 * Hook definition for altering payment parameters before talking to a payment processor back end.
1138 * Definition will look like this:
1140 * function hook_civicrm_alterPaymentProcessorParams(
1146 * @param CRM_Core_Payment $paymentObj
1147 * Instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
1148 * See discussion in CRM-16224 as to whether $paymentObj should be passed by reference.
1149 * @param array &$rawParams
1150 * array of params as passed to to the processor
1151 * @param array &$cookedParams
1152 * params after the processor code has translated them into its own key/value pairs
1155 * This return is not really intended to be used.
1157 public static function alterPaymentProcessorParams(
1162 return self
::singleton()->invoke(['paymentObj', 'rawParams', 'cookedParams'], $paymentObj, $rawParams, $cookedParams,
1163 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1164 'civicrm_alterPaymentProcessorParams'
1169 * This hook is called when an email is about to be sent by CiviCRM.
1171 * @param array $params
1172 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
1173 * returnPath, replyTo, headers, attachments (array)
1174 * @param string $context
1175 * The context in which the hook is being invoked, eg 'civimail'.
1179 public static function alterMailParams(&$params, $context = NULL) {
1180 return self
::singleton()->invoke(['params', 'context'], $params, $context,
1181 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1182 'civicrm_alterMailParams'
1187 * This hook is called when membership status is being calculated.
1189 * @param array $membershipStatus
1190 * Membership status details as determined - alter if required.
1191 * @param array $arguments
1192 * Arguments passed in to calculate date.
1197 * - 'exclude_is_admin'
1198 * - 'membership_type_id'
1199 * @param array $membership
1200 * Membership details from the calling function.
1204 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
1205 return self
::singleton()->invoke(['membershipStatus', 'arguments', 'membership'], $membershipStatus, $arguments,
1206 $membership, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1207 'civicrm_alterCalculatedMembershipStatus'
1212 * This hook is called after getting the content of the mail and before tokenizing it.
1214 * @param array $content
1215 * Array fields include: html, text, subject
1219 public static function alterMailContent(&$content) {
1220 return self
::singleton()->invoke(['content'], $content,
1221 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1222 'civicrm_alterMailContent'
1227 * This hook is called when rendering the Manage Case screen.
1229 * @param int $caseID
1233 * Array of data to be displayed, where the key is a unique id to be used for styling (div id's)
1234 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
1236 public static function caseSummary($caseID) {
1237 return self
::singleton()->invoke(['caseID'], $caseID,
1238 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1239 'civicrm_caseSummary'
1244 * This hook is called when locating CiviCase types.
1246 * @param array $caseTypes
1250 public static function caseTypes(&$caseTypes) {
1251 return self
::singleton()
1252 ->invoke(['caseTypes'], $caseTypes, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_caseTypes');
1256 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1257 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
1259 * @param CRM_Core_Config|array $config
1264 public static function config(&$config) {
1265 return self
::singleton()->invoke(['config'], $config,
1266 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1272 * This hooks allows to change option values.
1274 * @deprecated in favor of hook_civicrm_fieldOptions
1276 * @param array $options
1277 * Associated array of option values / id
1278 * @param string $groupName
1283 public static function optionValues(&$options, $groupName) {
1284 return self
::singleton()->invoke(['options', 'groupName'], $options, $groupName,
1285 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1286 'civicrm_optionValues'
1291 * This hook allows modification of the navigation menu.
1293 * @param array $params
1294 * Associated array of navigation menu entry to Modify/Add
1298 public static function navigationMenu(&$params) {
1299 return self
::singleton()->invoke(['params'], $params,
1300 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1301 'civicrm_navigationMenu'
1306 * This hook allows modification of the data used to perform merging of duplicates.
1308 * @param string $type
1309 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1310 * @param array $data
1311 * The data, as described in $type.
1312 * @param int $mainId
1313 * Contact_id of the contact that survives the merge.
1314 * @param int $otherId
1315 * Contact_id of the contact that will be absorbed and deleted.
1316 * @param array $tables
1317 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
1321 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
1322 return self
::singleton()->invoke(['type', 'data', 'mainId', 'otherId', 'tables'], $type, $data, $mainId, $otherId, $tables, self
::$_nullObject, 'civicrm_merge');
1326 * This hook allows modification of the data calculated for merging locations.
1328 * @param array $blocksDAO
1329 * Array of location DAO to be saved. These are arrays in 2 keys 'update' & 'delete'.
1330 * @param int $mainId
1331 * Contact_id of the contact that survives the merge.
1332 * @param int $otherId
1333 * Contact_id of the contact that will be absorbed and deleted.
1334 * @param array $migrationInfo
1335 * Calculated migration info, informational only.
1339 public static function alterLocationMergeData(&$blocksDAO, $mainId, $otherId, $migrationInfo) {
1340 return self
::singleton()->invoke(['blocksDAO', 'mainId', 'otherId', 'migrationInfo'], $blocksDAO, $mainId, $otherId, $migrationInfo, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterLocationMergeData');
1344 * This hook provides a way to override the default privacy behavior for notes.
1346 * @param array &$noteValues
1347 * Associative array of values for this note
1351 public static function notePrivacy(&$noteValues) {
1352 return self
::singleton()->invoke(['noteValues'], $noteValues,
1353 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1354 'civicrm_notePrivacy'
1359 * This hook is called before record is exported as CSV.
1361 * @param string $exportTempTable
1362 * Name of the temporary export table used during export.
1363 * @param array $headerRows
1364 * Header rows for output.
1365 * @param array $sqlColumns
1367 * @param int $exportMode
1368 * Export mode ( contact, contribution, etc...).
1369 * @param string $componentTable
1370 * Name of temporary table
1372 * Array of object's ids
1376 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids) {
1377 return self
::singleton()->invoke(['exportTempTable', 'headerRows', 'sqlColumns', 'exportMode', 'componentTable', 'ids'],
1378 $exportTempTable, $headerRows, $sqlColumns,
1379 $exportMode, $componentTable, $ids,
1385 * This hook allows modification of the queries constructed from dupe rules.
1387 * @param string $obj
1388 * Object of rulegroup class.
1389 * @param string $type
1390 * Type of queries e.g table / threshold.
1391 * @param array $query
1396 public static function dupeQuery($obj, $type, &$query) {
1397 return self
::singleton()->invoke(['obj', 'type', 'query'], $obj, $type, $query,
1398 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1404 * Check for duplicate contacts
1406 * @param array $dedupeParams
1407 * Array of params for finding duplicates: [
1408 * '{parameters returned by CRM_Dedupe_Finder::formatParams}
1409 * 'check_permission' => TRUE/FALSE;
1410 * 'contact_type' => $contactType;
1412 * 'rule_group_id' => $ruleGroupID;
1413 * 'excludedContactIDs' => $excludedContactIDs;
1414 * @param array $dedupeResults
1415 * Array of results ['handled' => TRUE/FALSE, 'ids' => array of IDs of duplicate contacts]
1416 * @param array $contextParams
1417 * The context if relevant, eg. ['event_id' => X]
1421 public static function findDuplicates($dedupeParams, &$dedupeResults, $contextParams) {
1422 return self
::singleton()
1423 ->invoke(['dedupeParams', 'dedupeResults', 'contextParams'], $dedupeParams, $dedupeResults, $contextParams, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_findDuplicates');
1427 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1429 * @param string $type
1430 * Type of mail processed: 'activity' OR 'mailing'.
1431 * @param array &$params the params that were sent to the CiviCRM API function
1432 * @param object $mail
1433 * The mail object which is an ezcMail class.
1434 * @param array &$result the result returned by the api call
1435 * @param string $action
1436 * (optional ) the requested action to be performed if the types was 'mailing'.
1440 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
1441 return self
::singleton()
1442 ->invoke(['type', 'params', 'mail', 'result', 'action'], $type, $params, $mail, $result, $action, self
::$_nullObject, 'civicrm_emailProcessor');
1446 * This hook is called after a row has been processed and the
1447 * record (and associated records imported
1449 * @param string $object
1450 * Object being imported (for now Contact only, later Contribution, Activity,.
1451 * Participant and Member)
1452 * @param string $usage
1453 * Hook usage/location (for now process only, later mapping and others).
1454 * @param string $objectRef
1455 * Import record object.
1456 * @param array $params
1457 * Array with various key values: currently.
1458 * contactID - contact id
1459 * importID - row id in temp table
1460 * importTempTable - name of tempTable
1461 * fieldHeaders - field headers
1462 * fields - import fields
1466 public static function import($object, $usage, &$objectRef, &$params) {
1467 return self
::singleton()->invoke(['object', 'usage', 'objectRef', 'params'], $object, $usage, $objectRef, $params,
1468 self
::$_nullObject, self
::$_nullObject,
1474 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
1475 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
1477 * @param string $entity
1478 * The API entity (like contact).
1479 * @param string $action
1480 * The API action (like get).
1481 * @param array &$params the API parameters
1482 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
1486 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
1487 return self
::singleton()->invoke(['entity', 'action', 'params', 'permissions'], $entity, $action, $params, $permissions,
1488 self
::$_nullObject, self
::$_nullObject,
1489 'civicrm_alterAPIPermissions'
1494 * @param CRM_Core_DAO $dao
1498 public static function postSave(&$dao) {
1499 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1500 return self
::singleton()->invoke(['dao'], $dao,
1501 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1507 * This hook allows user to customize context menu Actions on contact summary page.
1509 * @param array $actions
1510 * Array of all Actions in contextmenu.
1511 * @param int $contactID
1512 * ContactID for the summary page.
1516 public static function summaryActions(&$actions, $contactID = NULL) {
1517 return self
::singleton()->invoke(['actions', 'contactID'], $actions, $contactID,
1518 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1519 'civicrm_summaryActions'
1524 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1525 * This enables us hook implementors to modify both the headers and the rows
1527 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1528 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1530 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1531 * you want displayed. This is a hackish, but avoids template modification.
1533 * @param string $objectName
1534 * The component name that we are doing the search.
1535 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
1536 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1537 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
1538 * @param array $selector
1539 * the selector object. Allows you access to the context of the search
1542 * modify the header and values object to pass the data you need
1544 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
1545 return self
::singleton()->invoke(['objectName', 'headers', 'rows', 'selector'], $objectName, $headers, $rows, $selector,
1546 self
::$_nullObject, self
::$_nullObject,
1547 'civicrm_searchColumns'
1552 * This hook is called when uf groups are being built for a module.
1554 * @param string $moduleName
1556 * @param array $ufGroups
1557 * Array of ufgroups for a module.
1561 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
1562 return self
::singleton()->invoke(['moduleName', 'ufGroups'], $moduleName, $ufGroups,
1563 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1564 'civicrm_buildUFGroupsForModule'
1569 * This hook is called when we are determining the contactID for a specific
1572 * @param string $email
1573 * The email address.
1574 * @param int $contactID
1575 * The contactID that matches this email address, IF it exists.
1576 * @param array $result
1577 * (reference) has two fields.
1578 * contactID - the new (or same) contactID
1579 * action - 3 possible values:
1580 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1581 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1582 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
1586 public static function emailProcessorContact($email, $contactID, &$result) {
1587 return self
::singleton()->invoke(['email', 'contactID', 'result'], $email, $contactID, $result,
1588 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1589 'civicrm_emailProcessorContact'
1594 * Hook definition for altering the generation of Mailing Labels.
1596 * @param array $args
1597 * An array of the args in the order defined for the tcpdf multiCell api call.
1598 * with the variable names below converted into string keys (ie $w become 'w'
1599 * as the first key for $args)
1600 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1601 * float $h Cell minimum height. The cell extends automatically if needed.
1602 * string $txt String to print
1603 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1604 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1605 * a string containing some or all of the following characters (in any order):
1606 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1607 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1608 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1609 * (default value when $ishtml=false)</li></ul>
1610 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1611 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1612 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1613 * float $x x position in user units
1614 * float $y y position in user units
1615 * boolean $reseth if true reset the last cell height (default true).
1616 * int $stretch stretch character mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
1617 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1618 * necessary</li><li>4 = forced character spacing</li></ul>
1619 * boolean $ishtml set to true if $txt is HTML content (default = false).
1620 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1621 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1622 * or 0 for disable this feature. This feature works only when $ishtml=false.
1626 public static function alterMailingLabelParams(&$args) {
1627 return self
::singleton()->invoke(['args'], $args,
1628 self
::$_nullObject, self
::$_nullObject,
1629 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1630 'civicrm_alterMailingLabelParams'
1635 * This hooks allows alteration of generated page content.
1638 * Previously generated content.
1640 * Context of content - page or form.
1642 * The file name of the tpl.
1644 * A reference to the page or form object.
1648 public static function alterContent(&$content, $context, $tplName, &$object) {
1649 return self
::singleton()->invoke(['content', 'context', 'tplName', 'object'], $content, $context, $tplName, $object,
1650 self
::$_nullObject, self
::$_nullObject,
1651 'civicrm_alterContent'
1656 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1657 * altercontent hook as the content has already been rendered through the tpl at that point
1660 * Previously generated content.
1662 * Reference to the form object.
1664 * Context of content - page or form.
1666 * Reference the file name of the tpl.
1670 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
1671 return self
::singleton()->invoke(['formName', 'form', 'context', 'tplName'], $formName, $form, $context, $tplName,
1672 self
::$_nullObject, self
::$_nullObject,
1673 'civicrm_alterTemplateFile'
1678 * This hook collects the trigger definition from all components.
1681 * @param string $tableName
1682 * (optional) the name of the table that we are interested in only.
1684 * @internal param \reference $triggerInfo to an array of trigger information
1685 * each element has 4 fields:
1686 * table - array of tableName
1687 * when - BEFORE or AFTER
1688 * event - array of eventName - INSERT OR UPDATE OR DELETE
1689 * sql - array of statements optionally terminated with a ;
1690 * a statement can use the tokes {tableName} and {eventName}
1691 * to do token replacement with the table / event. This allows
1692 * templatizing logging and other hooks
1695 public static function triggerInfo(&$info, $tableName = NULL) {
1696 return self
::singleton()->invoke(['info', 'tableName'], $info, $tableName,
1697 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1699 'civicrm_triggerInfo'
1704 * This hook allows changes to the spec of which tables to log.
1706 * @param array $logTableSpec
1710 public static function alterLogTables(&$logTableSpec) {
1711 return self
::singleton()->invoke(['logTableSpec'], $logTableSpec, $_nullObject,
1712 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1714 'civicrm_alterLogTables'
1719 * This hook is called when a module-extension is installed.
1720 * Each module will receive hook_civicrm_install during its own installation (but not during the
1721 * installation of unrelated modules).
1723 public static function install() {
1724 return self
::singleton()->invoke(0, self
::$_nullObject,
1725 self
::$_nullObject, self
::$_nullObject,
1726 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1732 * This hook is called when a module-extension is uninstalled.
1733 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1734 * uninstallation of unrelated modules).
1736 public static function uninstall() {
1737 return self
::singleton()->invoke(0, self
::$_nullObject,
1738 self
::$_nullObject, self
::$_nullObject,
1739 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1745 * This hook is called when a module-extension is re-enabled.
1746 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1747 * re-enablement of unrelated modules).
1749 public static function enable() {
1750 return self
::singleton()->invoke(0, self
::$_nullObject,
1751 self
::$_nullObject, self
::$_nullObject,
1752 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1758 * This hook is called when a module-extension is disabled.
1759 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1760 * disablement of unrelated modules).
1762 public static function disable() {
1763 return self
::singleton()->invoke(0, self
::$_nullObject,
1764 self
::$_nullObject, self
::$_nullObject,
1765 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1773 * This hook is called when the browser is being re-directed and allows the url
1776 * @param \Psr\Http\Message\UriInterface $url
1777 * @param array $context
1778 * Additional information about context
1779 * - output - if this is 'json' then it will return json.
1782 * the return value is ignored
1784 public static function alterRedirect(&$url, &$context) {
1785 return self
::singleton()->invoke(['url', 'context'], $url,
1786 $context, self
::$_nullObject,
1787 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1788 'civicrm_alterRedirect'
1799 public static function alterReportVar($varType, &$var, &$object) {
1800 return self
::singleton()->invoke(['varType', 'var', 'object'], $varType, $var, $object,
1802 self
::$_nullObject, self
::$_nullObject,
1803 'civicrm_alterReportVar'
1808 * This hook is called to drive database upgrades for extension-modules.
1811 * The type of operation being performed; 'check' or 'enqueue'.
1812 * @param CRM_Queue_Queue $queue
1813 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
1816 * NULL, if $op is 'enqueue'.
1817 * TRUE, if $op is 'check' and upgrades are pending.
1818 * FALSE, if $op is 'check' and upgrades are not pending.
1820 public static function upgrade($op, CRM_Queue_Queue
$queue = NULL) {
1821 return self
::singleton()->invoke(['op', 'queue'], $op, $queue,
1822 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1829 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1831 * @param array $params
1832 * The mailing parameters. Array fields include: groupName, from, toName,
1833 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1834 * attachments (array)
1838 public static function postEmailSend(&$params) {
1839 return self
::singleton()->invoke(['params'], $params,
1840 self
::$_nullObject, self
::$_nullObject,
1841 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1842 'civicrm_postEmailSend'
1847 * This hook is called when a CiviMail mailing has completed
1849 * @param int $mailingId
1854 public static function postMailing($mailingId) {
1855 return self
::singleton()->invoke(['mailingId'], $mailingId,
1856 self
::$_nullObject, self
::$_nullObject,
1857 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1858 'civicrm_postMailing'
1863 * This hook is called when Settings specifications are loaded.
1865 * @param array $settingsFolders
1866 * List of paths from which to derive metadata
1870 public static function alterSettingsFolders(&$settingsFolders) {
1871 return self
::singleton()->invoke(['settingsFolders'], $settingsFolders,
1872 self
::$_nullObject, self
::$_nullObject,
1873 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1874 'civicrm_alterSettingsFolders'
1879 * This hook is called when Settings have been loaded from the xml
1880 * It is an opportunity for hooks to alter the data
1882 * @param array $settingsMetaData
1883 * Settings Metadata.
1884 * @param int $domainID
1885 * @param mixed $profile
1889 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
1890 return self
::singleton()->invoke(['settingsMetaData', 'domainID', 'profile'], $settingsMetaData,
1891 $domainID, $profile,
1892 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1893 'civicrm_alterSettingsMetaData'
1898 * This hook is called before running an api call.
1900 * @param API_Wrapper[] $wrappers
1901 * (see CRM_Utils_API_ReloadOption as an example)
1902 * @param mixed $apiRequest
1905 * The return value is ignored
1907 public static function apiWrappers(&$wrappers, $apiRequest) {
1908 return self
::singleton()
1909 ->invoke(['wrappers', 'apiRequest'], $wrappers, $apiRequest, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1910 self
::$_nullObject, 'civicrm_apiWrappers'
1915 * This hook is called before running pending cron jobs.
1917 * @param CRM_Core_JobManager $jobManager
1920 * The return value is ignored.
1922 public static function cron($jobManager) {
1923 return self
::singleton()->invoke(['jobManager'],
1924 $jobManager, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1930 * This hook is called when loading CMS permissions; use this hook to modify
1931 * the array of system permissions for CiviCRM.
1933 * @param array $permissions
1934 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1935 * the format of this array.
1938 * The return value is ignored
1940 public static function permission(&$permissions) {
1941 return self
::singleton()->invoke(['permissions'], $permissions,
1942 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1943 'civicrm_permission'
1948 * This hook is called when checking permissions; use this hook to dynamically
1949 * escalate user permissions in certain use cases (cf. CRM-19256).
1951 * @param string $permission
1952 * The name of an atomic permission, ie. 'access deleted contacts'
1953 * @param bool $granted
1954 * Whether this permission is currently granted. The hook can change this value.
1955 * @param int $contactId
1956 * Contact whose permissions we are checking (if null, assume current user).
1959 * The return value is ignored
1961 public static function permission_check($permission, &$granted, $contactId) {
1962 return self
::singleton()->invoke(['permission', 'granted', 'contactId'], $permission, $granted, $contactId,
1963 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1964 'civicrm_permission_check'
1969 * @param CRM_Core_Exception $exception
1970 * @param mixed $request
1971 * Reserved for future use.
1973 public static function unhandledException($exception, $request = NULL) {
1974 $event = new \Civi\Core\Event\
UnhandledExceptionEvent($exception, self
::$_nullObject);
1975 \Civi
::dispatcher()->dispatch('hook_civicrm_unhandled_exception', $event);
1979 * This hook is called for declaring managed entities via API.
1981 * Note: This is a pre-boot hook. It will dispatch via the extension/module
1982 * subsystem but *not* the Symfony EventDispatcher.
1984 * @param array[] $entityTypes
1985 * List of entity types; each entity-type is an array with keys:
1986 * - name: string, a unique short name (e.g. "ReportInstance")
1987 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
1988 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
1989 * - fields_callback: array, list of callables which manipulates field list
1990 * - links_callback: array, list of callables which manipulates fk list
1993 * The return value is ignored
1995 public static function entityTypes(&$entityTypes) {
1996 return self
::singleton()->invoke(['entityTypes'], $entityTypes, self
::$_nullObject, self
::$_nullObject,
1997 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_entityTypes'
2002 * Build a description of available hooks.
2004 * @param \Civi\Core\CiviEventInspector $inspector
2006 public static function eventDefs($inspector) {
2007 $event = \Civi\Core\Event\GenericHookEvent
::create([
2008 'inspector' => $inspector,
2010 Civi
::dispatcher()->dispatch('hook_civicrm_eventDefs', $event);
2014 * This hook is called while preparing a profile form.
2016 * @param string $profileName
2019 public static function buildProfile($profileName) {
2020 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2021 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildProfile');
2025 * This hook is called while validating a profile form submission.
2027 * @param string $profileName
2030 public static function validateProfile($profileName) {
2031 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2032 self
::$_nullObject, self
::$_nullObject, 'civicrm_validateProfile');
2036 * This hook is called processing a valid profile form submission.
2038 * @param string $profileName
2041 public static function processProfile($profileName) {
2042 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2043 self
::$_nullObject, self
::$_nullObject, 'civicrm_processProfile');
2047 * This hook is called while preparing a read-only profile screen
2049 * @param string $profileName
2052 public static function viewProfile($profileName) {
2053 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2054 self
::$_nullObject, self
::$_nullObject, 'civicrm_viewProfile');
2058 * This hook is called while preparing a list of contacts (based on a profile)
2060 * @param string $profileName
2063 public static function searchProfile($profileName) {
2064 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2065 self
::$_nullObject, self
::$_nullObject, 'civicrm_searchProfile');
2069 * This hook is invoked when building a CiviCRM name badge.
2071 * @param string $labelName
2072 * String referencing name of badge format.
2073 * @param object $label
2074 * Reference to the label object.
2075 * @param array $format
2076 * Array of format data.
2077 * @param array $participant
2078 * Array of participant values.
2081 * the return value is ignored
2083 public static function alterBadge($labelName, &$label, &$format, &$participant) {
2084 return self
::singleton()
2085 ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBadge');
2089 * This hook is called before encoding data in barcode.
2091 * @param array $data
2092 * Associated array of values available for encoding.
2093 * @param string $type
2094 * Type of barcode, classic barcode or QRcode.
2095 * @param string $context
2096 * Where this hooks is invoked.
2100 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
2101 return self
::singleton()->invoke(['data', 'type', 'context'], $data, $type, $context, self
::$_nullObject,
2102 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBarcode');
2106 * Modify or replace the Mailer object used for outgoing mail.
2108 * @param object $mailer
2109 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2110 * @param string $driver
2111 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2112 * @param array $params
2113 * The default mailer config options
2116 * @see Mail::factory
2118 public static function alterMailer(&$mailer, $driver, $params) {
2119 return self
::singleton()
2120 ->invoke(['mailer', 'driver', 'params'], $mailer, $driver, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterMailer');
2124 * Deprecated: Misnamed version of alterMailer(). Remove post-4.7.x.
2125 * Modify or replace the Mailer object used for outgoing mail.
2127 * @param object $mailer
2128 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2129 * @param string $driver
2130 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2131 * @param array $params
2132 * The default mailer config options
2135 * @see Mail::factory
2138 public static function alterMail(&$mailer, $driver, $params) {
2139 // This has been deprecated on the premise it MIGHT be called externally for a long time.
2140 // We don't have a clear policy on how much we support external extensions calling internal
2141 // hooks (ie. in general we say 'don't call internal functions', but some hooks like pre hooks
2142 // are expected to be called externally.
2143 // It's really really unlikely anyone uses this - but let's add deprecations for a couple
2144 // of releases first.
2145 CRM_Core_Error
::deprecatedFunctionWarning('CRM_Utils_Hook::alterMailer');
2146 return CRM_Utils_Hook
::alterMailer($mailer, $driver, $params);
2150 * This hook is called while building the core search query,
2151 * so hook implementers can provide their own query objects which alters/extends core search.
2153 * @param array $queryObjects
2154 * @param string $type
2158 public static function queryObjects(&$queryObjects, $type = 'Contact') {
2159 return self
::singleton()
2160 ->invoke(['queryObjects', 'type'], $queryObjects, $type, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_queryObjects');
2164 * This hook is called while viewing contact dashboard.
2166 * @param array $availableDashlets
2167 * List of dashlets; each is formatted per api/v3/Dashboard
2168 * @param array $defaultDashlets
2169 * List of dashlets; each is formatted per api/v3/DashboardContact
2173 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
2174 return self
::singleton()
2175 ->invoke(['availableDashlets', 'defaultDashlets'], $availableDashlets, $defaultDashlets, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_dashboard_defaults');
2179 * This hook is called before a case merge (or a case reassign)
2181 * @param int $mainContactId
2182 * @param int $mainCaseId
2183 * @param int $otherContactId
2184 * @param int $otherCaseId
2185 * @param bool $changeClient
2189 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2190 return self
::singleton()
2191 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_pre_case_merge');
2195 * This hook is called after a case merge (or a case reassign)
2197 * @param int $mainContactId
2198 * @param int $mainCaseId
2199 * @param int $otherContactId
2200 * @param int $otherCaseId
2201 * @param bool $changeClient
2205 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2206 return self
::singleton()
2207 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_post_case_merge');
2212 * Add a hook for altering the display name
2214 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
2216 * @param string $displayName
2217 * @param int $contactId
2218 * @param object $dao
2219 * The contact object.
2223 public static function alterDisplayName(&$displayName, $contactId, $dao) {
2224 return self
::singleton()->invoke(['displayName', 'contactId', 'dao'],
2225 $displayName, $contactId, $dao, self
::$_nullObject, self
::$_nullObject,
2226 self
::$_nullObject, 'civicrm_contact_get_displayname'
2231 * Modify the CRM_Core_Resources settings data.
2233 * @param array $data
2234 * @see CRM_Core_Resources::addSetting
2236 public static function alterResourceSettings(&$data) {
2237 $event = \Civi\Core\Event\GenericHookEvent
::create([
2240 Civi
::dispatcher()->dispatch('hook_civicrm_alterResourceSettings', $event);
2244 * EXPERIMENTAL: This hook allows one to register additional Angular modules
2246 * @param array $angularModules
2247 * List of modules. Each module defines:
2248 * - ext: string, the CiviCRM extension which hosts the files.
2249 * - js: array, list of JS files or globs.
2250 * - css: array, list of CSS files or globs.
2251 * - partials: array, list of base-dirs containing HTML.
2252 * - requires: array, list of required Angular modules.
2253 * - basePages: array, uncondtionally load this module onto the given Angular pages. [v4.7.21+]
2254 * If omitted, default to "array('civicrm/a')" for backward compat.
2255 * For a utility that should only be loaded on-demand, use "array()".
2256 * For a utility that should be loaded in all pages use, "array('*')".
2258 * the return value is ignored
2261 * function mymod_civicrm_angularModules(&$angularModules) {
2262 * $angularModules['myAngularModule'] = array(
2263 * 'ext' => 'org.example.mymod',
2264 * 'js' => array('js/myAngularModule.js'),
2266 * $angularModules['myBigAngularModule'] = array(
2267 * 'ext' => 'org.example.mymod',
2268 * 'js' => array('js/part1.js', 'js/part2.js', 'ext://other.ext.name/file.js', 'assetBuilder://dynamicAsset.js'),
2269 * 'css' => array('css/myAngularModule.css', 'ext://other.ext.name/file.css', 'assetBuilder://dynamicAsset.css'),
2270 * 'partials' => array('partials/myBigAngularModule'),
2271 * 'requires' => array('otherModuleA', 'otherModuleB'),
2272 * 'basePages' => array('civicrm/a'),
2277 public static function angularModules(&$angularModules) {
2278 return self
::singleton()->invoke(['angularModules'], $angularModules,
2279 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2280 'civicrm_angularModules'
2285 * Alter the definition of some Angular HTML partials.
2287 * @param \Civi\Angular\Manager $angular
2290 * function example_civicrm_alterAngular($angular) {
2291 * $changeSet = \Civi\Angular\ChangeSet::create('mychanges')
2292 * ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) {
2293 * $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')');
2296 * $angular->add($changeSet);
2300 public static function alterAngular($angular) {
2301 $event = \Civi\Core\Event\GenericHookEvent
::create([
2302 'angular' => $angular,
2304 Civi
::dispatcher()->dispatch('hook_civicrm_alterAngular', $event);
2308 * This hook is called when building a link to a semi-static asset.
2310 * @param string $asset
2311 * The name of the asset.
2312 * Ex: 'angular.json'
2313 * @param array $params
2314 * List of optional arguments which influence the content.
2316 * the return value is ignored
2318 public static function getAssetUrl(&$asset, &$params) {
2319 return self
::singleton()->invoke(['asset', 'params'],
2320 $asset, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2321 'civicrm_getAssetUrl'
2326 * This hook is called whenever the system builds a new copy of
2327 * semi-static asset.
2329 * @param string $asset
2330 * The name of the asset.
2331 * Ex: 'angular.json'
2332 * @param array $params
2333 * List of optional arguments which influence the content.
2334 * Note: Params are immutable because they are part of the cache-key.
2335 * @param string $mimeType
2336 * Initially, NULL. Modify to specify the mime-type.
2337 * @param string $content
2338 * Initially, NULL. Modify to specify the rendered content.
2340 * the return value is ignored
2342 public static function buildAsset($asset, $params, &$mimeType, &$content) {
2343 return self
::singleton()->invoke(['asset', 'params', 'mimeType', 'content'],
2344 $asset, $params, $mimeType, $content, self
::$_nullObject, self
::$_nullObject,
2345 'civicrm_buildAsset'
2350 * This hook fires whenever a record in a case changes.
2352 * @param \Civi\CCase\Analyzer $analyzer
2353 * A bundle of data about the case (such as the case and activity records).
2355 public static function caseChange(\Civi\CCase\Analyzer
$analyzer) {
2356 $event = new \Civi\CCase\Event\
CaseChangeEvent($analyzer);
2357 \Civi
::dispatcher()->dispatch('hook_civicrm_caseChange', $event);
2361 * Generate a default CRUD URL for an entity.
2363 * @param array $spec
2365 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
2366 * - entity_table: string
2368 * @param CRM_Core_DAO $bao
2369 * @param array $link
2370 * To define the link, add these keys to $link:.
2374 * - url: string (used in lieu of "path"/"query")
2375 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
2378 public static function crudLink($spec, $bao, &$link) {
2379 return self
::singleton()->invoke(['spec', 'bao', 'link'], $spec, $bao, $link,
2380 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2386 * Modify the CiviCRM container - add new services, parameters, extensions, etc.
2389 * use Symfony\Component\Config\Resource\FileResource;
2390 * use Symfony\Component\DependencyInjection\Definition;
2392 * function mymodule_civicrm_container($container) {
2393 * $container->addResource(new FileResource(__FILE__));
2394 * $container->setDefinition('mysvc', new Definition('My\Class', array()));
2398 * Tip: The container configuration will be compiled/cached. The default cache
2399 * behavior is aggressive. When you first implement the hook, be sure to
2400 * flush the cache. Additionally, you should relax caching during development.
2401 * In `civicrm.settings.php`, set define('CIVICRM_CONTAINER_CACHE', 'auto').
2403 * Note: This is a preboot hook. It will dispatch via the extension/module
2404 * subsystem but *not* the Symfony EventDispatcher.
2406 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
2407 * @see http://symfony.com/doc/current/components/dependency_injection/index.html
2409 public static function container(\Symfony\Component\DependencyInjection\ContainerBuilder
$container) {
2410 self
::singleton()->invoke(['container'], $container, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_container');
2414 * @param array $fileSearches CRM_Core_FileSearchInterface
2417 public static function fileSearches(&$fileSearches) {
2418 return self
::singleton()->invoke(['fileSearches'], $fileSearches,
2419 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2420 'civicrm_fileSearches'
2425 * Check system status.
2427 * @param array $messages
2428 * Array<CRM_Utils_Check_Message>. A list of messages regarding system status.
2431 public static function check(&$messages) {
2432 return self
::singleton()
2433 ->invoke(['messages'], $messages, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_check');
2437 * This hook is called when a query string of the CSV Batch export is generated.
2439 * @param string $query
2443 public static function batchQuery(&$query) {
2444 return self
::singleton()->invoke(['query'], $query, self
::$_nullObject,
2445 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2446 'civicrm_batchQuery'
2451 * This hook is called to alter Deferred revenue item values just before they are
2452 * inserted in civicrm_financial_trxn table
2454 * @param array $deferredRevenues
2456 * @param array $contributionDetails
2458 * @param bool $update
2460 * @param string $context
2464 public static function alterDeferredRevenueItems(&$deferredRevenues, $contributionDetails, $update, $context) {
2465 return self
::singleton()->invoke(['deferredRevenues', 'contributionDetails', 'update', 'context'], $deferredRevenues, $contributionDetails, $update, $context,
2466 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterDeferredRevenueItems'
2471 * This hook is called when the entries of the CSV Batch export are mapped.
2473 * @param array $results
2474 * @param array $items
2478 public static function batchItems(&$results, &$items) {
2479 return self
::singleton()->invoke(['results', 'items'], $results, $items,
2480 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2481 'civicrm_batchItems'
2486 * This hook is called when core resources are being loaded
2488 * @see CRM_Core_Resources::coreResourceList
2490 * @param array $list
2491 * @param string $region
2493 public static function coreResourceList(&$list, $region) {
2494 self
::singleton()->invoke(['list', 'region'], $list, $region,
2495 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2496 'civicrm_coreResourceList'
2501 * Allows the list of filters on the EntityRef widget to be altered.
2503 * @see CRM_Core_Resources::entityRefFilters
2505 * @param array $filters
2506 * @param array $links
2508 public static function entityRefFilters(&$filters, &$links = NULL) {
2509 self
::singleton()->invoke(['filters', 'links'], $filters, $links, self
::$_nullObject,
2510 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2511 'civicrm_entityRefFilters'
2516 * This hook is called for bypass a few civicrm urls from IDS check.
2518 * @param array $skip list of civicrm urls
2522 public static function idsException(&$skip) {
2523 return self
::singleton()->invoke(['skip'], $skip, self
::$_nullObject,
2524 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2525 'civicrm_idsException'
2530 * This hook is called when a geocoder's format method is called.
2532 * @param string $geoProvider
2533 * @param array $values
2534 * @param SimpleXMLElement $xml
2538 public static function geocoderFormat($geoProvider, &$values, $xml) {
2539 return self
::singleton()->invoke(['geoProvider', 'values', 'xml'], $geoProvider, $values, $xml,
2540 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2541 'civicrm_geocoderFormat'
2546 * This hook is called before an inbound SMS is processed.
2548 * @param \CRM_SMS_Message $message
2549 * An SMS message received
2552 public static function inboundSMS(&$message) {
2553 return self
::singleton()->invoke(['message'], $message, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_inboundSMS');
2557 * This hook is called to modify api params of EntityRef form field
2559 * @param array $params
2560 * @param string $formName
2563 public static function alterEntityRefParams(&$params, $formName) {
2564 return self
::singleton()->invoke(['params', 'formName'], $params, $formName,
2565 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2566 'civicrm_alterEntityRefParams'
2571 * This hook is called before a scheduled job is executed
2573 * @param CRM_Core_DAO_Job $job
2574 * The job to be executed
2575 * @param array $params
2576 * The arguments to be given to the job
2578 public static function preJob($job, $params) {
2579 return self
::singleton()->invoke(['job', 'params'], $job, $params,
2580 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2586 * This hook is called after a scheduled job is executed
2588 * @param CRM_Core_DAO_Job $job
2589 * The job that was executed
2590 * @param array $params
2591 * The arguments given to the job
2592 * @param array $result
2593 * The result of the API call, or the thrown exception if any
2595 public static function postJob($job, $params, $result) {
2596 return self
::singleton()->invoke(['job', 'params', 'result'], $job, $params, $result,
2597 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2603 * This hook is called before and after constructing mail recipients.
2604 * Allows user to alter filter and/or search query to fetch mail recipients
2606 * @param CRM_Mailing_DAO_Mailing $mailingObject
2607 * @param array $criteria
2608 * A list of SQL criteria; you can add/remove/replace/modify criteria.
2609 * Array(string $name => CRM_Utils_SQL_Select $criterion).
2610 * Ex: array('do_not_email' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_email = 0")).
2611 * @param string $context
2615 public static function alterMailingRecipients(&$mailingObject, &$criteria, $context) {
2616 return self
::singleton()->invoke(['mailingObject', 'params', 'context'],
2617 $mailingObject, $criteria, $context,
2618 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2619 'civicrm_alterMailingRecipients'
2624 * ALlow Extensions to custom process IPN hook data such as sending Google Analyitcs information based on the IPN
2625 * @param array $IPNData - Array of IPN Data
2628 public static function postIPNProcess(&$IPNData) {
2629 return self
::singleton()->invoke(['IPNData'],
2630 $IPNData, self
::$_nullObject, self
::$_nullObject,
2631 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2632 'civicrm_postIPNProcess'