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;
55 public static $_nullObject = NULL;
58 * We only need one instance of this object. So we use the singleton
59 * pattern and cache the instance in this variable
63 static private $_singleton = NULL;
68 private $commonIncluded = FALSE;
73 private $commonCiviModules = [];
76 * @var CRM_Utils_Cache_Interface
81 * Constructor and getter for the singleton instance.
86 * An instance of $config->userHookClass
88 public static function singleton($fresh = FALSE) {
89 if (self
::$_singleton == NULL ||
$fresh) {
90 $config = CRM_Core_Config
::singleton();
91 $class = $config->userHookClass
;
92 self
::$_singleton = new $class();
94 return self
::$_singleton;
98 * CRM_Utils_Hook constructor.
100 public function __construct() {
101 $this->cache
= CRM_Utils_Cache
::create([
103 'type' => ['ArrayCache'],
109 * Invoke a hook through the UF/CMS hook system and the extension-hook
112 * @param int $numParams
113 * Number of parameters to pass to the hook.
115 * Parameter to be passed to the hook.
117 * Parameter to be passed to the hook.
119 * Parameter to be passed to the hook.
121 * Parameter to be passed to the hook.
123 * Parameter to be passed to the hook.
125 * Parameter to be passed to the hook.
126 * @param string $fnSuffix
127 * Function suffix, this is effectively the hook name.
131 abstract public function invokeViaUF(
133 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
140 * This is a transitional adapter. It supports the legacy syntax
141 * but also accepts enough information to support Symfony Event
144 * @param array|int $names
145 * (Recommended) Array of parameter names, in order.
146 * Using an array is recommended because it enables full
147 * event-broadcasting behaviors.
148 * (Legacy) Number of parameters to pass to the hook.
149 * This is provided for transitional purposes.
156 * @param mixed $fnSuffix
159 public function invoke(
161 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
164 // Per https://github.com/civicrm/civicrm-core/pull/13551 we have had ongoing significant problems where hooks from modules are
165 // invoked during upgrade but not those from extensions. The issues are both that an incorrect module list & settings are cached and that
166 // some hooks REALLY need to run during upgrade - the loss of triggers during upgrade causes significant loss of data
167 // whereas loss of logTable hooks means that log tables are created for tables specifically excluded - e.g due to large
168 // quantities of low-importance data or the table not having an id field, which could cause a fatal error.
169 // Instead of not calling any hooks we only call those we know to be frequently important - if a particular extension wanted
170 // to avoid this they could do an early return on CRM_Core_Config::singleton()->isUpgradeMode
171 $upgradeFriendlyHooks = ['civicrm_alterSettingsFolders', 'civicrm_alterSettingsMetaData', 'civicrm_triggerInfo', 'civicrm_alterLogTables', 'civicrm_container'];
172 if (CRM_Core_Config
::singleton()->isUpgradeMode() && !in_array($fnSuffix, $upgradeFriendlyHooks)) {
175 if (is_array($names) && !defined('CIVICRM_FORCE_LEGACY_HOOK') && \Civi\Core\Container
::isContainerBooted()) {
176 $event = \Civi\Core\Event\GenericHookEvent
::createOrdered(
178 array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6)
180 \Civi
::dispatcher()->dispatch('hook_' . $fnSuffix, $event);
181 return $event->getReturnValues();
184 $count = is_array($names) ?
count($names) : $names;
185 return $this->invokeViaUF($count, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $fnSuffix);
190 * @param array $numParams
202 public function commonInvoke(
204 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
208 $this->commonBuildModuleList($fnPrefix);
210 return $this->runHooks($this->commonCiviModules
, $fnSuffix,
211 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
216 * Build the list of modules to be processed for hooks.
218 * @param string $fnPrefix
220 public function commonBuildModuleList($fnPrefix) {
221 if (!$this->commonIncluded
) {
222 // include external file
223 $this->commonIncluded
= TRUE;
225 $config = CRM_Core_Config
::singleton();
226 if (!empty($config->customPHPPathDir
)) {
227 $civicrmHooksFile = CRM_Utils_File
::addTrailingSlash($config->customPHPPathDir
) . 'civicrmHooks.php';
228 if (file_exists($civicrmHooksFile)) {
229 @include_once
$civicrmHooksFile;
233 if (!empty($fnPrefix)) {
234 $this->commonCiviModules
[$fnPrefix] = $fnPrefix;
237 $this->requireCiviModules($this->commonCiviModules
);
242 * @param $civiModules
244 * @param array $numParams
254 public function runHooks(
255 $civiModules, $fnSuffix, $numParams,
256 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
258 // $civiModules is *not* passed by reference because runHooks
259 // must be reentrant. PHP is finicky about running
260 // multiple loops over the same variable. The circumstances
261 // to reproduce the issue are pretty intricate.
264 $fnNames = $this->cache
->get($fnSuffix);
265 if (!is_array($fnNames)) {
267 if ($civiModules !== NULL) {
268 foreach ($civiModules as $module) {
269 $fnName = "{$module}_{$fnSuffix}";
270 if (function_exists($fnName)) {
271 $fnNames[] = $fnName;
274 $this->cache
->set($fnSuffix, $fnNames);
278 foreach ($fnNames as $fnName) {
280 switch ($numParams) {
282 $fResult = $fnName();
286 $fResult = $fnName($arg1);
290 $fResult = $fnName($arg1, $arg2);
294 $fResult = $fnName($arg1, $arg2, $arg3);
298 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
302 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
306 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
310 CRM_Core_Error
::fatal(ts('Invalid hook invocation'));
314 if (!empty($fResult) &&
317 $result = array_merge($result, $fResult);
321 return empty($result) ?
TRUE : $result;
327 public function requireCiviModules(&$moduleList) {
328 $civiModules = CRM_Core_PseudoConstant
::getModuleExtensions();
329 foreach ($civiModules as $civiModule) {
330 if (!file_exists($civiModule['filePath'])) {
331 CRM_Core_Session
::setStatus(
332 ts('Error loading module file (%1). Please restore the file or disable the module.',
333 [1 => $civiModule['filePath']]),
334 ts('Warning'), 'error');
337 include_once $civiModule['filePath'];
338 $moduleList[$civiModule['prefix']] = $civiModule['prefix'];
343 * This hook is called before a db write on some core objects.
344 * This hook does not allow the abort of the operation
347 * The type of operation being performed.
348 * @param string $objectName
349 * The name of the object.
351 * The object id if available.
352 * @param array $params
353 * The parameters used for object creation / editing.
356 * the return value is ignored
358 public static function pre($op, $objectName, $id, &$params) {
359 $event = new \Civi\Core\Event\
PreEvent($op, $objectName, $id, $params);
360 \Civi
::dispatcher()->dispatch('hook_civicrm_pre', $event);
361 return $event->getReturnValues();
365 * This hook is called after a db write on some core objects.
368 * The type of operation being performed.
369 * @param string $objectName
370 * The name of the object.
371 * @param int $objectId
372 * The unique identifier for the object.
373 * @param object $objectRef
374 * The reference to the object if available.
377 * based on op. pre-hooks return a boolean or
378 * an error message which aborts the operation
380 public static function post($op, $objectName, $objectId, &$objectRef = NULL) {
381 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
382 \Civi
::dispatcher()->dispatch('hook_civicrm_post', $event);
383 return $event->getReturnValues();
387 * This hook retrieves links from other modules and injects it into.
388 * the view contact tabs
391 * The type of operation being performed.
392 * @param string $objectName
393 * The name of the object.
394 * @param int $objectId
395 * The unique identifier for the object.
396 * @param array $links
397 * (optional) the links array (introduced in v3.2).
399 * (optional) the bitmask to show/hide links.
400 * @param array $values
401 * (optional) the values to fill the links.
404 * the return value is ignored
406 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = []) {
407 return self
::singleton()->invoke(['op', 'objectName', 'objectId', 'links', 'mask', 'values'], $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
411 * This hook is invoked during the CiviCRM form preProcess phase.
413 * @param string $formName
414 * The name of the form.
415 * @param CRM_Core_Form $form
416 * Reference to the form object.
419 * the return value is ignored
421 public static function preProcess($formName, &$form) {
422 return self
::singleton()
423 ->invoke(['formName', 'form'], $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_preProcess');
427 * This hook is invoked when building a CiviCRM form. This hook should also
428 * be used to set the default values of a form element
430 * @param string $formName
431 * The name of the form.
432 * @param CRM_Core_Form $form
433 * Reference to the form object.
436 * the return value is ignored
438 public static function buildForm($formName, &$form) {
439 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
440 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
446 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
447 * any form elements, this hook should save the values in the database
449 * @param string $formName
450 * The name of the form.
451 * @param CRM_Core_Form $form
452 * Reference to the form object.
455 * the return value is ignored
457 public static function postProcess($formName, &$form) {
458 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
459 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
460 'civicrm_postProcess'
465 * This hook is invoked during all CiviCRM form validation. An array of errors
466 * detected is returned. Else we assume validation succeeded.
468 * @param string $formName
469 * The name of the form.
470 * @param array &$fields the POST parameters as filtered by QF
471 * @param array &$files the FILES parameters as sent in by POST
472 * @param array &$form the form object
473 * @param array &$errors the array of errors.
476 * formRule hooks return a boolean or
477 * an array of error messages which display a QF Error
479 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
480 return self
::singleton()
481 ->invoke(['formName', 'fields', 'files', 'form', 'errors'],
482 $formName, $fields, $files, $form, $errors, self
::$_nullObject, 'civicrm_validateForm');
486 * This hook is called after a db write on a custom table.
489 * The type of operation being performed.
490 * @param string $groupID
491 * The custom group ID.
492 * @param object $entityID
493 * The entityID of the row in the custom table.
494 * @param array $params
495 * The parameters that were sent into the calling function.
498 * the return value is ignored
500 public static function custom($op, $groupID, $entityID, &$params) {
501 return self
::singleton()
502 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_custom');
506 * This hook is called when composing the ACL where clause to restrict
507 * visibility of contacts to the logged in user
510 * The type of permission needed.
511 * @param array $tables
512 * (reference ) add the tables that are needed for the select clause.
513 * @param array $whereTables
514 * (reference ) add the tables that are needed for the where clause.
515 * @param int $contactID
516 * The contactID for whom the check is made.
517 * @param string $where
518 * The currrent where clause.
521 * the return value is ignored
523 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
524 return self
::singleton()
525 ->invoke(['type', 'tables', 'whereTables', 'contactID', 'where'], $type, $tables, $whereTables, $contactID, $where, self
::$_nullObject, 'civicrm_aclWhereClause');
529 * This hook is called when composing the ACL where clause to restrict
530 * visibility of contacts to the logged in user
533 * The type of permission needed.
534 * @param int $contactID
535 * The contactID for whom the check is made.
536 * @param string $tableName
537 * The tableName which is being permissioned.
538 * @param array $allGroups
539 * The set of all the objects for the above table.
540 * @param array $currentGroups
541 * The set of objects that are currently permissioned for this contact.
544 * the return value is ignored
546 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
547 return self
::singleton()
548 ->invoke(['type', 'contactID', 'tableName', 'allGroups', 'currentGroups'], $type, $contactID, $tableName, $allGroups, $currentGroups, self
::$_nullObject, 'civicrm_aclGroup');
552 * @param string|CRM_Core_DAO $entity
553 * @param array $clauses
556 public static function selectWhereClause($entity, &$clauses) {
557 $entityName = is_object($entity) ?
_civicrm_api_get_entity_name_from_dao($entity) : $entity;
558 return self
::singleton()->invoke(['entity', 'clauses'], $entityName, $clauses,
559 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
560 'civicrm_selectWhereClause'
565 * This hook is called when building the menu table.
567 * @param array $files
568 * The current set of files to process.
571 * the return value is ignored
573 public static function xmlMenu(&$files) {
574 return self
::singleton()->invoke(['files'], $files,
575 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
581 * (Experimental) This hook is called when build the menu table.
583 * @param array $items
584 * List of records to include in menu table.
586 * the return value is ignored
588 public static function alterMenu(&$items) {
589 return self
::singleton()->invoke(['items'], $items,
590 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
596 * This hook is called for declaring managed entities via API.
598 * @param array $entities
599 * List of pending entities. Each entity is an array with keys:
600 * + '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")
601 * + 'name': string, a symbolic name which can be used to track this entity (Note: Each module creates its own namespace)
602 * + 'entity': string, an entity-type supported by the CiviCRM API (Note: this currently must be an entity which supports the 'is_active' property)
603 * + 'params': array, the entity data as supported by the CiviCRM API
604 * + 'update' (v4.5+): string, a policy which describes when to update records
605 * - 'always' (default): always update the managed-entity record; changes in $entities will override any local changes (eg by the site-admin)
606 * - 'never': never update the managed-entity record; changes made locally (eg by the site-admin) will override changes in $entities
607 * + '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)
608 * - 'always' (default): always delete orphaned records
609 * - 'never': never delete orphaned records
610 * - '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.)
613 * the return value is ignored
615 public static function managed(&$entities) {
616 return self
::singleton()->invoke(['entities'], $entities,
617 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
623 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
625 * @param int $contactID
626 * The contactID for whom the dashboard is being rendered.
627 * @param int $contentPlacement
628 * (output parameter) where should the hook content be displayed.
629 * relative to the activity list
632 * the html snippet to include in the dashboard
634 public static function dashboard($contactID, &$contentPlacement = self
::DASHBOARD_BELOW
) {
635 $retval = self
::singleton()->invoke(['contactID', 'contentPlacement'], $contactID, $contentPlacement,
636 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
641 * Note we need this seemingly unnecessary code because in the event that the implementation
642 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
643 * though we have a default value in this function's declaration above.
645 if (!isset($contentPlacement)) {
646 $contentPlacement = self
::DASHBOARD_BELOW
;
653 * This hook is called before storing recently viewed items.
655 * @param array $recentArray
656 * An array of recently viewed or processed items, for in place modification.
660 public static function recent(&$recentArray) {
661 return self
::singleton()->invoke(['recentArray'], $recentArray,
662 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
668 * Determine how many other records refer to a given record.
670 * @param CRM_Core_DAO $dao
671 * The item for which we want a reference count.
672 * @param array $refCounts
673 * Each item in the array is an Array with keys:
674 * - name: string, eg "sql:civicrm_email:contact_id"
675 * - type: string, eg "sql"
676 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
679 * Return is not really intended to be used.
681 public static function referenceCounts($dao, &$refCounts) {
682 return self
::singleton()->invoke(['dao', 'refCounts'], $dao, $refCounts,
683 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
684 'civicrm_referenceCounts'
689 * This hook is called when building the amount structure for a Contribution or Event Page.
691 * @param int $pageType
692 * Is this a contribution or event page.
693 * @param CRM_Core_Form $form
694 * Reference to the form object.
695 * @param array $amount
696 * The amount structure to be displayed.
700 public static function buildAmount($pageType, &$form, &$amount) {
701 return self
::singleton()->invoke(['pageType', 'form', 'amount'], $pageType, $form, $amount, self
::$_nullObject,
702 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildAmount');
706 * This hook is called when building the state list for a particular country.
708 * @param array $countryID
709 * The country id whose states are being selected.
714 public static function buildStateProvinceForCountry($countryID, &$states) {
715 return self
::singleton()->invoke(['countryID', 'states'], $countryID, $states,
716 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
717 'civicrm_buildStateProvinceForCountry'
722 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
725 * The array of tabs that will be displayed.
726 * @param int $contactID
727 * The contactID for whom the dashboard is being rendered.
730 * @deprecated Use tabset() instead.
732 public static function tabs(&$tabs, $contactID) {
733 return self
::singleton()->invoke(['tabs', 'contactID'], $tabs, $contactID,
734 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabs'
739 * This hook is called when rendering the tabs used for events and potentially
740 * contribution pages, etc.
742 * @param string $tabsetName
743 * Name of the screen or visual element.
745 * Tabs that will be displayed.
746 * @param array $context
747 * Extra data about the screen or context in which the tab is used.
751 public static function tabset($tabsetName, &$tabs, $context) {
752 return self
::singleton()->invoke(['tabsetName', 'tabs', 'context'], $tabsetName, $tabs,
753 $context, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabset'
758 * This hook is called when sending an email / printing labels
760 * @param array $tokens
761 * The list of tokens that can be used for the contact.
765 public static function tokens(&$tokens) {
766 return self
::singleton()->invoke(['tokens'], $tokens,
767 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tokens'
772 * This hook is called when sending an email / printing labels to get the values for all the
773 * tokens returned by the 'tokens' hook
775 * @param array $details
776 * The array to store the token values indexed by contactIDs (unless it a single).
777 * @param array $contactIDs
778 * An array of contactIDs.
780 * The jobID if this is associated with a CiviMail mailing.
781 * @param array $tokens
782 * The list of tokens associated with the content.
783 * @param string $className
784 * The top level className from where the hook is invoked.
788 public static function tokenValues(
795 return self
::singleton()
796 ->invoke(['details', 'contactIDs', 'jobID', 'tokens', 'className'], $details, $contactIDs, $jobID, $tokens, $className, self
::$_nullObject, 'civicrm_tokenValues');
800 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
803 * @param object $page
804 * The page that will be rendered.
808 public static function pageRun(&$page) {
809 return self
::singleton()->invoke(['page'], $page,
810 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
816 * This hook is called after a copy of an object has been made. The current objects are
817 * Event, Contribution Page and UFGroup
819 * @param string $objectName
820 * Name of the object.
821 * @param object $object
822 * Reference to the copy.
826 public static function copy($objectName, &$object) {
827 return self
::singleton()->invoke(['objectName', 'object'], $objectName, $object,
828 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
834 * This hook is called when a contact unsubscribes from a mailing. It allows modules
835 * to override what the contacts are removed from.
839 * @param int $mailingId
840 * The id of the mailing to unsub from
841 * @param int $contactId
842 * The id of the contact who is unsubscribing
843 * @param array|int $groups
844 * Groups the contact will be removed from.
845 * @param array|int $baseGroups
846 * Base groups (used in smart mailings) the contact will be removed from.
851 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
852 return self
::singleton()
853 ->invoke(['op', 'mailingId', 'contactId', 'groups', 'baseGroups'], $op, $mailingId, $contactId, $groups, $baseGroups, self
::$_nullObject, 'civicrm_unsubscribeGroups');
857 * This hook is called when CiviCRM needs to edit/display a custom field with options
859 * @deprecated in favor of hook_civicrm_fieldOptions
861 * @param int $customFieldID
862 * The custom field ID.
863 * @param array $options
864 * The current set of options for that custom field.
865 * You can add/remove existing options.
866 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
867 * to be careful to not overwrite the array.
868 * Only add/edit/remove the specific field options you intend to affect.
869 * @param bool $detailedFormat
870 * If true, the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
871 * @param array $selectAttributes
872 * Contain select attribute(s) if any.
876 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = []) {
877 // Weird: $selectAttributes is inputted but not outputted.
878 return self
::singleton()->invoke(['customFieldID', 'options', 'detailedFormat'], $customFieldID, $options, $detailedFormat,
879 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
880 'civicrm_customFieldOptions'
885 * Hook for modifying field options
887 * @param string $entity
888 * @param string $field
889 * @param array $options
890 * @param array $params
894 public static function fieldOptions($entity, $field, &$options, $params) {
895 return self
::singleton()->invoke(['entity', 'field', 'options', 'params'], $entity, $field, $options, $params,
896 self
::$_nullObject, self
::$_nullObject,
897 'civicrm_fieldOptions'
903 * This hook is called to display the list of actions allowed after doing a search.
904 * This allows the module developer to inject additional actions or to remove existing actions.
906 * @param string $objectType
907 * The object type for this search.
908 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
909 * @param array $tasks
910 * The current set of tasks for that custom field.
911 * You can add/remove existing tasks.
912 * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class
913 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
914 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
915 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
916 * found in CRM/$objectType/Task.php.
920 public static function searchTasks($objectType, &$tasks) {
921 return self
::singleton()->invoke(['objectType', 'tasks'], $objectType, $tasks,
922 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
923 'civicrm_searchTasks'
929 * @param array $params
933 public static function eventDiscount(&$form, &$params) {
934 return self
::singleton()->invoke(['form', 'params'], $form, $params,
935 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
936 'civicrm_eventDiscount'
941 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
944 * The form object for which groups / mailings being displayed
945 * @param array $groups
946 * The list of groups being included / excluded
947 * @param array $mailings
948 * The list of mailings being included / excluded
952 public static function mailingGroups(&$form, &$groups, &$mailings) {
953 return self
::singleton()->invoke(['form', 'groups', 'mailings'], $form, $groups, $mailings,
954 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
955 'civicrm_mailingGroups'
960 * (Experimental) Modify the list of template-types used for CiviMail composition.
962 * @param array $types
963 * Sequentially indexed list of template types. Each type specifies:
965 * - editorUrl: string, Angular template URL
966 * - weight: int, priority when picking a default value for new mailings
969 public static function mailingTemplateTypes(&$types) {
970 return self
::singleton()->invoke(['types'], $types, self
::$_nullObject, self
::$_nullObject,
971 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
972 'civicrm_mailingTemplateTypes'
977 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
979 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
980 * You can use it to alter the membership types when first loaded, or after submission
981 * (for example if you want to gather data in the form and use it to alter the fees).
984 * The form object that is presenting the page
985 * @param array $membershipTypes
986 * The array of membership types and their amount
990 public static function membershipTypeValues(&$form, &$membershipTypes) {
991 return self
::singleton()->invoke(['form', 'membershipTypes'], $form, $membershipTypes,
992 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
993 'civicrm_membershipTypeValues'
998 * This hook is called when rendering the contact summary.
1000 * @param int $contactID
1001 * The contactID for whom the summary is being rendered
1002 * @param mixed $content
1003 * @param int $contentPlacement
1004 * Specifies where the hook content should be displayed relative to the
1008 * The html snippet to include in the contact summary
1010 public static function summary($contactID, &$content, &$contentPlacement = self
::SUMMARY_BELOW
) {
1011 return self
::singleton()->invoke(['contactID', 'content', 'contentPlacement'], $contactID, $content, $contentPlacement,
1012 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1018 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
1019 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
1020 * If you want to limit the contacts returned to a specific group, or some other criteria
1021 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
1022 * The hook is called when the query is executed to get the list of contacts to display.
1024 * @param mixed $query
1025 * - the query that will be executed (input and output parameter);.
1026 * It's important to realize that the ACL clause is built prior to this hook being fired,
1027 * so your query will ignore any ACL rules that may be defined.
1028 * Your query must return two columns:
1029 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
1031 * @param string $queryText
1032 * The name string to execute the query against (this is the value being typed in by the user).
1033 * @param string $context
1034 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
1036 * The id of the object for which the call is being made.
1037 * For custom fields, it will be the custom field id
1041 public static function contactListQuery(&$query, $queryText, $context, $id) {
1042 return self
::singleton()->invoke(['query', 'queryText', 'context', 'id'], $query, $queryText, $context, $id,
1043 self
::$_nullObject, self
::$_nullObject,
1044 'civicrm_contactListQuery'
1049 * Hook definition for altering payment parameters before talking to a payment processor back end.
1051 * Definition will look like this:
1053 * function hook_civicrm_alterPaymentProcessorParams(
1059 * @param CRM_Core_Payment $paymentObj
1060 * Instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
1061 * See discussion in CRM-16224 as to whether $paymentObj should be passed by reference.
1062 * @param array &$rawParams
1063 * array of params as passed to to the processor
1064 * @param array &$cookedParams
1065 * params after the processor code has translated them into its own key/value pairs
1068 * This return is not really intended to be used.
1070 public static function alterPaymentProcessorParams(
1075 return self
::singleton()->invoke(['paymentObj', 'rawParams', 'cookedParams'], $paymentObj, $rawParams, $cookedParams,
1076 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1077 'civicrm_alterPaymentProcessorParams'
1082 * This hook is called when an email is about to be sent by CiviCRM.
1084 * @param array $params
1085 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
1086 * returnPath, replyTo, headers, attachments (array)
1087 * @param string $context
1088 * The context in which the hook is being invoked, eg 'civimail'.
1092 public static function alterMailParams(&$params, $context = NULL) {
1093 return self
::singleton()->invoke(['params', 'context'], $params, $context,
1094 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1095 'civicrm_alterMailParams'
1100 * This hook is called when membership status is being calculated.
1102 * @param array $membershipStatus
1103 * Membership status details as determined - alter if required.
1104 * @param array $arguments
1105 * Arguments passed in to calculate date.
1110 * - 'exclude_is_admin'
1111 * - 'membership_type_id'
1112 * @param array $membership
1113 * Membership details from the calling function.
1117 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
1118 return self
::singleton()->invoke(['membershipStatus', 'arguments', 'membership'], $membershipStatus, $arguments,
1119 $membership, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1120 'civicrm_alterCalculatedMembershipStatus'
1125 * This hook is called after getting the content of the mail and before tokenizing it.
1127 * @param array $content
1128 * Array fields include: html, text, subject
1132 public static function alterMailContent(&$content) {
1133 return self
::singleton()->invoke(['content'], $content,
1134 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1135 'civicrm_alterMailContent'
1140 * This hook is called when rendering the Manage Case screen.
1142 * @param int $caseID
1146 * Array of data to be displayed, where the key is a unique id to be used for styling (div id's)
1147 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
1149 public static function caseSummary($caseID) {
1150 return self
::singleton()->invoke(['caseID'], $caseID,
1151 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1152 'civicrm_caseSummary'
1157 * This hook is called when locating CiviCase types.
1159 * @param array $caseTypes
1163 public static function caseTypes(&$caseTypes) {
1164 return self
::singleton()
1165 ->invoke(['caseTypes'], $caseTypes, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_caseTypes');
1169 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1170 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
1172 * @param CRM_Core_Config|array $config
1177 public static function config(&$config) {
1178 return self
::singleton()->invoke(['config'], $config,
1179 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1185 * This hooks allows to change option values.
1187 * @deprecated in favor of hook_civicrm_fieldOptions
1189 * @param array $options
1190 * Associated array of option values / id
1191 * @param string $groupName
1196 public static function optionValues(&$options, $groupName) {
1197 return self
::singleton()->invoke(['options', 'groupName'], $options, $groupName,
1198 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1199 'civicrm_optionValues'
1204 * This hook allows modification of the navigation menu.
1206 * @param array $params
1207 * Associated array of navigation menu entry to Modify/Add
1211 public static function navigationMenu(&$params) {
1212 return self
::singleton()->invoke(['params'], $params,
1213 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1214 'civicrm_navigationMenu'
1219 * This hook allows modification of the data used to perform merging of duplicates.
1221 * @param string $type
1222 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1223 * @param array $data
1224 * The data, as described in $type.
1225 * @param int $mainId
1226 * Contact_id of the contact that survives the merge.
1227 * @param int $otherId
1228 * Contact_id of the contact that will be absorbed and deleted.
1229 * @param array $tables
1230 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
1234 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
1235 return self
::singleton()->invoke(['type', 'data', 'mainId', 'otherId', 'tables'], $type, $data, $mainId, $otherId, $tables, self
::$_nullObject, 'civicrm_merge');
1239 * This hook allows modification of the data calculated for merging locations.
1241 * @param array $blocksDAO
1242 * Array of location DAO to be saved. These are arrays in 2 keys 'update' & 'delete'.
1243 * @param int $mainId
1244 * Contact_id of the contact that survives the merge.
1245 * @param int $otherId
1246 * Contact_id of the contact that will be absorbed and deleted.
1247 * @param array $migrationInfo
1248 * Calculated migration info, informational only.
1252 public static function alterLocationMergeData(&$blocksDAO, $mainId, $otherId, $migrationInfo) {
1253 return self
::singleton()->invoke(['blocksDAO', 'mainId', 'otherId', 'migrationInfo'], $blocksDAO, $mainId, $otherId, $migrationInfo, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterLocationMergeData');
1257 * This hook provides a way to override the default privacy behavior for notes.
1259 * @param array &$noteValues
1260 * Associative array of values for this note
1264 public static function notePrivacy(&$noteValues) {
1265 return self
::singleton()->invoke(['noteValues'], $noteValues,
1266 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1267 'civicrm_notePrivacy'
1272 * This hook is called before record is exported as CSV.
1274 * @param string $exportTempTable
1275 * Name of the temporary export table used during export.
1276 * @param array $headerRows
1277 * Header rows for output.
1278 * @param array $sqlColumns
1280 * @param int $exportMode
1281 * Export mode ( contact, contribution, etc...).
1282 * @param string $componentTable
1283 * Name of temporary table
1285 * Array of object's ids
1289 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, &$exportMode, &$componentTable, &$ids) {
1290 return self
::singleton()->invoke(['exportTempTable', 'headerRows', 'sqlColumns', 'exportMode', 'componentTable', 'ids'],
1291 $exportTempTable, $headerRows, $sqlColumns,
1292 $exportMode, $componentTable, $ids,
1298 * This hook allows modification of the queries constructed from dupe rules.
1300 * @param string $obj
1301 * Object of rulegroup class.
1302 * @param string $type
1303 * Type of queries e.g table / threshold.
1304 * @param array $query
1309 public static function dupeQuery($obj, $type, &$query) {
1310 return self
::singleton()->invoke(['obj', 'type', 'query'], $obj, $type, $query,
1311 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1317 * Check for duplicate contacts
1319 * @param array $dedupeParams
1320 * Array of params for finding duplicates: [
1321 * '{parameters returned by CRM_Dedupe_Finder::formatParams}
1322 * 'check_permission' => TRUE/FALSE;
1323 * 'contact_type' => $contactType;
1325 * 'rule_group_id' => $ruleGroupID;
1326 * 'excludedContactIDs' => $excludedContactIDs;
1327 * @param array $dedupeResults
1328 * Array of results ['handled' => TRUE/FALSE, 'ids' => array of IDs of duplicate contacts]
1329 * @param array $contextParams
1330 * The context if relevant, eg. ['event_id' => X]
1334 public static function findDuplicates($dedupeParams, &$dedupeResults, $contextParams) {
1335 return self
::singleton()
1336 ->invoke(['dedupeParams', 'dedupeResults', 'contextParams'], $dedupeParams, $dedupeResults, $contextParams, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_findDuplicates');
1340 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1342 * @param string $type
1343 * Type of mail processed: 'activity' OR 'mailing'.
1344 * @param array &$params the params that were sent to the CiviCRM API function
1345 * @param object $mail
1346 * The mail object which is an ezcMail class.
1347 * @param array &$result the result returned by the api call
1348 * @param string $action
1349 * (optional ) the requested action to be performed if the types was 'mailing'.
1353 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
1354 return self
::singleton()
1355 ->invoke(['type', 'params', 'mail', 'result', 'action'], $type, $params, $mail, $result, $action, self
::$_nullObject, 'civicrm_emailProcessor');
1359 * This hook is called after a row has been processed and the
1360 * record (and associated records imported
1362 * @param string $object
1363 * Object being imported (for now Contact only, later Contribution, Activity,.
1364 * Participant and Member)
1365 * @param string $usage
1366 * Hook usage/location (for now process only, later mapping and others).
1367 * @param string $objectRef
1368 * Import record object.
1369 * @param array $params
1370 * Array with various key values: currently.
1371 * contactID - contact id
1372 * importID - row id in temp table
1373 * importTempTable - name of tempTable
1374 * fieldHeaders - field headers
1375 * fields - import fields
1379 public static function import($object, $usage, &$objectRef, &$params) {
1380 return self
::singleton()->invoke(['object', 'usage', 'objectRef', 'params'], $object, $usage, $objectRef, $params,
1381 self
::$_nullObject, self
::$_nullObject,
1387 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
1388 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
1390 * @param string $entity
1391 * The API entity (like contact).
1392 * @param string $action
1393 * The API action (like get).
1394 * @param array &$params the API parameters
1395 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
1399 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
1400 return self
::singleton()->invoke(['entity', 'action', 'params', 'permissions'], $entity, $action, $params, $permissions,
1401 self
::$_nullObject, self
::$_nullObject,
1402 'civicrm_alterAPIPermissions'
1407 * @param CRM_Core_DAO $dao
1411 public static function postSave(&$dao) {
1412 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1413 return self
::singleton()->invoke(['dao'], $dao,
1414 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1420 * This hook allows user to customize context menu Actions on contact summary page.
1422 * @param array $actions
1423 * Array of all Actions in contextmenu.
1424 * @param int $contactID
1425 * ContactID for the summary page.
1429 public static function summaryActions(&$actions, $contactID = NULL) {
1430 return self
::singleton()->invoke(['actions', 'contactID'], $actions, $contactID,
1431 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1432 'civicrm_summaryActions'
1437 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1438 * This enables us hook implementors to modify both the headers and the rows
1440 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1441 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1443 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1444 * you want displayed. This is a hackish, but avoids template modification.
1446 * @param string $objectName
1447 * The component name that we are doing the search.
1448 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
1449 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1450 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
1451 * @param array $selector
1452 * the selector object. Allows you access to the context of the search
1455 * modify the header and values object to pass the data you need
1457 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
1458 return self
::singleton()->invoke(['objectName', 'headers', 'rows', 'selector'], $objectName, $headers, $rows, $selector,
1459 self
::$_nullObject, self
::$_nullObject,
1460 'civicrm_searchColumns'
1465 * This hook is called when uf groups are being built for a module.
1467 * @param string $moduleName
1469 * @param array $ufGroups
1470 * Array of ufgroups for a module.
1474 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
1475 return self
::singleton()->invoke(['moduleName', 'ufGroups'], $moduleName, $ufGroups,
1476 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1477 'civicrm_buildUFGroupsForModule'
1482 * This hook is called when we are determining the contactID for a specific
1485 * @param string $email
1486 * The email address.
1487 * @param int $contactID
1488 * The contactID that matches this email address, IF it exists.
1489 * @param array $result
1490 * (reference) has two fields.
1491 * contactID - the new (or same) contactID
1492 * action - 3 possible values:
1493 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1494 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1495 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
1499 public static function emailProcessorContact($email, $contactID, &$result) {
1500 return self
::singleton()->invoke(['email', 'contactID', 'result'], $email, $contactID, $result,
1501 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1502 'civicrm_emailProcessorContact'
1507 * Hook definition for altering the generation of Mailing Labels.
1509 * @param array $args
1510 * An array of the args in the order defined for the tcpdf multiCell api call.
1511 * with the variable names below converted into string keys (ie $w become 'w'
1512 * as the first key for $args)
1513 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1514 * float $h Cell minimum height. The cell extends automatically if needed.
1515 * string $txt String to print
1516 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1517 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1518 * a string containing some or all of the following characters (in any order):
1519 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1520 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1521 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1522 * (default value when $ishtml=false)</li></ul>
1523 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1524 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1525 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1526 * float $x x position in user units
1527 * float $y y position in user units
1528 * boolean $reseth if true reset the last cell height (default true).
1529 * int $stretch stretch character mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
1530 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1531 * necessary</li><li>4 = forced character spacing</li></ul>
1532 * boolean $ishtml set to true if $txt is HTML content (default = false).
1533 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1534 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1535 * or 0 for disable this feature. This feature works only when $ishtml=false.
1539 public static function alterMailingLabelParams(&$args) {
1540 return self
::singleton()->invoke(['args'], $args,
1541 self
::$_nullObject, self
::$_nullObject,
1542 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1543 'civicrm_alterMailingLabelParams'
1548 * This hooks allows alteration of generated page content.
1551 * Previously generated content.
1553 * Context of content - page or form.
1555 * The file name of the tpl.
1557 * A reference to the page or form object.
1561 public static function alterContent(&$content, $context, $tplName, &$object) {
1562 return self
::singleton()->invoke(['content', 'context', 'tplName', 'object'], $content, $context, $tplName, $object,
1563 self
::$_nullObject, self
::$_nullObject,
1564 'civicrm_alterContent'
1569 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1570 * altercontent hook as the content has already been rendered through the tpl at that point
1573 * Previously generated content.
1575 * Reference to the form object.
1577 * Context of content - page or form.
1579 * Reference the file name of the tpl.
1583 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
1584 return self
::singleton()->invoke(['formName', 'form', 'context', 'tplName'], $formName, $form, $context, $tplName,
1585 self
::$_nullObject, self
::$_nullObject,
1586 'civicrm_alterTemplateFile'
1591 * This hook collects the trigger definition from all components.
1594 * @param string $tableName
1595 * (optional) the name of the table that we are interested in only.
1597 * @internal param \reference $triggerInfo to an array of trigger information
1598 * each element has 4 fields:
1599 * table - array of tableName
1600 * when - BEFORE or AFTER
1601 * event - array of eventName - INSERT OR UPDATE OR DELETE
1602 * sql - array of statements optionally terminated with a ;
1603 * a statement can use the tokes {tableName} and {eventName}
1604 * to do token replacement with the table / event. This allows
1605 * templatizing logging and other hooks
1608 public static function triggerInfo(&$info, $tableName = NULL) {
1609 return self
::singleton()->invoke(['info', 'tableName'], $info, $tableName,
1610 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1612 'civicrm_triggerInfo'
1617 * This hook allows changes to the spec of which tables to log.
1619 * @param array $logTableSpec
1623 public static function alterLogTables(&$logTableSpec) {
1624 return self
::singleton()->invoke(['logTableSpec'], $logTableSpec, $_nullObject,
1625 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1627 'civicrm_alterLogTables'
1632 * This hook is called when a module-extension is installed.
1633 * Each module will receive hook_civicrm_install during its own installation (but not during the
1634 * installation of unrelated modules).
1636 public static function install() {
1637 return self
::singleton()->invoke(0, self
::$_nullObject,
1638 self
::$_nullObject, self
::$_nullObject,
1639 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1645 * This hook is called when a module-extension is uninstalled.
1646 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1647 * uninstallation of unrelated modules).
1649 public static function uninstall() {
1650 return self
::singleton()->invoke(0, self
::$_nullObject,
1651 self
::$_nullObject, self
::$_nullObject,
1652 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1658 * This hook is called when a module-extension is re-enabled.
1659 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1660 * re-enablement of unrelated modules).
1662 public static function enable() {
1663 return self
::singleton()->invoke(0, self
::$_nullObject,
1664 self
::$_nullObject, self
::$_nullObject,
1665 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1671 * This hook is called when a module-extension is disabled.
1672 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1673 * disablement of unrelated modules).
1675 public static function disable() {
1676 return self
::singleton()->invoke(0, self
::$_nullObject,
1677 self
::$_nullObject, self
::$_nullObject,
1678 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1686 * This hook is called when the browser is being re-directed and allows the url
1689 * @param \Psr\Http\Message\UriInterface $url
1690 * @param array $context
1691 * Additional information about context
1692 * - output - if this is 'json' then it will return json.
1695 * the return value is ignored
1697 public static function alterRedirect(&$url, &$context) {
1698 return self
::singleton()->invoke(['url', 'context'], $url,
1699 $context, self
::$_nullObject,
1700 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1701 'civicrm_alterRedirect'
1712 public static function alterReportVar($varType, &$var, &$object) {
1713 return self
::singleton()->invoke(['varType', 'var', 'object'], $varType, $var, $object,
1715 self
::$_nullObject, self
::$_nullObject,
1716 'civicrm_alterReportVar'
1721 * This hook is called to drive database upgrades for extension-modules.
1724 * The type of operation being performed; 'check' or 'enqueue'.
1725 * @param CRM_Queue_Queue $queue
1726 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
1729 * NULL, if $op is 'enqueue'.
1730 * TRUE, if $op is 'check' and upgrades are pending.
1731 * FALSE, if $op is 'check' and upgrades are not pending.
1733 public static function upgrade($op, CRM_Queue_Queue
$queue = NULL) {
1734 return self
::singleton()->invoke(['op', 'queue'], $op, $queue,
1735 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1742 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1744 * @param array $params
1745 * The mailing parameters. Array fields include: groupName, from, toName,
1746 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1747 * attachments (array)
1751 public static function postEmailSend(&$params) {
1752 return self
::singleton()->invoke(['params'], $params,
1753 self
::$_nullObject, self
::$_nullObject,
1754 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1755 'civicrm_postEmailSend'
1760 * This hook is called when a CiviMail mailing has completed
1762 * @param int $mailingId
1767 public static function postMailing($mailingId) {
1768 return self
::singleton()->invoke(['mailingId'], $mailingId,
1769 self
::$_nullObject, self
::$_nullObject,
1770 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1771 'civicrm_postMailing'
1776 * This hook is called when Settings specifications are loaded.
1778 * @param array $settingsFolders
1779 * List of paths from which to derive metadata
1783 public static function alterSettingsFolders(&$settingsFolders) {
1784 return self
::singleton()->invoke(['settingsFolders'], $settingsFolders,
1785 self
::$_nullObject, self
::$_nullObject,
1786 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1787 'civicrm_alterSettingsFolders'
1792 * This hook is called when Settings have been loaded from the xml
1793 * It is an opportunity for hooks to alter the data
1795 * @param array $settingsMetaData
1796 * Settings Metadata.
1797 * @param int $domainID
1798 * @param mixed $profile
1802 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
1803 return self
::singleton()->invoke(['settingsMetaData', 'domainID', 'profile'], $settingsMetaData,
1804 $domainID, $profile,
1805 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1806 'civicrm_alterSettingsMetaData'
1811 * This hook is called before running an api call.
1813 * @param API_Wrapper[] $wrappers
1814 * (see CRM_Utils_API_ReloadOption as an example)
1815 * @param mixed $apiRequest
1818 * The return value is ignored
1820 public static function apiWrappers(&$wrappers, $apiRequest) {
1821 return self
::singleton()
1822 ->invoke(['wrappers', 'apiRequest'], $wrappers, $apiRequest, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1823 self
::$_nullObject, 'civicrm_apiWrappers'
1828 * This hook is called before running pending cron jobs.
1830 * @param CRM_Core_JobManager $jobManager
1833 * The return value is ignored.
1835 public static function cron($jobManager) {
1836 return self
::singleton()->invoke(['jobManager'],
1837 $jobManager, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1843 * This hook is called when loading CMS permissions; use this hook to modify
1844 * the array of system permissions for CiviCRM.
1846 * @param array $permissions
1847 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1848 * the format of this array.
1851 * The return value is ignored
1853 public static function permission(&$permissions) {
1854 return self
::singleton()->invoke(['permissions'], $permissions,
1855 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1856 'civicrm_permission'
1861 * This hook is called when checking permissions; use this hook to dynamically
1862 * escalate user permissions in certain use cases (cf. CRM-19256).
1864 * @param string $permission
1865 * The name of an atomic permission, ie. 'access deleted contacts'
1866 * @param bool $granted
1867 * Whether this permission is currently granted. The hook can change this value.
1868 * @param int $contactId
1869 * Contact whose permissions we are checking (if null, assume current user).
1872 * The return value is ignored
1874 public static function permission_check($permission, &$granted, $contactId) {
1875 return self
::singleton()->invoke(['permission', 'granted', 'contactId'], $permission, $granted, $contactId,
1876 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1877 'civicrm_permission_check'
1882 * @param CRM_Core_ExceptionObject $exception
1883 * @param mixed $request
1884 * Reserved for future use.
1886 public static function unhandledException($exception, $request = NULL) {
1887 $event = new \Civi\Core\Event\
UnhandledExceptionEvent($exception, self
::$_nullObject);
1888 \Civi
::dispatcher()->dispatch('hook_civicrm_unhandled_exception', $event);
1892 * This hook is called for declaring managed entities via API.
1894 * Note: This is a preboot hook. It will dispatch via the extension/module
1895 * subsystem but *not* the Symfony EventDispatcher.
1897 * @param array[] $entityTypes
1898 * List of entity types; each entity-type is an array with keys:
1899 * - name: string, a unique short name (e.g. "ReportInstance")
1900 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
1901 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
1902 * - fields_callback: array, list of callables which manipulates field list
1903 * - links_callback: array, list of callables which manipulates fk list
1906 * The return value is ignored
1908 public static function entityTypes(&$entityTypes) {
1909 return self
::singleton()->invoke(['entityTypes'], $entityTypes, self
::$_nullObject, self
::$_nullObject,
1910 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_entityTypes'
1915 * Build a description of available hooks.
1917 * @param \Civi\Core\CiviEventInspector $inspector
1919 public static function eventDefs($inspector) {
1920 $event = \Civi\Core\Event\GenericHookEvent
::create([
1921 'inspector' => $inspector,
1923 Civi
::dispatcher()->dispatch('hook_civicrm_eventDefs', $event);
1927 * This hook is called while preparing a profile form.
1929 * @param string $profileName
1932 public static function buildProfile($profileName) {
1933 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1934 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildProfile');
1938 * This hook is called while validating a profile form submission.
1940 * @param string $profileName
1943 public static function validateProfile($profileName) {
1944 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1945 self
::$_nullObject, self
::$_nullObject, 'civicrm_validateProfile');
1949 * This hook is called processing a valid profile form submission.
1951 * @param string $profileName
1954 public static function processProfile($profileName) {
1955 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1956 self
::$_nullObject, self
::$_nullObject, 'civicrm_processProfile');
1960 * This hook is called while preparing a read-only profile screen
1962 * @param string $profileName
1965 public static function viewProfile($profileName) {
1966 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1967 self
::$_nullObject, self
::$_nullObject, 'civicrm_viewProfile');
1971 * This hook is called while preparing a list of contacts (based on a profile)
1973 * @param string $profileName
1976 public static function searchProfile($profileName) {
1977 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1978 self
::$_nullObject, self
::$_nullObject, 'civicrm_searchProfile');
1982 * This hook is invoked when building a CiviCRM name badge.
1984 * @param string $labelName
1985 * String referencing name of badge format.
1986 * @param object $label
1987 * Reference to the label object.
1988 * @param array $format
1989 * Array of format data.
1990 * @param array $participant
1991 * Array of participant values.
1994 * the return value is ignored
1996 public static function alterBadge($labelName, &$label, &$format, &$participant) {
1997 return self
::singleton()
1998 ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBadge');
2002 * This hook is called before encoding data in barcode.
2004 * @param array $data
2005 * Associated array of values available for encoding.
2006 * @param string $type
2007 * Type of barcode, classic barcode or QRcode.
2008 * @param string $context
2009 * Where this hooks is invoked.
2013 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
2014 return self
::singleton()->invoke(['data', 'type', 'context'], $data, $type, $context, self
::$_nullObject,
2015 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBarcode');
2019 * Modify or replace the Mailer object used for outgoing mail.
2021 * @param object $mailer
2022 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2023 * @param string $driver
2024 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2025 * @param array $params
2026 * The default mailer config options
2029 * @see Mail::factory
2031 public static function alterMailer(&$mailer, $driver, $params) {
2032 return self
::singleton()
2033 ->invoke(['mailer', 'driver', 'params'], $mailer, $driver, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterMailer');
2037 * Deprecated: Misnamed version of alterMailer(). Remove post-4.7.x.
2038 * Modify or replace the Mailer object used for outgoing mail.
2040 * @param object $mailer
2041 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2042 * @param string $driver
2043 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2044 * @param array $params
2045 * The default mailer config options
2048 * @see Mail::factory
2051 public static function alterMail(&$mailer, $driver, $params) {
2052 // This has been deprecated on the premise it MIGHT be called externally for a long time.
2053 // We don't have a clear policy on how much we support external extensions calling internal
2054 // hooks (ie. in general we say 'don't call internal functions', but some hooks like pre hooks
2055 // are expected to be called externally.
2056 // It's really really unlikely anyone uses this - but let's add deprecations for a couple
2057 // of releases first.
2058 CRM_Core_Error
::deprecatedFunctionWarning('CRM_Utils_Hook::alterMailer');
2059 return CRM_Utils_Hook
::alterMailer($mailer, $driver, $params);
2063 * This hook is called while building the core search query,
2064 * so hook implementers can provide their own query objects which alters/extends core search.
2066 * @param array $queryObjects
2067 * @param string $type
2071 public static function queryObjects(&$queryObjects, $type = 'Contact') {
2072 return self
::singleton()
2073 ->invoke(['queryObjects', 'type'], $queryObjects, $type, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_queryObjects');
2077 * This hook is called while viewing contact dashboard.
2079 * @param array $availableDashlets
2080 * List of dashlets; each is formatted per api/v3/Dashboard
2081 * @param array $defaultDashlets
2082 * List of dashlets; each is formatted per api/v3/DashboardContact
2086 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
2087 return self
::singleton()
2088 ->invoke(['availableDashlets', 'defaultDashlets'], $availableDashlets, $defaultDashlets, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_dashboard_defaults');
2092 * This hook is called before a case merge (or a case reassign)
2094 * @param int $mainContactId
2095 * @param int $mainCaseId
2096 * @param int $otherContactId
2097 * @param int $otherCaseId
2098 * @param bool $changeClient
2102 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2103 return self
::singleton()
2104 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_pre_case_merge');
2108 * This hook is called after a case merge (or a case reassign)
2110 * @param int $mainContactId
2111 * @param int $mainCaseId
2112 * @param int $otherContactId
2113 * @param int $otherCaseId
2114 * @param bool $changeClient
2118 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2119 return self
::singleton()
2120 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_post_case_merge');
2125 * Add a hook for altering the display name
2127 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
2129 * @param string $displayName
2130 * @param int $contactId
2131 * @param object $dao
2132 * The contact object.
2136 public static function alterDisplayName(&$displayName, $contactId, $dao) {
2137 return self
::singleton()->invoke(['displayName', 'contactId', 'dao'],
2138 $displayName, $contactId, $dao, self
::$_nullObject, self
::$_nullObject,
2139 self
::$_nullObject, 'civicrm_contact_get_displayname'
2144 * Modify the CRM_Core_Resources settings data.
2146 * @param array $data
2147 * @see CRM_Core_Resources::addSetting
2149 public static function alterResourceSettings(&$data) {
2150 $event = \Civi\Core\Event\GenericHookEvent
::create([
2153 Civi
::dispatcher()->dispatch('hook_civicrm_alterResourceSettings', $event);
2157 * EXPERIMENTAL: This hook allows one to register additional Angular modules
2159 * @param array $angularModules
2160 * List of modules. Each module defines:
2161 * - ext: string, the CiviCRM extension which hosts the files.
2162 * - js: array, list of JS files or globs.
2163 * - css: array, list of CSS files or globs.
2164 * - partials: array, list of base-dirs containing HTML.
2165 * - requires: array, list of required Angular modules.
2166 * - basePages: array, uncondtionally load this module onto the given Angular pages. [v4.7.21+]
2167 * If omitted, default to "array('civicrm/a')" for backward compat.
2168 * For a utility that should only be loaded on-demand, use "array()".
2169 * For a utility that should be loaded in all pages use, "array('*')".
2171 * the return value is ignored
2174 * function mymod_civicrm_angularModules(&$angularModules) {
2175 * $angularModules['myAngularModule'] = array(
2176 * 'ext' => 'org.example.mymod',
2177 * 'js' => array('js/myAngularModule.js'),
2179 * $angularModules['myBigAngularModule'] = array(
2180 * 'ext' => 'org.example.mymod',
2181 * 'js' => array('js/part1.js', 'js/part2.js', 'ext://other.ext.name/file.js', 'assetBuilder://dynamicAsset.js'),
2182 * 'css' => array('css/myAngularModule.css', 'ext://other.ext.name/file.css', 'assetBuilder://dynamicAsset.css'),
2183 * 'partials' => array('partials/myBigAngularModule'),
2184 * 'requires' => array('otherModuleA', 'otherModuleB'),
2185 * 'basePages' => array('civicrm/a'),
2190 public static function angularModules(&$angularModules) {
2191 return self
::singleton()->invoke(['angularModules'], $angularModules,
2192 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2193 'civicrm_angularModules'
2198 * Alter the definition of some Angular HTML partials.
2200 * @param \Civi\Angular\Manager $angular
2203 * function example_civicrm_alterAngular($angular) {
2204 * $changeSet = \Civi\Angular\ChangeSet::create('mychanges')
2205 * ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) {
2206 * $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')');
2209 * $angular->add($changeSet);
2213 public static function alterAngular($angular) {
2214 $event = \Civi\Core\Event\GenericHookEvent
::create([
2215 'angular' => $angular,
2217 Civi
::dispatcher()->dispatch('hook_civicrm_alterAngular', $event);
2221 * This hook is called when building a link to a semi-static asset.
2223 * @param string $asset
2224 * The name of the asset.
2225 * Ex: 'angular.json'
2226 * @param array $params
2227 * List of optional arguments which influence the content.
2229 * the return value is ignored
2231 public static function getAssetUrl(&$asset, &$params) {
2232 return self
::singleton()->invoke(['asset', 'params'],
2233 $asset, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2234 'civicrm_getAssetUrl'
2239 * This hook is called whenever the system builds a new copy of
2240 * semi-static asset.
2242 * @param string $asset
2243 * The name of the asset.
2244 * Ex: 'angular.json'
2245 * @param array $params
2246 * List of optional arguments which influence the content.
2247 * Note: Params are immutable because they are part of the cache-key.
2248 * @param string $mimeType
2249 * Initially, NULL. Modify to specify the mime-type.
2250 * @param string $content
2251 * Initially, NULL. Modify to specify the rendered content.
2253 * the return value is ignored
2255 public static function buildAsset($asset, $params, &$mimeType, &$content) {
2256 return self
::singleton()->invoke(['asset', 'params', 'mimeType', 'content'],
2257 $asset, $params, $mimeType, $content, self
::$_nullObject, self
::$_nullObject,
2258 'civicrm_buildAsset'
2263 * This hook fires whenever a record in a case changes.
2265 * @param \Civi\CCase\Analyzer $analyzer
2266 * A bundle of data about the case (such as the case and activity records).
2268 public static function caseChange(\Civi\CCase\Analyzer
$analyzer) {
2269 $event = new \Civi\CCase\Event\
CaseChangeEvent($analyzer);
2270 \Civi
::dispatcher()->dispatch('hook_civicrm_caseChange', $event);
2274 * Generate a default CRUD URL for an entity.
2276 * @param array $spec
2278 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
2279 * - entity_table: string
2281 * @param CRM_Core_DAO $bao
2282 * @param array $link
2283 * To define the link, add these keys to $link:.
2287 * - url: string (used in lieu of "path"/"query")
2288 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
2291 public static function crudLink($spec, $bao, &$link) {
2292 return self
::singleton()->invoke(['spec', 'bao', 'link'], $spec, $bao, $link,
2293 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2299 * Modify the CiviCRM container - add new services, parameters, extensions, etc.
2302 * use Symfony\Component\Config\Resource\FileResource;
2303 * use Symfony\Component\DependencyInjection\Definition;
2305 * function mymodule_civicrm_container($container) {
2306 * $container->addResource(new FileResource(__FILE__));
2307 * $container->setDefinition('mysvc', new Definition('My\Class', array()));
2311 * Tip: The container configuration will be compiled/cached. The default cache
2312 * behavior is aggressive. When you first implement the hook, be sure to
2313 * flush the cache. Additionally, you should relax caching during development.
2314 * In `civicrm.settings.php`, set define('CIVICRM_CONTAINER_CACHE', 'auto').
2316 * Note: This is a preboot hook. It will dispatch via the extension/module
2317 * subsystem but *not* the Symfony EventDispatcher.
2319 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
2320 * @see http://symfony.com/doc/current/components/dependency_injection/index.html
2322 public static function container(\Symfony\Component\DependencyInjection\ContainerBuilder
$container) {
2323 self
::singleton()->invoke(['container'], $container, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_container');
2327 * @param array $fileSearches CRM_Core_FileSearchInterface
2330 public static function fileSearches(&$fileSearches) {
2331 return self
::singleton()->invoke(['fileSearches'], $fileSearches,
2332 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2333 'civicrm_fileSearches'
2338 * Check system status.
2340 * @param array $messages
2341 * Array<CRM_Utils_Check_Message>. A list of messages regarding system status.
2344 public static function check(&$messages) {
2345 return self
::singleton()
2346 ->invoke(['messages'], $messages, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_check');
2350 * This hook is called when a query string of the CSV Batch export is generated.
2352 * @param string $query
2356 public static function batchQuery(&$query) {
2357 return self
::singleton()->invoke(['query'], $query, self
::$_nullObject,
2358 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2359 'civicrm_batchQuery'
2364 * This hook is called to alter Deferred revenue item values just before they are
2365 * inserted in civicrm_financial_trxn table
2367 * @param array $deferredRevenues
2369 * @param array $contributionDetails
2371 * @param bool $update
2373 * @param string $context
2377 public static function alterDeferredRevenueItems(&$deferredRevenues, $contributionDetails, $update, $context) {
2378 return self
::singleton()->invoke(['deferredRevenues', 'contributionDetails', 'update', 'context'], $deferredRevenues, $contributionDetails, $update, $context,
2379 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterDeferredRevenueItems'
2384 * This hook is called when the entries of the CSV Batch export are mapped.
2386 * @param array $results
2387 * @param array $items
2391 public static function batchItems(&$results, &$items) {
2392 return self
::singleton()->invoke(['results', 'items'], $results, $items,
2393 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2394 'civicrm_batchItems'
2399 * This hook is called when core resources are being loaded
2401 * @see CRM_Core_Resources::coreResourceList
2403 * @param array $list
2404 * @param string $region
2406 public static function coreResourceList(&$list, $region) {
2407 self
::singleton()->invoke(['list', 'region'], $list, $region,
2408 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2409 'civicrm_coreResourceList'
2414 * Allows the list of filters on the EntityRef widget to be altered.
2416 * @see CRM_Core_Resources::entityRefFilters
2418 * @param array $filters
2420 public static function entityRefFilters(&$filters) {
2421 self
::singleton()->invoke(['filters'], $filters, self
::$_nullObject, self
::$_nullObject,
2422 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2423 'civicrm_entityRefFilters'
2428 * This hook is called for bypass a few civicrm urls from IDS check.
2430 * @param array $skip list of civicrm urls
2434 public static function idsException(&$skip) {
2435 return self
::singleton()->invoke(['skip'], $skip, self
::$_nullObject,
2436 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2437 'civicrm_idsException'
2442 * This hook is called when a geocoder's format method is called.
2444 * @param string $geoProvider
2445 * @param array $values
2446 * @param SimpleXMLElement $xml
2450 public static function geocoderFormat($geoProvider, &$values, $xml) {
2451 return self
::singleton()->invoke(['geoProvider', 'values', 'xml'], $geoProvider, $values, $xml,
2452 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2453 'civicrm_geocoderFormat'
2458 * This hook is called before an inbound SMS is processed.
2460 * @param \CRM_SMS_MessageObject $message
2461 * An SMS message received
2464 public static function inboundSMS(&$message) {
2465 return self
::singleton()->invoke(['message'], $message, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_inboundSMS');
2469 * This hook is called to modify api params of EntityRef form field
2471 * @param array $params
2472 * @param string $formName
2475 public static function alterEntityRefParams(&$params, $formName) {
2476 return self
::singleton()->invoke(['params', 'formName'], $params, $formName,
2477 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2478 'civicrm_alterEntityRefParams'
2483 * This hook is called before a scheduled job is executed
2485 * @param CRM_Core_DAO_Job $job
2486 * The job to be executed
2487 * @param array $params
2488 * The arguments to be given to the job
2490 public static function preJob($job, $params) {
2491 return self
::singleton()->invoke(['job', 'params'], $job, $params,
2492 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2498 * This hook is called after a scheduled job is executed
2500 * @param CRM_Core_DAO_Job $job
2501 * The job that was executed
2502 * @param array $params
2503 * The arguments given to the job
2504 * @param array $result
2505 * The result of the API call, or the thrown exception if any
2507 public static function postJob($job, $params, $result) {
2508 return self
::singleton()->invoke(['job', 'params', 'result'], $job, $params, $result,
2509 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2515 * This hook is called before and after constructing mail recipients.
2516 * Allows user to alter filter and/or search query to fetch mail recipients
2518 * @param CRM_Mailing_DAO_Mailing $mailingObject
2519 * @param array $criteria
2520 * A list of SQL criteria; you can add/remove/replace/modify criteria.
2521 * Array(string $name => CRM_Utils_SQL_Select $criterion).
2522 * Ex: array('do_not_email' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_email = 0")).
2523 * @param string $context
2527 public static function alterMailingRecipients(&$mailingObject, &$criteria, $context) {
2528 return self
::singleton()->invoke(['mailingObject', 'params', 'context'],
2529 $mailingObject, $criteria, $context,
2530 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2531 'civicrm_alterMailingRecipients'
2536 * ALlow Extensions to custom process IPN hook data such as sending Google Analyitcs information based on the IPN
2537 * @param array $IPNData - Array of IPN Data
2540 public static function postIPNProcess(&$IPNData) {
2541 return self
::singleton()->invoke(['IPNData'],
2542 $IPNData, self
::$_nullObject, self
::$_nullObject,
2543 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2544 'civicrm_postIPNProcess'