(NFC) (dev/core#878) Simplify copyright header (templates/*)
[civicrm-core.git] / CRM / Utils / Hook.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
f299f7db 6 | Copyright CiviCRM LLC (c) 2004-2020 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CiviCRM_Hook
ca5cec67 31 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035 32 */
6a488035
TO
33abstract class CRM_Utils_Hook {
34
35 // Allowed values for dashboard hook content placement
36 // Default - place content below activity list
7da04cde 37 const DASHBOARD_BELOW = 1;
6a488035 38 // Place content above activity list
7da04cde 39 const DASHBOARD_ABOVE = 2;
6a488035 40 // Don't display activity list at all
7da04cde 41 const DASHBOARD_REPLACE = 3;
6a488035
TO
42
43 // by default - place content below existing content
7da04cde 44 const SUMMARY_BELOW = 1;
50bfb460 45 // place hook content above
7da04cde 46 const SUMMARY_ABOVE = 2;
6714d8d2
SL
47 /**
48 *create your own summaries
49 */
7da04cde 50 const SUMMARY_REPLACE = 3;
6a488035 51
6714d8d2 52 /**
e97c66ff 53 * Object to pass when an object is required to be passed by params.
54 *
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.
57 *
58 * @var null
6714d8d2
SL
59 */
60 public static $_nullObject = NULL;
6a488035
TO
61
62 /**
63 * We only need one instance of this object. So we use the singleton
64 * pattern and cache the instance in this variable
65 *
e97c66ff 66 * @var CRM_Utils_Hook
6a488035
TO
67 */
68 static private $_singleton = NULL;
69
70 /**
71 * @var bool
72 */
73 private $commonIncluded = FALSE;
74
75 /**
76 * @var array(string)
77 */
be2fb01f 78 private $commonCiviModules = [];
6a488035 79
ad8ccc04
TO
80 /**
81 * @var CRM_Utils_Cache_Interface
82 */
83 protected $cache;
84
6a488035 85 /**
fe482240 86 * Constructor and getter for the singleton instance.
6a488035 87 *
72536736
AH
88 * @param bool $fresh
89 *
e97c66ff 90 * @return CRM_Utils_Hook
72536736 91 * An instance of $config->userHookClass
6a488035 92 */
00be9182 93 public static function singleton($fresh = FALSE) {
6a488035
TO
94 if (self::$_singleton == NULL || $fresh) {
95 $config = CRM_Core_Config::singleton();
96 $class = $config->userHookClass;
6a488035
TO
97 self::$_singleton = new $class();
98 }
99 return self::$_singleton;
100 }
101
f2ac86d1 102 /**
103 * CRM_Utils_Hook constructor.
e97c66ff 104 *
105 * @throws \CRM_Core_Exception
f2ac86d1 106 */
ad8ccc04 107 public function __construct() {
be2fb01f 108 $this->cache = CRM_Utils_Cache::create([
ad8ccc04 109 'name' => 'hooks',
be2fb01f 110 'type' => ['ArrayCache'],
ad8ccc04 111 'prefetch' => 1,
be2fb01f 112 ]);
ad8ccc04
TO
113 }
114
72536736 115 /**
354345c9
TO
116 * Invoke a hook through the UF/CMS hook system and the extension-hook
117 * system.
f0a7a0c9 118 *
77855840
TO
119 * @param int $numParams
120 * Number of parameters to pass to the hook.
121 * @param mixed $arg1
122 * Parameter to be passed to the hook.
123 * @param mixed $arg2
124 * Parameter to be passed to the hook.
125 * @param mixed $arg3
126 * Parameter to be passed to the hook.
127 * @param mixed $arg4
128 * Parameter to be passed to the hook.
129 * @param mixed $arg5
130 * Parameter to be passed to the hook.
131 * @param mixed $arg6
132 * Parameter to be passed to the hook.
133 * @param string $fnSuffix
134 * Function suffix, this is effectively the hook name.
72536736
AH
135 *
136 * @return mixed
137 */
6714d8d2 138 abstract public function invokeViaUF(
a3e55d9c 139 $numParams,
87dab4a4 140 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
6a488035
TO
141 $fnSuffix
142 );
143
354345c9
TO
144 /**
145 * Invoke a hook.
146 *
147 * This is a transitional adapter. It supports the legacy syntax
148 * but also accepts enough information to support Symfony Event
149 * dispatching.
150 *
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.
157 * @param mixed $arg1
158 * @param mixed $arg2
159 * @param mixed $arg3
160 * @param mixed $arg4
161 * @param mixed $arg5
162 * @param mixed $arg6
163 * @param mixed $fnSuffix
164 * @return mixed
165 */
166 public function invoke(
167 $names,
168 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
169 $fnSuffix
170 ) {
62f662b0 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)) {
180 return;
181 }
4d8e83b6 182 if (is_array($names) && !defined('CIVICRM_FORCE_LEGACY_HOOK') && \Civi\Core\Container::isContainerBooted()) {
e24a07e6
TO
183 $event = \Civi\Core\Event\GenericHookEvent::createOrdered(
184 $names,
185 array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6)
186 );
187 \Civi::dispatcher()->dispatch('hook_' . $fnSuffix, $event);
188 return $event->getReturnValues();
189 }
190 else {
9cf60966 191 // We need to ensure tht we will still run known bootstrap related hooks even if the container is not booted.
bbdc693f 192 $prebootContainerHooks = array_merge($upgradeFriendlyHooks, ['civicrm_entityTypes', 'civicrm_config']);
9cf60966
SL
193 if (!\Civi\Core\Container::isContainerBooted() && !in_array($fnSuffix, $prebootContainerHooks)) {
194 return;
195 }
e24a07e6
TO
196 $count = is_array($names) ? count($names) : $names;
197 return $this->invokeViaUF($count, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $fnSuffix);
198 }
354345c9
TO
199 }
200
5bc392e6 201 /**
100fef9d 202 * @param array $numParams
5bc392e6
EM
203 * @param $arg1
204 * @param $arg2
205 * @param $arg3
206 * @param $arg4
207 * @param $arg5
208 * @param $arg6
209 * @param $fnSuffix
210 * @param $fnPrefix
211 *
212 * @return array|bool
213 */
37cd2432 214 public function commonInvoke(
a3e55d9c 215 $numParams,
87dab4a4 216 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
6a488035
TO
217 $fnSuffix, $fnPrefix
218 ) {
219
220 $this->commonBuildModuleList($fnPrefix);
4636d4fd 221
6a488035 222 return $this->runHooks($this->commonCiviModules, $fnSuffix,
87dab4a4 223 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
6a488035
TO
224 );
225 }
226
227 /**
228 * Build the list of modules to be processed for hooks.
72536736
AH
229 *
230 * @param string $fnPrefix
6a488035 231 */
00be9182 232 public function commonBuildModuleList($fnPrefix) {
6a488035
TO
233 if (!$this->commonIncluded) {
234 // include external file
235 $this->commonIncluded = TRUE;
236
237 $config = CRM_Core_Config::singleton();
5d9bcf01
TO
238 if (!empty($config->customPHPPathDir)) {
239 $civicrmHooksFile = CRM_Utils_File::addTrailingSlash($config->customPHPPathDir) . 'civicrmHooks.php';
240 if (file_exists($civicrmHooksFile)) {
241 @include_once $civicrmHooksFile;
242 }
6a488035
TO
243 }
244
245 if (!empty($fnPrefix)) {
246 $this->commonCiviModules[$fnPrefix] = $fnPrefix;
247 }
248
249 $this->requireCiviModules($this->commonCiviModules);
250 }
251 }
252
72536736 253 /**
e97c66ff 254 * Run hooks.
255 *
256 * @param array $civiModules
257 * @param string $fnSuffix
258 * @param int $numParams
259 * @param mixed $arg1
260 * @param mixed $arg2
261 * @param mixed $arg3
262 * @param mixed $arg4
263 * @param mixed $arg5
264 * @param mixed $arg6
72536736
AH
265 *
266 * @return array|bool
e97c66ff 267 * @throws \Exception
72536736 268 */
37cd2432 269 public function runHooks(
a3e55d9c 270 $civiModules, $fnSuffix, $numParams,
87dab4a4 271 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
6a488035 272 ) {
3ac9ab1c
TO
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.
be2fb01f 277 $result = [];
6a488035 278
ad8ccc04
TO
279 $fnNames = $this->cache->get($fnSuffix);
280 if (!is_array($fnNames)) {
be2fb01f 281 $fnNames = [];
ad8ccc04
TO
282 if ($civiModules !== NULL) {
283 foreach ($civiModules as $module) {
284 $fnName = "{$module}_{$fnSuffix}";
285 if (function_exists($fnName)) {
286 $fnNames[] = $fnName;
1cba072e 287 }
4636d4fd 288 }
ad8ccc04
TO
289 $this->cache->set($fnSuffix, $fnNames);
290 }
291 }
292
293 foreach ($fnNames as $fnName) {
be2fb01f 294 $fResult = [];
ad8ccc04
TO
295 switch ($numParams) {
296 case 0:
297 $fResult = $fnName();
298 break;
299
300 case 1:
301 $fResult = $fnName($arg1);
302 break;
303
304 case 2:
305 $fResult = $fnName($arg1, $arg2);
306 break;
307
308 case 3:
309 $fResult = $fnName($arg1, $arg2, $arg3);
310 break;
311
312 case 4:
313 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
314 break;
315
316 case 5:
317 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
318 break;
319
320 case 6:
321 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
322 break;
323
324 default:
325 CRM_Core_Error::fatal(ts('Invalid hook invocation'));
326 break;
327 }
328
329 if (!empty($fResult) &&
330 is_array($fResult)
331 ) {
332 $result = array_merge($result, $fResult);
6a488035
TO
333 }
334 }
335
336 return empty($result) ? TRUE : $result;
337 }
338
5bc392e6
EM
339 /**
340 * @param $moduleList
341 */
00be9182 342 public function requireCiviModules(&$moduleList) {
6a488035
TO
343 $civiModules = CRM_Core_PseudoConstant::getModuleExtensions();
344 foreach ($civiModules as $civiModule) {
345 if (!file_exists($civiModule['filePath'])) {
346 CRM_Core_Session::setStatus(
481a74f4 347 ts('Error loading module file (%1). Please restore the file or disable the module.',
be2fb01f 348 [1 => $civiModule['filePath']]),
481a74f4 349 ts('Warning'), 'error');
6a488035
TO
350 continue;
351 }
352 include_once $civiModule['filePath'];
353 $moduleList[$civiModule['prefix']] = $civiModule['prefix'];
6a488035 354 }
e7292422 355 }
6a488035
TO
356
357 /**
358 * This hook is called before a db write on some core objects.
359 * This hook does not allow the abort of the operation
360 *
77855840
TO
361 * @param string $op
362 * The type of operation being performed.
363 * @param string $objectName
364 * The name of the object.
365 * @param int $id
366 * The object id if available.
367 * @param array $params
368 * The parameters used for object creation / editing.
6a488035 369 *
a6c01b45
CW
370 * @return null
371 * the return value is ignored
6a488035 372 */
00be9182 373 public static function pre($op, $objectName, $id, &$params) {
fd901044 374 $event = new \Civi\Core\Event\PreEvent($op, $objectName, $id, $params);
c73e3098
TO
375 \Civi::dispatcher()->dispatch('hook_civicrm_pre', $event);
376 return $event->getReturnValues();
6a488035
TO
377 }
378
379 /**
380 * This hook is called after a db write on some core objects.
381 *
77855840
TO
382 * @param string $op
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.
6a488035 390 *
72b3a70c
CW
391 * @return mixed
392 * based on op. pre-hooks return a boolean or
6a488035 393 * an error message which aborts the operation
6a488035 394 */
1273d77c 395 public static function post($op, $objectName, $objectId, &$objectRef = NULL) {
fd901044 396 $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef);
c73e3098
TO
397 \Civi::dispatcher()->dispatch('hook_civicrm_post', $event);
398 return $event->getReturnValues();
6a488035
TO
399 }
400
6a488035 401 /**
fe482240 402 * This hook retrieves links from other modules and injects it into.
6a488035
TO
403 * the view contact tabs
404 *
77855840
TO
405 * @param string $op
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).
413 * @param int $mask
414 * (optional) the bitmask to show/hide links.
415 * @param array $values
416 * (optional) the values to fill the links.
6a488035 417 *
a6c01b45
CW
418 * @return null
419 * the return value is ignored
6a488035 420 */
be2fb01f
CW
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');
6a488035
TO
423 }
424
21d2903d
AN
425 /**
426 * This hook is invoked during the CiviCRM form preProcess phase.
427 *
77855840
TO
428 * @param string $formName
429 * The name of the form.
430 * @param CRM_Core_Form $form
431 * Reference to the form object.
21d2903d 432 *
a6c01b45
CW
433 * @return null
434 * the return value is ignored
21d2903d 435 */
00be9182 436 public static function preProcess($formName, &$form) {
37cd2432 437 return self::singleton()
be2fb01f 438 ->invoke(['formName', 'form'], $formName, $form, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_preProcess');
21d2903d
AN
439 }
440
6a488035
TO
441 /**
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
444 *
77855840
TO
445 * @param string $formName
446 * The name of the form.
447 * @param CRM_Core_Form $form
448 * Reference to the form object.
6a488035 449 *
a6c01b45
CW
450 * @return null
451 * the return value is ignored
6a488035 452 */
00be9182 453 public static function buildForm($formName, &$form) {
be2fb01f 454 return self::singleton()->invoke(['formName', 'form'], $formName, $form,
37cd2432
TO
455 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
456 'civicrm_buildForm'
457 );
6a488035
TO
458 }
459
460 /**
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
463 *
77855840
TO
464 * @param string $formName
465 * The name of the form.
466 * @param CRM_Core_Form $form
467 * Reference to the form object.
6a488035 468 *
a6c01b45
CW
469 * @return null
470 * the return value is ignored
6a488035 471 */
00be9182 472 public static function postProcess($formName, &$form) {
be2fb01f 473 return self::singleton()->invoke(['formName', 'form'], $formName, $form,
37cd2432
TO
474 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
475 'civicrm_postProcess'
476 );
6a488035
TO
477 }
478
479 /**
480 * This hook is invoked during all CiviCRM form validation. An array of errors
6a488035
TO
481 * detected is returned. Else we assume validation succeeded.
482 *
77855840
TO
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.
6a488035 489 *
72b3a70c
CW
490 * @return mixed
491 * formRule hooks return a boolean or
6a488035 492 * an array of error messages which display a QF Error
6a488035 493 */
00be9182 494 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
37cd2432 495 return self::singleton()
be2fb01f 496 ->invoke(['formName', 'fields', 'files', 'form', 'errors'],
6a8f1687 497 $formName, $fields, $files, $form, $errors, self::$_nullObject, 'civicrm_validateForm');
6a488035
TO
498 }
499
500 /**
42bc70d4 501 * This hook is called after a db write on a custom table.
6a488035 502 *
77855840
TO
503 * @param string $op
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.
6a488035 511 *
a6c01b45
CW
512 * @return null
513 * the return value is ignored
6a488035 514 */
00be9182 515 public static function custom($op, $groupID, $entityID, &$params) {
37cd2432 516 return self::singleton()
be2fb01f 517 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_custom');
6a488035
TO
518 }
519
520 /**
521 * This hook is called when composing the ACL where clause to restrict
522 * visibility of contacts to the logged in user
523 *
77855840
TO
524 * @param int $type
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.
6a488035 534 *
a6c01b45
CW
535 * @return null
536 * the return value is ignored
6a488035 537 */
00be9182 538 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
37cd2432 539 return self::singleton()
be2fb01f 540 ->invoke(['type', 'tables', 'whereTables', 'contactID', 'where'], $type, $tables, $whereTables, $contactID, $where, self::$_nullObject, 'civicrm_aclWhereClause');
6a488035
TO
541 }
542
543 /**
544 * This hook is called when composing the ACL where clause to restrict
545 * visibility of contacts to the logged in user
546 *
77855840
TO
547 * @param int $type
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.
6a488035 557 *
a6c01b45
CW
558 * @return null
559 * the return value is ignored
6a488035 560 */
00be9182 561 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
37cd2432 562 return self::singleton()
be2fb01f 563 ->invoke(['type', 'contactID', 'tableName', 'allGroups', 'currentGroups'], $type, $contactID, $tableName, $allGroups, $currentGroups, self::$_nullObject, 'civicrm_aclGroup');
6a488035
TO
564 }
565
032346cc
CW
566 /**
567 * @param string|CRM_Core_DAO $entity
568 * @param array $clauses
569 * @return mixed
570 */
571 public static function selectWhereClause($entity, &$clauses) {
572 $entityName = is_object($entity) ? _civicrm_api_get_entity_name_from_dao($entity) : $entity;
be2fb01f 573 return self::singleton()->invoke(['entity', 'clauses'], $entityName, $clauses,
032346cc
CW
574 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
575 'civicrm_selectWhereClause'
576 );
577 }
578
6a488035 579 /**
fe482240 580 * This hook is called when building the menu table.
6a488035 581 *
77855840
TO
582 * @param array $files
583 * The current set of files to process.
6a488035 584 *
a6c01b45
CW
585 * @return null
586 * the return value is ignored
6a488035 587 */
00be9182 588 public static function xmlMenu(&$files) {
be2fb01f 589 return self::singleton()->invoke(['files'], $files,
87dab4a4 590 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
591 'civicrm_xmlMenu'
592 );
593 }
594
7dc34fb8
TO
595 /**
596 * (Experimental) This hook is called when build the menu table.
597 *
598 * @param array $items
599 * List of records to include in menu table.
600 * @return null
601 * the return value is ignored
602 */
603 public static function alterMenu(&$items) {
be2fb01f 604 return self::singleton()->invoke(['items'], $items,
7dc34fb8
TO
605 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
606 'civicrm_alterMenu'
607 );
608 }
609
d89d2545
TO
610 /**
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:
613 *
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)
618 * Visible title.
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).
634 *
635 * @param array $themes
636 * List of themes, keyed by name.
637 * @return null
638 * the return value is ignored
639 */
640 public static function themes(&$themes) {
641 return self::singleton()->invoke(1, $themes,
642 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
643 'civicrm_themes'
644 );
645 }
646
647 /**
648 * The activeTheme hook determines which theme is active.
649 *
650 * @param string $theme
651 * The identifier for the theme. Alterable.
652 * Ex: 'greenwich'.
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.
657 * @return null
658 * the return value is ignored
659 */
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'
664 );
665 }
666
6a488035 667 /**
88718db2 668 * This hook is called for declaring managed entities via API.
6a488035 669 *
77855840 670 * @param array $entities
88718db2
TO
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.)
6a488035 683 *
a6c01b45
CW
684 * @return null
685 * the return value is ignored
6a488035 686 */
00be9182 687 public static function managed(&$entities) {
be2fb01f 688 return self::singleton()->invoke(['entities'], $entities,
87dab4a4 689 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
690 'civicrm_managed'
691 );
692 }
693
694 /**
695 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
696 *
77855840
TO
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.
9399901d 701 * relative to the activity list
6a488035 702 *
a6c01b45
CW
703 * @return string
704 * the html snippet to include in the dashboard
6a488035 705 */
00be9182 706 public static function dashboard($contactID, &$contentPlacement = self::DASHBOARD_BELOW) {
be2fb01f 707 $retval = self::singleton()->invoke(['contactID', 'contentPlacement'], $contactID, $contentPlacement,
87dab4a4 708 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
709 'civicrm_dashboard'
710 );
711
712 /*
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.
716 */
717 if (!isset($contentPlacement)) {
718 $contentPlacement = self::DASHBOARD_BELOW;
719 }
720
721 return $retval;
722 }
723
724 /**
725 * This hook is called before storing recently viewed items.
726 *
77855840
TO
727 * @param array $recentArray
728 * An array of recently viewed or processed items, for in place modification.
6a488035
TO
729 *
730 * @return array
6a488035 731 */
00be9182 732 public static function recent(&$recentArray) {
be2fb01f 733 return self::singleton()->invoke(['recentArray'], $recentArray,
87dab4a4 734 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
735 'civicrm_recent'
736 );
737 }
738
91dee34b 739 /**
fe482240 740 * Determine how many other records refer to a given record.
91dee34b 741 *
77855840
TO
742 * @param CRM_Core_DAO $dao
743 * The item for which we want a reference count.
744 * @param array $refCounts
16b10e64 745 * Each item in the array is an Array with keys:
91dee34b
TO
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
153b262f
EM
749 *
750 * @return mixed
751 * Return is not really intended to be used.
91dee34b 752 */
00be9182 753 public static function referenceCounts($dao, &$refCounts) {
be2fb01f 754 return self::singleton()->invoke(['dao', 'refCounts'], $dao, $refCounts,
91dee34b
TO
755 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
756 'civicrm_referenceCounts'
757 );
758 }
759
6a488035 760 /**
fe482240 761 * This hook is called when building the amount structure for a Contribution or Event Page.
6a488035 762 *
77855840
TO
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.
6a488035
TO
769 *
770 * @return null
6a488035 771 */
00be9182 772 public static function buildAmount($pageType, &$form, &$amount) {
be2fb01f 773 return self::singleton()->invoke(['pageType', 'form', 'amount'], $pageType, $form, $amount, self::$_nullObject,
87dab4a4 774 self::$_nullObject, self::$_nullObject, 'civicrm_buildAmount');
6a488035
TO
775 }
776
777 /**
778 * This hook is called when building the state list for a particular country.
779 *
72536736
AH
780 * @param array $countryID
781 * The country id whose states are being selected.
782 * @param $states
6a488035
TO
783 *
784 * @return null
6a488035 785 */
00be9182 786 public static function buildStateProvinceForCountry($countryID, &$states) {
be2fb01f 787 return self::singleton()->invoke(['countryID', 'states'], $countryID, $states,
87dab4a4 788 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
789 'civicrm_buildStateProvinceForCountry'
790 );
791 }
792
793 /**
794 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
795 *
77855840
TO
796 * @param array $tabs
797 * The array of tabs that will be displayed.
798 * @param int $contactID
799 * The contactID for whom the dashboard is being rendered.
6a488035
TO
800 *
801 * @return null
48fe48a6 802 * @deprecated Use tabset() instead.
6a488035 803 */
00be9182 804 public static function tabs(&$tabs, $contactID) {
be2fb01f 805 return self::singleton()->invoke(['tabs', 'contactID'], $tabs, $contactID,
87dab4a4 806 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tabs'
6a488035
TO
807 );
808 }
809
fa3dbfbd 810 /**
72536736
AH
811 * This hook is called when rendering the tabs used for events and potentially
812 * contribution pages, etc.
813 *
814 * @param string $tabsetName
815 * Name of the screen or visual element.
816 * @param array $tabs
817 * Tabs that will be displayed.
818 * @param array $context
819 * Extra data about the screen or context in which the tab is used.
fa3dbfbd 820 *
2efcf0c2 821 * @return null
fa3dbfbd 822 */
00be9182 823 public static function tabset($tabsetName, &$tabs, $context) {
be2fb01f 824 return self::singleton()->invoke(['tabsetName', 'tabs', 'context'], $tabsetName, $tabs,
87dab4a4 825 $context, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tabset'
fa3dbfbd 826 );
827 }
828
6a488035
TO
829 /**
830 * This hook is called when sending an email / printing labels
831 *
77855840
TO
832 * @param array $tokens
833 * The list of tokens that can be used for the contact.
6a488035
TO
834 *
835 * @return null
6a488035 836 */
00be9182 837 public static function tokens(&$tokens) {
be2fb01f 838 return self::singleton()->invoke(['tokens'], $tokens,
87dab4a4 839 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tokens'
6a488035
TO
840 );
841 }
842
8f4eb478 843 /**
844 * This hook allows modification of the admin panels
845 *
846 * @param array $panels
847 * Associated array of admin panels
848 *
849 * @return mixed
850 */
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'
855 );
856 }
857
6a488035
TO
858 /**
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
861 *
77855840
TO
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.
866 * @param int $jobID
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.
6a488035
TO
872 *
873 * @return null
6a488035 874 */
37cd2432 875 public static function tokenValues(
a3e55d9c 876 &$details,
6a488035 877 $contactIDs,
e7292422 878 $jobID = NULL,
be2fb01f 879 $tokens = [],
6a488035
TO
880 $className = NULL
881 ) {
37cd2432 882 return self::singleton()
be2fb01f 883 ->invoke(['details', 'contactIDs', 'jobID', 'tokens', 'className'], $details, $contactIDs, $jobID, $tokens, $className, self::$_nullObject, 'civicrm_tokenValues');
6a488035
TO
884 }
885
886 /**
887 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
888 * in a template
889 *
77855840
TO
890 * @param object $page
891 * The page that will be rendered.
6a488035
TO
892 *
893 * @return null
6a488035 894 */
00be9182 895 public static function pageRun(&$page) {
be2fb01f 896 return self::singleton()->invoke(['page'], $page,
87dab4a4 897 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
898 'civicrm_pageRun'
899 );
900 }
901
902 /**
903 * This hook is called after a copy of an object has been made. The current objects are
904 * Event, Contribution Page and UFGroup
905 *
77855840
TO
906 * @param string $objectName
907 * Name of the object.
908 * @param object $object
909 * Reference to the copy.
6a488035
TO
910 *
911 * @return null
6a488035 912 */
00be9182 913 public static function copy($objectName, &$object) {
be2fb01f 914 return self::singleton()->invoke(['objectName', 'object'], $objectName, $object,
87dab4a4 915 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
916 'civicrm_copy'
917 );
918 }
919
920 /**
921 * This hook is called when a contact unsubscribes from a mailing. It allows modules
922 * to override what the contacts are removed from.
923 *
72536736
AH
924 * @param string $op
925 * Ignored for now
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.
934 *
dcbd3a55 935 *
72536736
AH
936 * @return mixed
937 */
00be9182 938 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
37cd2432 939 return self::singleton()
be2fb01f 940 ->invoke(['op', 'mailingId', 'contactId', 'groups', 'baseGroups'], $op, $mailingId, $contactId, $groups, $baseGroups, self::$_nullObject, 'civicrm_unsubscribeGroups');
6a488035
TO
941 }
942
943 /**
6eb95671
CW
944 * This hook is called when CiviCRM needs to edit/display a custom field with options
945 *
946 * @deprecated in favor of hook_civicrm_fieldOptions
6a488035 947 *
77855840
TO
948 * @param int $customFieldID
949 * The custom field ID.
950 * @param array $options
951 * The current set of options for that custom field.
6a488035 952 * You can add/remove existing options.
9399901d
KJ
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.
6a488035 955 * Only add/edit/remove the specific field options you intend to affect.
77855840 956 * @param bool $detailedFormat
6eb95671 957 * If true, the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
77855840
TO
958 * @param array $selectAttributes
959 * Contain select attribute(s) if any.
72536736
AH
960 *
961 * @return mixed
6a488035 962 */
be2fb01f 963 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = []) {
9c42b57d 964 // Weird: $selectAttributes is inputted but not outputted.
be2fb01f 965 return self::singleton()->invoke(['customFieldID', 'options', 'detailedFormat'], $customFieldID, $options, $detailedFormat,
87dab4a4 966 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
967 'civicrm_customFieldOptions'
968 );
969 }
970
33e61cb8
CW
971 /**
972 * Hook for modifying field options
973 *
974 * @param string $entity
975 * @param string $field
976 * @param array $options
977 * @param array $params
978 *
979 * @return mixed
980 */
981 public static function fieldOptions($entity, $field, &$options, $params) {
be2fb01f 982 return self::singleton()->invoke(['entity', 'field', 'options', 'params'], $entity, $field, $options, $params,
33e61cb8
CW
983 self::$_nullObject, self::$_nullObject,
984 'civicrm_fieldOptions'
985 );
986 }
987
6a488035
TO
988 /**
989 *
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.
992 *
77855840
TO
993 * @param string $objectType
994 * The object type for this search.
6a488035 995 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
77855840
TO
996 * @param array $tasks
997 * The current set of tasks for that custom field.
6a488035 998 * You can add/remove existing tasks.
7f82e636 999 * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class
9399901d 1000 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
6a488035 1001 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
9399901d
KJ
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.
72536736
AH
1004 *
1005 * @return mixed
6a488035 1006 */
00be9182 1007 public static function searchTasks($objectType, &$tasks) {
be2fb01f 1008 return self::singleton()->invoke(['objectType', 'tasks'], $objectType, $tasks,
87dab4a4 1009 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1010 'civicrm_searchTasks'
1011 );
1012 }
1013
72536736
AH
1014 /**
1015 * @param mixed $form
1016 * @param array $params
1017 *
1018 * @return mixed
1019 */
00be9182 1020 public static function eventDiscount(&$form, &$params) {
be2fb01f 1021 return self::singleton()->invoke(['form', 'params'], $form, $params,
87dab4a4 1022 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1023 'civicrm_eventDiscount'
1024 );
1025 }
1026
1027 /**
1028 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
1029 *
72536736
AH
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
1036 *
1037 * @return mixed
6a488035 1038 */
00be9182 1039 public static function mailingGroups(&$form, &$groups, &$mailings) {
be2fb01f 1040 return self::singleton()->invoke(['form', 'groups', 'mailings'], $form, $groups, $mailings,
87dab4a4 1041 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1042 'civicrm_mailingGroups'
1043 );
1044 }
1045
703875d8
TO
1046 /**
1047 * (Experimental) Modify the list of template-types used for CiviMail composition.
1048 *
1049 * @param array $types
1050 * Sequentially indexed list of template types. Each type specifies:
1051 * - name: string
1052 * - editorUrl: string, Angular template URL
1053 * - weight: int, priority when picking a default value for new mailings
1054 * @return mixed
1055 */
1056 public static function mailingTemplateTypes(&$types) {
be2fb01f 1057 return self::singleton()->invoke(['types'], $types, self::$_nullObject, self::$_nullObject,
703875d8
TO
1058 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1059 'civicrm_mailingTemplateTypes'
1060 );
1061 }
1062
6a488035 1063 /**
9399901d
KJ
1064 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
1065 * (new or renewal).
6a488035
TO
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).
1069 *
72536736
AH
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
1074 *
1075 * @return mixed
6a488035 1076 */
00be9182 1077 public static function membershipTypeValues(&$form, &$membershipTypes) {
be2fb01f 1078 return self::singleton()->invoke(['form', 'membershipTypes'], $form, $membershipTypes,
87dab4a4 1079 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1080 'civicrm_membershipTypeValues'
1081 );
1082 }
1083
1084 /**
fe482240 1085 * This hook is called when rendering the contact summary.
6a488035 1086 *
72536736
AH
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
1092 * existing content
6a488035 1093 *
72536736
AH
1094 * @return string
1095 * The html snippet to include in the contact summary
6a488035 1096 */
00be9182 1097 public static function summary($contactID, &$content, &$contentPlacement = self::SUMMARY_BELOW) {
be2fb01f 1098 return self::singleton()->invoke(['contactID', 'content', 'contentPlacement'], $contactID, $content, $contentPlacement,
87dab4a4 1099 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1100 'civicrm_summary'
1101 );
1102 }
1103
1104 /**
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.
1110 *
77855840
TO
1111 * @param mixed $query
1112 * - the query that will be executed (input and output parameter);.
6a488035
TO
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')
1117 * the contact IDs
0fcad357 1118 * @param string $queryText
77855840
TO
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').
1122 * @param int $id
1123 * The id of the object for which the call is being made.
6a488035 1124 * For custom fields, it will be the custom field id
72536736
AH
1125 *
1126 * @return mixed
6a488035 1127 */
0fcad357 1128 public static function contactListQuery(&$query, $queryText, $context, $id) {
be2fb01f 1129 return self::singleton()->invoke(['query', 'queryText', 'context', 'id'], $query, $queryText, $context, $id,
87dab4a4 1130 self::$_nullObject, self::$_nullObject,
6a488035
TO
1131 'civicrm_contactListQuery'
1132 );
1133 }
1134
1135 /**
1136 * Hook definition for altering payment parameters before talking to a payment processor back end.
1137 *
1138 * Definition will look like this:
1139 *
153b262f
EM
1140 * function hook_civicrm_alterPaymentProcessorParams(
1141 * $paymentObj,
1142 * &$rawParams,
1143 * &$cookedParams
1144 * );
80bcd255 1145 *
153b262f
EM
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.
6a488035
TO
1149 * @param array &$rawParams
1150 * array of params as passed to to the processor
72536736 1151 * @param array &$cookedParams
6a488035
TO
1152 * params after the processor code has translated them into its own key/value pairs
1153 *
72536736 1154 * @return mixed
80bcd255 1155 * This return is not really intended to be used.
6a488035 1156 */
37cd2432 1157 public static function alterPaymentProcessorParams(
a3e55d9c 1158 $paymentObj,
6a488035
TO
1159 &$rawParams,
1160 &$cookedParams
1161 ) {
be2fb01f 1162 return self::singleton()->invoke(['paymentObj', 'rawParams', 'cookedParams'], $paymentObj, $rawParams, $cookedParams,
87dab4a4 1163 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1164 'civicrm_alterPaymentProcessorParams'
1165 );
1166 }
1167
1168 /**
1169 * This hook is called when an email is about to be sent by CiviCRM.
1170 *
72536736
AH
1171 * @param array $params
1172 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
16b10e64 1173 * returnPath, replyTo, headers, attachments (array)
77855840
TO
1174 * @param string $context
1175 * The context in which the hook is being invoked, eg 'civimail'.
72536736
AH
1176 *
1177 * @return mixed
6a488035 1178 */
00be9182 1179 public static function alterMailParams(&$params, $context = NULL) {
be2fb01f 1180 return self::singleton()->invoke(['params', 'context'], $params, $context,
87dab4a4 1181 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1182 'civicrm_alterMailParams'
1183 );
1184 }
1185
5f11bbcc 1186 /**
fe482240 1187 * This hook is called when membership status is being calculated.
5f11bbcc 1188 *
77855840
TO
1189 * @param array $membershipStatus
1190 * Membership status details as determined - alter if required.
1191 * @param array $arguments
1192 * Arguments passed in to calculate date.
5f11bbcc
EM
1193 * - 'start_date'
1194 * - 'end_date'
1195 * - 'status_date'
1196 * - 'join_date'
1197 * - 'exclude_is_admin'
1198 * - 'membership_type_id'
77855840
TO
1199 * @param array $membership
1200 * Membership details from the calling function.
f4aaa82a
EM
1201 *
1202 * @return mixed
5f11bbcc 1203 */
00be9182 1204 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
be2fb01f 1205 return self::singleton()->invoke(['membershipStatus', 'arguments', 'membership'], $membershipStatus, $arguments,
fc6a608f 1206 $membership, self::$_nullObject, self::$_nullObject, self::$_nullObject,
5f11bbcc
EM
1207 'civicrm_alterCalculatedMembershipStatus'
1208 );
1209 }
1210
d04a3a9b 1211 /**
1212 * This hook is called after getting the content of the mail and before tokenizing it.
1213 *
d1719f82 1214 * @param array $content
d04a3a9b 1215 * Array fields include: html, text, subject
1216 *
1217 * @return mixed
1218 */
d1719f82 1219 public static function alterMailContent(&$content) {
be2fb01f 1220 return self::singleton()->invoke(['content'], $content,
d04a3a9b 1221 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
d1719f82 1222 'civicrm_alterMailContent'
d04a3a9b 1223 );
1224 }
1225
6a488035 1226 /**
fe482240 1227 * This hook is called when rendering the Manage Case screen.
6a488035 1228 *
77855840
TO
1229 * @param int $caseID
1230 * The case ID.
6a488035 1231 *
a6c01b45 1232 * @return array
16b10e64
CW
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
6a488035 1235 */
00be9182 1236 public static function caseSummary($caseID) {
be2fb01f 1237 return self::singleton()->invoke(['caseID'], $caseID,
87dab4a4 1238 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1239 'civicrm_caseSummary'
1240 );
1241 }
1242
6b86870e
TO
1243 /**
1244 * This hook is called when locating CiviCase types.
1245 *
1246 * @param array $caseTypes
72536736
AH
1247 *
1248 * @return mixed
6b86870e 1249 */
00be9182 1250 public static function caseTypes(&$caseTypes) {
37cd2432 1251 return self::singleton()
be2fb01f 1252 ->invoke(['caseTypes'], $caseTypes, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_caseTypes');
6b86870e
TO
1253 }
1254
6a488035
TO
1255 /**
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.
72536736
AH
1258 *
1259 * @param CRM_Core_Config|array $config
1260 * The config object
1261 *
1262 * @return mixed
6a488035 1263 */
00be9182 1264 public static function config(&$config) {
be2fb01f 1265 return self::singleton()->invoke(['config'], $config,
87dab4a4 1266 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1267 'civicrm_config'
1268 );
1269 }
1270
6a488035 1271 /**
fe482240 1272 * This hooks allows to change option values.
6a488035 1273 *
6eb95671
CW
1274 * @deprecated in favor of hook_civicrm_fieldOptions
1275 *
72536736
AH
1276 * @param array $options
1277 * Associated array of option values / id
0fcad357 1278 * @param string $groupName
72536736 1279 * Option group name
6a488035 1280 *
72536736 1281 * @return mixed
6a488035 1282 */
0fcad357 1283 public static function optionValues(&$options, $groupName) {
be2fb01f 1284 return self::singleton()->invoke(['options', 'groupName'], $options, $groupName,
87dab4a4 1285 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1286 'civicrm_optionValues'
1287 );
1288 }
1289
1290 /**
1291 * This hook allows modification of the navigation menu.
1292 *
72536736
AH
1293 * @param array $params
1294 * Associated array of navigation menu entry to Modify/Add
1295 *
1296 * @return mixed
6a488035 1297 */
00be9182 1298 public static function navigationMenu(&$params) {
be2fb01f 1299 return self::singleton()->invoke(['params'], $params,
87dab4a4 1300 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1301 'civicrm_navigationMenu'
1302 );
1303 }
1304
1305 /**
1306 * This hook allows modification of the data used to perform merging of duplicates.
1307 *
77855840
TO
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.
6a488035 1318 *
72536736 1319 * @return mixed
6a488035 1320 */
00be9182 1321 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
be2fb01f 1322 return self::singleton()->invoke(['type', 'data', 'mainId', 'otherId', 'tables'], $type, $data, $mainId, $otherId, $tables, self::$_nullObject, 'civicrm_merge');
6a488035
TO
1323 }
1324
92a77772 1325 /**
1326 * This hook allows modification of the data calculated for merging locations.
1327 *
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.
1336 *
1337 * @return mixed
1338 */
1339 public static function alterLocationMergeData(&$blocksDAO, $mainId, $otherId, $migrationInfo) {
be2fb01f 1340 return self::singleton()->invoke(['blocksDAO', 'mainId', 'otherId', 'migrationInfo'], $blocksDAO, $mainId, $otherId, $migrationInfo, self::$_nullObject, self::$_nullObject, 'civicrm_alterLocationMergeData');
92a77772 1341 }
1342
6a488035
TO
1343 /**
1344 * This hook provides a way to override the default privacy behavior for notes.
1345 *
72536736
AH
1346 * @param array &$noteValues
1347 * Associative array of values for this note
6a488035 1348 *
72536736 1349 * @return mixed
6a488035 1350 */
00be9182 1351 public static function notePrivacy(&$noteValues) {
be2fb01f 1352 return self::singleton()->invoke(['noteValues'], $noteValues,
87dab4a4 1353 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1354 'civicrm_notePrivacy'
1355 );
1356 }
1357
1358 /**
fe482240 1359 * This hook is called before record is exported as CSV.
6a488035 1360 *
77855840
TO
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
1366 * SQL columns.
1367 * @param int $exportMode
1368 * Export mode ( contact, contribution, etc...).
a09323e9 1369 * @param string $componentTable
1370 * Name of temporary table
1371 * @param array $ids
1372 * Array of object's ids
6a488035 1373 *
72536736 1374 * @return mixed
6a488035 1375 */
ca934663 1376 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids) {
be2fb01f 1377 return self::singleton()->invoke(['exportTempTable', 'headerRows', 'sqlColumns', 'exportMode', 'componentTable', 'ids'],
a09323e9 1378 $exportTempTable, $headerRows, $sqlColumns,
1379 $exportMode, $componentTable, $ids,
6a488035
TO
1380 'civicrm_export'
1381 );
1382 }
1383
1384 /**
1385 * This hook allows modification of the queries constructed from dupe rules.
1386 *
77855840
TO
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
1392 * Set of queries.
6a488035 1393 *
f4aaa82a 1394 * @return mixed
6a488035 1395 */
00be9182 1396 public static function dupeQuery($obj, $type, &$query) {
be2fb01f 1397 return self::singleton()->invoke(['obj', 'type', 'query'], $obj, $type, $query,
87dab4a4 1398 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1399 'civicrm_dupeQuery'
1400 );
1401 }
1402
b8cb7e46
MWMC
1403 /**
1404 * Check for duplicate contacts
1405 *
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;
1411 * 'rule' = $rule;
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]
1418 *
1419 * @return mixed
1420 */
1421 public static function findDuplicates($dedupeParams, &$dedupeResults, $contextParams) {
1422 return self::singleton()
be2fb01f 1423 ->invoke(['dedupeParams', 'dedupeResults', 'contextParams'], $dedupeParams, $dedupeResults, $contextParams, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_findDuplicates');
b8cb7e46
MWMC
1424 }
1425
6a488035
TO
1426 /**
1427 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1428 *
77855840
TO
1429 * @param string $type
1430 * Type of mail processed: 'activity' OR 'mailing'.
f4aaa82a 1431 * @param array &$params the params that were sent to the CiviCRM API function
77855840
TO
1432 * @param object $mail
1433 * The mail object which is an ezcMail class.
f4aaa82a 1434 * @param array &$result the result returned by the api call
77855840
TO
1435 * @param string $action
1436 * (optional ) the requested action to be performed if the types was 'mailing'.
6a488035 1437 *
f4aaa82a 1438 * @return mixed
6a488035 1439 */
00be9182 1440 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
37cd2432 1441 return self::singleton()
be2fb01f 1442 ->invoke(['type', 'params', 'mail', 'result', 'action'], $type, $params, $mail, $result, $action, self::$_nullObject, 'civicrm_emailProcessor');
6a488035
TO
1443 }
1444
1445 /**
1446 * This hook is called after a row has been processed and the
1447 * record (and associated records imported
1448 *
77855840
TO
1449 * @param string $object
1450 * Object being imported (for now Contact only, later Contribution, Activity,.
9399901d 1451 * Participant and Member)
77855840
TO
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.
6a488035
TO
1458 * contactID - contact id
1459 * importID - row id in temp table
1460 * importTempTable - name of tempTable
1461 * fieldHeaders - field headers
1462 * fields - import fields
1463 *
b8c71ffa 1464 * @return mixed
6a488035 1465 */
00be9182 1466 public static function import($object, $usage, &$objectRef, &$params) {
be2fb01f 1467 return self::singleton()->invoke(['object', 'usage', 'objectRef', 'params'], $object, $usage, $objectRef, $params,
87dab4a4 1468 self::$_nullObject, self::$_nullObject,
6a488035
TO
1469 'civicrm_import'
1470 );
1471 }
1472
1473 /**
1474 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
aa5ba569 1475 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
6a488035 1476 *
77855840
TO
1477 * @param string $entity
1478 * The API entity (like contact).
1479 * @param string $action
1480 * The API action (like get).
f4aaa82a 1481 * @param array &$params the API parameters
c490a46a 1482 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
f4aaa82a
EM
1483 *
1484 * @return mixed
6a488035 1485 */
00be9182 1486 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
be2fb01f 1487 return self::singleton()->invoke(['entity', 'action', 'params', 'permissions'], $entity, $action, $params, $permissions,
87dab4a4 1488 self::$_nullObject, self::$_nullObject,
6a488035
TO
1489 'civicrm_alterAPIPermissions'
1490 );
1491 }
1492
5bc392e6 1493 /**
c490a46a 1494 * @param CRM_Core_DAO $dao
5bc392e6
EM
1495 *
1496 * @return mixed
1497 */
00be9182 1498 public static function postSave(&$dao) {
6a488035 1499 $hookName = 'civicrm_postSave_' . $dao->getTableName();
be2fb01f 1500 return self::singleton()->invoke(['dao'], $dao,
87dab4a4 1501 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1502 $hookName
1503 );
1504 }
1505
1506 /**
1507 * This hook allows user to customize context menu Actions on contact summary page.
1508 *
77855840
TO
1509 * @param array $actions
1510 * Array of all Actions in contextmenu.
1511 * @param int $contactID
1512 * ContactID for the summary page.
f4aaa82a
EM
1513 *
1514 * @return mixed
6a488035 1515 */
00be9182 1516 public static function summaryActions(&$actions, $contactID = NULL) {
be2fb01f 1517 return self::singleton()->invoke(['actions', 'contactID'], $actions, $contactID,
87dab4a4 1518 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1519 'civicrm_summaryActions'
1520 );
1521 }
1522
1523 /**
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
1526 *
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
1529 *
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.
1532 *
77855840
TO
1533 * @param string $objectName
1534 * The component name that we are doing the search.
6a488035 1535 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
f4aaa82a
EM
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
16b10e64
CW
1538 * @param array $selector
1539 * the selector object. Allows you access to the context of the search
6a488035 1540 *
b8c71ffa 1541 * @return mixed
50bfb460 1542 * modify the header and values object to pass the data you need
6a488035 1543 */
00be9182 1544 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
be2fb01f 1545 return self::singleton()->invoke(['objectName', 'headers', 'rows', 'selector'], $objectName, $headers, $rows, $selector,
87dab4a4 1546 self::$_nullObject, self::$_nullObject,
6a488035
TO
1547 'civicrm_searchColumns'
1548 );
1549 }
1550
1551 /**
1552 * This hook is called when uf groups are being built for a module.
1553 *
77855840
TO
1554 * @param string $moduleName
1555 * Module name.
1556 * @param array $ufGroups
1557 * Array of ufgroups for a module.
6a488035
TO
1558 *
1559 * @return null
6a488035 1560 */
00be9182 1561 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
be2fb01f 1562 return self::singleton()->invoke(['moduleName', 'ufGroups'], $moduleName, $ufGroups,
87dab4a4 1563 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1564 'civicrm_buildUFGroupsForModule'
1565 );
1566 }
1567
1568 /**
1569 * This hook is called when we are determining the contactID for a specific
1570 * email address
1571 *
77855840
TO
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.
6a488035
TO
1578 * contactID - the new (or same) contactID
1579 * action - 3 possible values:
9399901d
KJ
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
6a488035
TO
1583 *
1584 * @return null
6a488035 1585 */
00be9182 1586 public static function emailProcessorContact($email, $contactID, &$result) {
be2fb01f 1587 return self::singleton()->invoke(['email', 'contactID', 'result'], $email, $contactID, $result,
87dab4a4 1588 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1589 'civicrm_emailProcessorContact'
1590 );
1591 }
1592
1593 /**
fe482240 1594 * Hook definition for altering the generation of Mailing Labels.
6a488035 1595 *
77855840
TO
1596 * @param array $args
1597 * An array of the args in the order defined for the tcpdf multiCell api call.
6a488035
TO
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).
b44e3f84 1616 * int $stretch stretch character mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
6a488035
TO
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.
1623 *
f4aaa82a 1624 * @return mixed
6a488035 1625 */
00be9182 1626 public static function alterMailingLabelParams(&$args) {
be2fb01f 1627 return self::singleton()->invoke(['args'], $args,
6a488035 1628 self::$_nullObject, self::$_nullObject,
87dab4a4 1629 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1630 'civicrm_alterMailingLabelParams'
1631 );
1632 }
1633
1634 /**
fe482240 1635 * This hooks allows alteration of generated page content.
6a488035 1636 *
77855840
TO
1637 * @param $content
1638 * Previously generated content.
1639 * @param $context
1640 * Context of content - page or form.
1641 * @param $tplName
1642 * The file name of the tpl.
1643 * @param $object
1644 * A reference to the page or form object.
6a488035 1645 *
f4aaa82a 1646 * @return mixed
6a488035 1647 */
00be9182 1648 public static function alterContent(&$content, $context, $tplName, &$object) {
be2fb01f 1649 return self::singleton()->invoke(['content', 'context', 'tplName', 'object'], $content, $context, $tplName, $object,
87dab4a4 1650 self::$_nullObject, self::$_nullObject,
6a488035
TO
1651 'civicrm_alterContent'
1652 );
1653 }
1654
8aac22c8 1655 /**
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
1658 *
77855840
TO
1659 * @param $formName
1660 * Previously generated content.
1661 * @param $form
1662 * Reference to the form object.
1663 * @param $context
1664 * Context of content - page or form.
1665 * @param $tplName
1666 * Reference the file name of the tpl.
8aac22c8 1667 *
f4aaa82a 1668 * @return mixed
8aac22c8 1669 */
00be9182 1670 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
be2fb01f 1671 return self::singleton()->invoke(['formName', 'form', 'context', 'tplName'], $formName, $form, $context, $tplName,
87dab4a4 1672 self::$_nullObject, self::$_nullObject,
8aac22c8 1673 'civicrm_alterTemplateFile'
1674 );
1675 }
f4aaa82a 1676
6a488035 1677 /**
fe482240 1678 * This hook collects the trigger definition from all components.
6a488035 1679 *
f4aaa82a 1680 * @param $info
77855840
TO
1681 * @param string $tableName
1682 * (optional) the name of the table that we are interested in only.
f4aaa82a
EM
1683 *
1684 * @internal param \reference $triggerInfo to an array of trigger information
6a488035
TO
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
f4aaa82a 1693 * @return mixed
6a488035 1694 */
00be9182 1695 public static function triggerInfo(&$info, $tableName = NULL) {
be2fb01f 1696 return self::singleton()->invoke(['info', 'tableName'], $info, $tableName,
87dab4a4 1697 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1698 self::$_nullObject,
1699 'civicrm_triggerInfo'
1700 );
1701 }
6714d8d2 1702
ef587f9c 1703 /**
1704 * This hook allows changes to the spec of which tables to log.
1705 *
1706 * @param array $logTableSpec
1707 *
1708 * @return mixed
1709 */
1710 public static function alterLogTables(&$logTableSpec) {
be2fb01f 1711 return self::singleton()->invoke(['logTableSpec'], $logTableSpec, $_nullObject,
ef587f9c 1712 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1713 self::$_nullObject,
1714 'civicrm_alterLogTables'
1715 );
1716 }
6a488035
TO
1717
1718 /**
1719 * This hook is called when a module-extension is installed.
9399901d
KJ
1720 * Each module will receive hook_civicrm_install during its own installation (but not during the
1721 * installation of unrelated modules).
6a488035 1722 */
00be9182 1723 public static function install() {
6a488035
TO
1724 return self::singleton()->invoke(0, self::$_nullObject,
1725 self::$_nullObject, self::$_nullObject,
87dab4a4 1726 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1727 'civicrm_install'
1728 );
1729 }
1730
1731 /**
1732 * This hook is called when a module-extension is uninstalled.
9399901d
KJ
1733 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1734 * uninstallation of unrelated modules).
6a488035 1735 */
00be9182 1736 public static function uninstall() {
6a488035
TO
1737 return self::singleton()->invoke(0, self::$_nullObject,
1738 self::$_nullObject, self::$_nullObject,
87dab4a4 1739 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1740 'civicrm_uninstall'
1741 );
1742 }
1743
1744 /**
1745 * This hook is called when a module-extension is re-enabled.
9399901d
KJ
1746 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1747 * re-enablement of unrelated modules).
6a488035 1748 */
00be9182 1749 public static function enable() {
6a488035
TO
1750 return self::singleton()->invoke(0, self::$_nullObject,
1751 self::$_nullObject, self::$_nullObject,
87dab4a4 1752 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1753 'civicrm_enable'
1754 );
1755 }
1756
1757 /**
1758 * This hook is called when a module-extension is disabled.
9399901d
KJ
1759 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1760 * disablement of unrelated modules).
6a488035 1761 */
00be9182 1762 public static function disable() {
6a488035
TO
1763 return self::singleton()->invoke(0, self::$_nullObject,
1764 self::$_nullObject, self::$_nullObject,
87dab4a4 1765 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1766 'civicrm_disable'
1767 );
1768 }
1769
f9bdf062 1770 /**
1771 * Alter redirect.
1772 *
1773 * This hook is called when the browser is being re-directed and allows the url
1774 * to be altered.
1775 *
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.
1780 *
1781 * @return null
1782 * the return value is ignored
1783 */
ca4ce861 1784 public static function alterRedirect(&$url, &$context) {
be2fb01f 1785 return self::singleton()->invoke(['url', 'context'], $url,
f9bdf062 1786 $context, self::$_nullObject,
1787 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1788 'civicrm_alterRedirect'
1789 );
1790 }
1791
5bc392e6
EM
1792 /**
1793 * @param $varType
1794 * @param $var
1795 * @param $object
1796 *
1797 * @return mixed
1798 */
00be9182 1799 public static function alterReportVar($varType, &$var, &$object) {
be2fb01f 1800 return self::singleton()->invoke(['varType', 'var', 'object'], $varType, $var, $object,
6a488035 1801 self::$_nullObject,
87dab4a4 1802 self::$_nullObject, self::$_nullObject,
6a488035
TO
1803 'civicrm_alterReportVar'
1804 );
1805 }
1806
1807 /**
1808 * This hook is called to drive database upgrades for extension-modules.
1809 *
72536736
AH
1810 * @param string $op
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.
6a488035 1814 *
72536736
AH
1815 * @return bool|null
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.
6a488035 1819 */
00be9182 1820 public static function upgrade($op, CRM_Queue_Queue $queue = NULL) {
be2fb01f 1821 return self::singleton()->invoke(['op', 'queue'], $op, $queue,
87dab4a4 1822 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1823 self::$_nullObject,
1824 'civicrm_upgrade'
1825 );
1826 }
1827
1828 /**
1829 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1830 *
72536736
AH
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)
1835 *
1836 * @return mixed
6a488035 1837 */
0870a69e 1838 public static function postEmailSend(&$params) {
be2fb01f 1839 return self::singleton()->invoke(['params'], $params,
6a488035 1840 self::$_nullObject, self::$_nullObject,
0870a69e 1841 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1842 'civicrm_postEmailSend'
1843 );
1844 }
1845
0870a69e
BS
1846 /**
1847 * This hook is called when a CiviMail mailing has completed
1848 *
c9a3cf8c
BS
1849 * @param int $mailingId
1850 * Mailing ID
0870a69e
BS
1851 *
1852 * @return mixed
1853 */
c9a3cf8c 1854 public static function postMailing($mailingId) {
be2fb01f 1855 return self::singleton()->invoke(['mailingId'], $mailingId,
0870a69e
BS
1856 self::$_nullObject, self::$_nullObject,
1857 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1858 'civicrm_postMailing'
1859 );
1860 }
1861
6a488035 1862 /**
fe482240 1863 * This hook is called when Settings specifications are loaded.
6a488035 1864 *
72536736
AH
1865 * @param array $settingsFolders
1866 * List of paths from which to derive metadata
1867 *
1868 * @return mixed
6a488035 1869 */
00be9182 1870 public static function alterSettingsFolders(&$settingsFolders) {
be2fb01f 1871 return self::singleton()->invoke(['settingsFolders'], $settingsFolders,
37cd2432
TO
1872 self::$_nullObject, self::$_nullObject,
1873 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1874 'civicrm_alterSettingsFolders'
6a488035
TO
1875 );
1876 }
1877
1878 /**
1879 * This hook is called when Settings have been loaded from the xml
1880 * It is an opportunity for hooks to alter the data
1881 *
77855840
TO
1882 * @param array $settingsMetaData
1883 * Settings Metadata.
72536736
AH
1884 * @param int $domainID
1885 * @param mixed $profile
1886 *
1887 * @return mixed
6a488035 1888 */
00be9182 1889 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
be2fb01f 1890 return self::singleton()->invoke(['settingsMetaData', 'domainID', 'profile'], $settingsMetaData,
37cd2432
TO
1891 $domainID, $profile,
1892 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1893 'civicrm_alterSettingsMetaData'
6a488035
TO
1894 );
1895 }
1896
5270c026
XD
1897 /**
1898 * This hook is called before running an api call.
1899 *
72536736
AH
1900 * @param API_Wrapper[] $wrappers
1901 * (see CRM_Utils_API_ReloadOption as an example)
1902 * @param mixed $apiRequest
5270c026 1903 *
72536736
AH
1904 * @return null
1905 * The return value is ignored
5270c026 1906 */
00be9182 1907 public static function apiWrappers(&$wrappers, $apiRequest) {
09f8c8dc 1908 return self::singleton()
be2fb01f 1909 ->invoke(['wrappers', 'apiRequest'], $wrappers, $apiRequest, self::$_nullObject, self::$_nullObject, self::$_nullObject,
37cd2432
TO
1910 self::$_nullObject, 'civicrm_apiWrappers'
1911 );
5270c026
XD
1912 }
1913
6a488035
TO
1914 /**
1915 * This hook is called before running pending cron jobs.
1916 *
1917 * @param CRM_Core_JobManager $jobManager
1918 *
72536736
AH
1919 * @return null
1920 * The return value is ignored.
6a488035 1921 */
00be9182 1922 public static function cron($jobManager) {
be2fb01f 1923 return self::singleton()->invoke(['jobManager'],
87dab4a4 1924 $jobManager, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1925 'civicrm_cron'
1926 );
1927 }
1928
1929 /**
1930 * This hook is called when loading CMS permissions; use this hook to modify
1931 * the array of system permissions for CiviCRM.
1932 *
72536736
AH
1933 * @param array $permissions
1934 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1935 * the format of this array.
6a488035 1936 *
72536736
AH
1937 * @return null
1938 * The return value is ignored
6a488035 1939 */
00be9182 1940 public static function permission(&$permissions) {
be2fb01f 1941 return self::singleton()->invoke(['permissions'], $permissions,
87dab4a4 1942 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1943 'civicrm_permission'
1944 );
1945 }
fed67e4d 1946
3ae62cab
NG
1947 /**
1948 * This hook is called when checking permissions; use this hook to dynamically
1949 * escalate user permissions in certain use cases (cf. CRM-19256).
1950 *
1951 * @param string $permission
1952 * The name of an atomic permission, ie. 'access deleted contacts'
68773b26 1953 * @param bool $granted
3ae62cab 1954 * Whether this permission is currently granted. The hook can change this value.
fa4dac9c
CW
1955 * @param int $contactId
1956 * Contact whose permissions we are checking (if null, assume current user).
3ae62cab
NG
1957 *
1958 * @return null
1959 * The return value is ignored
1960 */
fa4dac9c 1961 public static function permission_check($permission, &$granted, $contactId) {
be2fb01f 1962 return self::singleton()->invoke(['permission', 'granted', 'contactId'], $permission, $granted, $contactId,
fa4dac9c 1963 self::$_nullObject, self::$_nullObject, self::$_nullObject,
3ae62cab
NG
1964 'civicrm_permission_check'
1965 );
1966 }
1967
4b57bc9f 1968 /**
e97c66ff 1969 * @param CRM_Core_Exception $exception
77855840
TO
1970 * @param mixed $request
1971 * Reserved for future use.
4b57bc9f 1972 */
37cd2432 1973 public static function unhandledException($exception, $request = NULL) {
4caeca04 1974 $event = new \Civi\Core\Event\UnhandledExceptionEvent($exception, self::$_nullObject);
c73e3098 1975 \Civi::dispatcher()->dispatch('hook_civicrm_unhandled_exception', $event);
4b57bc9f 1976 }
fed67e4d
TO
1977
1978 /**
fe482240 1979 * This hook is called for declaring managed entities via API.
fed67e4d 1980 *
e97c66ff 1981 * Note: This is a pre-boot hook. It will dispatch via the extension/module
4d8e83b6
TO
1982 * subsystem but *not* the Symfony EventDispatcher.
1983 *
72536736
AH
1984 * @param array[] $entityTypes
1985 * List of entity types; each entity-type is an array with keys:
fed67e4d
TO
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")
740dd877
TO
1989 * - fields_callback: array, list of callables which manipulates field list
1990 * - links_callback: array, list of callables which manipulates fk list
fed67e4d 1991 *
72536736
AH
1992 * @return null
1993 * The return value is ignored
fed67e4d 1994 */
00be9182 1995 public static function entityTypes(&$entityTypes) {
be2fb01f 1996 return self::singleton()->invoke(['entityTypes'], $entityTypes, self::$_nullObject, self::$_nullObject,
87dab4a4 1997 self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_entityTypes'
fed67e4d
TO
1998 );
1999 }
a8387f19 2000
bdd65b5c
TO
2001 /**
2002 * Build a description of available hooks.
2003 *
ec84755a 2004 * @param \Civi\Core\CiviEventInspector $inspector
bdd65b5c 2005 */
47e7c2f8 2006 public static function eventDefs($inspector) {
be2fb01f 2007 $event = \Civi\Core\Event\GenericHookEvent::create([
00932067 2008 'inspector' => $inspector,
be2fb01f 2009 ]);
47e7c2f8 2010 Civi::dispatcher()->dispatch('hook_civicrm_eventDefs', $event);
bdd65b5c
TO
2011 }
2012
a8387f19 2013 /**
fe482240 2014 * This hook is called while preparing a profile form.
a8387f19 2015 *
0fcad357 2016 * @param string $profileName
72536736 2017 * @return mixed
a8387f19 2018 */
0fcad357 2019 public static function buildProfile($profileName) {
be2fb01f 2020 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 2021 self::$_nullObject, self::$_nullObject, 'civicrm_buildProfile');
a8387f19
TO
2022 }
2023
2024 /**
fe482240 2025 * This hook is called while validating a profile form submission.
a8387f19 2026 *
0fcad357 2027 * @param string $profileName
72536736 2028 * @return mixed
a8387f19 2029 */
0fcad357 2030 public static function validateProfile($profileName) {
be2fb01f 2031 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 2032 self::$_nullObject, self::$_nullObject, 'civicrm_validateProfile');
a8387f19
TO
2033 }
2034
2035 /**
fe482240 2036 * This hook is called processing a valid profile form submission.
a8387f19 2037 *
0fcad357 2038 * @param string $profileName
72536736 2039 * @return mixed
a8387f19 2040 */
0fcad357 2041 public static function processProfile($profileName) {
be2fb01f 2042 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 2043 self::$_nullObject, self::$_nullObject, 'civicrm_processProfile');
a8387f19
TO
2044 }
2045
2046 /**
2047 * This hook is called while preparing a read-only profile screen
2048 *
0fcad357 2049 * @param string $profileName
72536736 2050 * @return mixed
a8387f19 2051 */
0fcad357 2052 public static function viewProfile($profileName) {
be2fb01f 2053 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 2054 self::$_nullObject, self::$_nullObject, 'civicrm_viewProfile');
a8387f19
TO
2055 }
2056
2057 /**
2058 * This hook is called while preparing a list of contacts (based on a profile)
2059 *
0fcad357 2060 * @param string $profileName
72536736 2061 * @return mixed
a8387f19 2062 */
0fcad357 2063 public static function searchProfile($profileName) {
be2fb01f 2064 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 2065 self::$_nullObject, self::$_nullObject, 'civicrm_searchProfile');
9399901d
KJ
2066 }
2067
d0fc33e2
M
2068 /**
2069 * This hook is invoked when building a CiviCRM name badge.
2070 *
77855840
TO
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.
d0fc33e2 2079 *
a6c01b45
CW
2080 * @return null
2081 * the return value is ignored
d0fc33e2 2082 */
00be9182 2083 public static function alterBadge($labelName, &$label, &$format, &$participant) {
37cd2432 2084 return self::singleton()
be2fb01f 2085 ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self::$_nullObject, self::$_nullObject, 'civicrm_alterBadge');
d0fc33e2
M
2086 }
2087
9399901d 2088 /**
fe482240 2089 * This hook is called before encoding data in barcode.
9399901d 2090 *
77855840
TO
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.
9399901d 2097 *
72536736 2098 * @return mixed
9399901d 2099 */
e7292422 2100 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
be2fb01f 2101 return self::singleton()->invoke(['data', 'type', 'context'], $data, $type, $context, self::$_nullObject,
87dab4a4 2102 self::$_nullObject, self::$_nullObject, 'civicrm_alterBarcode');
a8387f19 2103 }
99e9587a 2104
72ad6c1b
TO
2105 /**
2106 * Modify or replace the Mailer object used for outgoing mail.
2107 *
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
72536736
AH
2114 *
2115 * @return mixed
72ad6c1b
TO
2116 * @see Mail::factory
2117 */
f2b63bd3 2118 public static function alterMailer(&$mailer, $driver, $params) {
c8e4bea0 2119 return self::singleton()
be2fb01f 2120 ->invoke(['mailer', 'driver', 'params'], $mailer, $driver, $params, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_alterMailer');
72ad6c1b
TO
2121 }
2122
f2b63bd3
C
2123 /**
2124 * Deprecated: Misnamed version of alterMailer(). Remove post-4.7.x.
2125 * Modify or replace the Mailer object used for outgoing mail.
2126 *
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
2133 *
2134 * @return mixed
2135 * @see Mail::factory
2136 * @deprecated
2137 */
2138 public static function alterMail(&$mailer, $driver, $params) {
d63e34d7 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.
496320c3 2145 CRM_Core_Error::deprecatedFunctionWarning('CRM_Utils_Hook::alterMailer');
f2b63bd3
C
2146 return CRM_Utils_Hook::alterMailer($mailer, $driver, $params);
2147 }
2148
99e9587a 2149 /**
2efcf0c2 2150 * This hook is called while building the core search query,
99e9587a
DS
2151 * so hook implementers can provide their own query objects which alters/extends core search.
2152 *
72536736
AH
2153 * @param array $queryObjects
2154 * @param string $type
2155 *
2156 * @return mixed
99e9587a 2157 */
00be9182 2158 public static function queryObjects(&$queryObjects, $type = 'Contact') {
37cd2432 2159 return self::singleton()
be2fb01f 2160 ->invoke(['queryObjects', 'type'], $queryObjects, $type, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_queryObjects');
99e9587a 2161 }
15d9b3ae
N
2162
2163 /**
fe482240 2164 * This hook is called while viewing contact dashboard.
15d9b3ae 2165 *
72536736
AH
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
2170 *
2171 * @return mixed
15d9b3ae 2172 */
00be9182 2173 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
37cd2432 2174 return self::singleton()
be2fb01f 2175 ->invoke(['availableDashlets', 'defaultDashlets'], $availableDashlets, $defaultDashlets, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_dashboard_defaults');
15d9b3ae 2176 }
02094cdb
JJ
2177
2178 /**
2179 * This hook is called before a case merge (or a case reassign)
f4aaa82a 2180 *
77855840
TO
2181 * @param int $mainContactId
2182 * @param int $mainCaseId
2183 * @param int $otherContactId
2184 * @param int $otherCaseId
3d0d359e 2185 * @param bool $changeClient
f4aaa82a 2186 *
b8c71ffa 2187 * @return mixed
02094cdb 2188 */
00be9182 2189 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
37cd2432 2190 return self::singleton()
be2fb01f 2191 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_pre_case_merge');
02094cdb 2192 }
f4aaa82a 2193
02094cdb
JJ
2194 /**
2195 * This hook is called after a case merge (or a case reassign)
f4aaa82a 2196 *
77855840
TO
2197 * @param int $mainContactId
2198 * @param int $mainCaseId
2199 * @param int $otherContactId
2200 * @param int $otherCaseId
3d0d359e 2201 * @param bool $changeClient
77b97be7 2202 *
b8c71ffa 2203 * @return mixed
02094cdb 2204 */
00be9182 2205 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
37cd2432 2206 return self::singleton()
be2fb01f 2207 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_post_case_merge');
02094cdb 2208 }
250b3b1f 2209
2210 /**
2211 * Issue CRM-14276
2212 * Add a hook for altering the display name
2213 *
2214 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
f4aaa82a 2215 *
250b3b1f 2216 * @param string $displayName
2217 * @param int $contactId
77855840
TO
2218 * @param object $dao
2219 * The contact object.
f4aaa82a
EM
2220 *
2221 * @return mixed
250b3b1f 2222 */
267578ea 2223 public static function alterDisplayName(&$displayName, $contactId, $dao) {
be2fb01f 2224 return self::singleton()->invoke(['displayName', 'contactId', 'dao'],
250b3b1f 2225 $displayName, $contactId, $dao, self::$_nullObject, self::$_nullObject,
2226 self::$_nullObject, 'civicrm_contact_get_displayname'
2227 );
2228 }
e7ff7042 2229
898951c6
TO
2230 /**
2231 * Modify the CRM_Core_Resources settings data.
2232 *
2233 * @param array $data
2234 * @see CRM_Core_Resources::addSetting
2235 */
2236 public static function alterResourceSettings(&$data) {
be2fb01f 2237 $event = \Civi\Core\Event\GenericHookEvent::create([
898951c6 2238 'data' => &$data,
be2fb01f 2239 ]);
898951c6
TO
2240 Civi::dispatcher()->dispatch('hook_civicrm_alterResourceSettings', $event);
2241 }
2242
e7ff7042
TO
2243 /**
2244 * EXPERIMENTAL: This hook allows one to register additional Angular modules
2245 *
77855840 2246 * @param array $angularModules
5438399c
TO
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.
8da6c9b8
TO
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('*')".
a6c01b45
CW
2257 * @return null
2258 * the return value is ignored
e7ff7042
TO
2259 *
2260 * @code
2261 * function mymod_civicrm_angularModules(&$angularModules) {
8671b4f2
TO
2262 * $angularModules['myAngularModule'] = array(
2263 * 'ext' => 'org.example.mymod',
2264 * 'js' => array('js/myAngularModule.js'),
2265 * );
2266 * $angularModules['myBigAngularModule'] = array(
2267 * 'ext' => 'org.example.mymod',
e5c376e7
TO
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'),
8671b4f2 2270 * 'partials' => array('partials/myBigAngularModule'),
5438399c 2271 * 'requires' => array('otherModuleA', 'otherModuleB'),
8da6c9b8 2272 * 'basePages' => array('civicrm/a'),
8671b4f2 2273 * );
e7ff7042
TO
2274 * }
2275 * @endcode
2276 */
00be9182 2277 public static function angularModules(&$angularModules) {
be2fb01f 2278 return self::singleton()->invoke(['angularModules'], $angularModules,
e7ff7042
TO
2279 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2280 'civicrm_angularModules'
2281 );
2282 }
2283
6dc348de
TO
2284 /**
2285 * Alter the definition of some Angular HTML partials.
2286 *
2287 * @param \Civi\Angular\Manager $angular
2288 *
2289 * @code
2290 * function example_civicrm_alterAngular($angular) {
f895c70e 2291 * $changeSet = \Civi\Angular\ChangeSet::create('mychanges')
6dc348de
TO
2292 * ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) {
2293 * $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')');
2294 * })
2295 * );
36bd3f7f 2296 * $angular->add($changeSet);
6dc348de
TO
2297 * }
2298 * @endCode
2299 */
2300 public static function alterAngular($angular) {
be2fb01f 2301 $event = \Civi\Core\Event\GenericHookEvent::create([
6dc348de 2302 'angular' => $angular,
be2fb01f 2303 ]);
6dc348de
TO
2304 Civi::dispatcher()->dispatch('hook_civicrm_alterAngular', $event);
2305 }
2306
c4560ed2
CW
2307 /**
2308 * This hook is called when building a link to a semi-static asset.
2309 *
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.
2315 * @return null
2316 * the return value is ignored
2317 */
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'
2322 );
2323 }
2324
87e3fe24
TO
2325 /**
2326 * This hook is called whenever the system builds a new copy of
2327 * semi-static asset.
2328 *
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.
2339 * @return null
2340 * the return value is ignored
2341 */
2342 public static function buildAsset($asset, $params, &$mimeType, &$content) {
be2fb01f 2343 return self::singleton()->invoke(['asset', 'params', 'mimeType', 'content'],
87e3fe24
TO
2344 $asset, $params, $mimeType, $content, self::$_nullObject, self::$_nullObject,
2345 'civicrm_buildAsset'
2346 );
2347 }
2348
708d8fa2
TO
2349 /**
2350 * This hook fires whenever a record in a case changes.
2351 *
2352 * @param \Civi\CCase\Analyzer $analyzer
542441f4 2353 * A bundle of data about the case (such as the case and activity records).
708d8fa2 2354 */
00be9182 2355 public static function caseChange(\Civi\CCase\Analyzer $analyzer) {
708d8fa2 2356 $event = new \Civi\CCase\Event\CaseChangeEvent($analyzer);
c73e3098 2357 \Civi::dispatcher()->dispatch('hook_civicrm_caseChange', $event);
708d8fa2 2358 }
688ad538
TO
2359
2360 /**
fe482240 2361 * Generate a default CRUD URL for an entity.
688ad538 2362 *
77855840
TO
2363 * @param array $spec
2364 * With keys:.
688ad538
TO
2365 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
2366 * - entity_table: string
2367 * - entity_id: int
2368 * @param CRM_Core_DAO $bao
77855840
TO
2369 * @param array $link
2370 * To define the link, add these keys to $link:.
16b10e64
CW
2371 * - title: string
2372 * - path: string
2373 * - query: array
2374 * - url: string (used in lieu of "path"/"query")
688ad538
TO
2375 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
2376 * @return mixed
2377 */
00be9182 2378 public static function crudLink($spec, $bao, &$link) {
be2fb01f 2379 return self::singleton()->invoke(['spec', 'bao', 'link'], $spec, $bao, $link,
688ad538
TO
2380 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2381 'civicrm_crudLink'
2382 );
2383 }
6cccc6d4 2384
40787e18
TO
2385 /**
2386 * Modify the CiviCRM container - add new services, parameters, extensions, etc.
2387 *
2388 * @code
2389 * use Symfony\Component\Config\Resource\FileResource;
2390 * use Symfony\Component\DependencyInjection\Definition;
2391 *
2392 * function mymodule_civicrm_container($container) {
2393 * $container->addResource(new FileResource(__FILE__));
2394 * $container->setDefinition('mysvc', new Definition('My\Class', array()));
2395 * }
2396 * @endcode
2397 *
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').
2402 *
4d8e83b6
TO
2403 * Note: This is a preboot hook. It will dispatch via the extension/module
2404 * subsystem but *not* the Symfony EventDispatcher.
2405 *
40787e18
TO
2406 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
2407 * @see http://symfony.com/doc/current/components/dependency_injection/index.html
2408 */
2409 public static function container(\Symfony\Component\DependencyInjection\ContainerBuilder $container) {
be2fb01f 2410 self::singleton()->invoke(['container'], $container, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_container');
40787e18
TO
2411 }
2412
6cccc6d4 2413 /**
6714d8d2 2414 * @param array $fileSearches CRM_Core_FileSearchInterface
6cccc6d4
TO
2415 * @return mixed
2416 */
00be9182 2417 public static function fileSearches(&$fileSearches) {
be2fb01f 2418 return self::singleton()->invoke(['fileSearches'], $fileSearches,
6cccc6d4
TO
2419 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2420 'civicrm_fileSearches'
2421 );
2422 }
96025800 2423
260e353b
TO
2424 /**
2425 * Check system status.
2426 *
2427 * @param array $messages
2428 * Array<CRM_Utils_Check_Message>. A list of messages regarding system status.
2429 * @return mixed
2430 */
2431 public static function check(&$messages) {
2432 return self::singleton()
be2fb01f 2433 ->invoke(['messages'], $messages, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_check');
260e353b
TO
2434 }
2435
75c8a3f7
GC
2436 /**
2437 * This hook is called when a query string of the CSV Batch export is generated.
54957108 2438 *
2439 * @param string $query
2440 *
2441 * @return mixed
75c8a3f7
GC
2442 */
2443 public static function batchQuery(&$query) {
be2fb01f 2444 return self::singleton()->invoke(['query'], $query, self::$_nullObject,
75c8a3f7
GC
2445 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2446 'civicrm_batchQuery'
2447 );
2448 }
2449
7340e501
PN
2450 /**
2451 * This hook is called to alter Deferred revenue item values just before they are
2452 * inserted in civicrm_financial_trxn table
2453 *
2454 * @param array $deferredRevenues
2455 *
7f35de6b
PN
2456 * @param array $contributionDetails
2457 *
2458 * @param bool $update
2459 *
2460 * @param string $context
2461 *
7340e501
PN
2462 * @return mixed
2463 */
7f35de6b 2464 public static function alterDeferredRevenueItems(&$deferredRevenues, $contributionDetails, $update, $context) {
be2fb01f 2465 return self::singleton()->invoke(['deferredRevenues', 'contributionDetails', 'update', 'context'], $deferredRevenues, $contributionDetails, $update, $context,
7f35de6b 2466 self::$_nullObject, self::$_nullObject, 'civicrm_alterDeferredRevenueItems'
7340e501
PN
2467 );
2468 }
2469
75c8a3f7
GC
2470 /**
2471 * This hook is called when the entries of the CSV Batch export are mapped.
54957108 2472 *
2473 * @param array $results
2474 * @param array $items
2475 *
2476 * @return mixed
75c8a3f7
GC
2477 */
2478 public static function batchItems(&$results, &$items) {
be2fb01f 2479 return self::singleton()->invoke(['results', 'items'], $results, $items,
75c8a3f7
GC
2480 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2481 'civicrm_batchItems'
2482 );
2483 }
2484
72e86d7d
CW
2485 /**
2486 * This hook is called when core resources are being loaded
2487 *
2488 * @see CRM_Core_Resources::coreResourceList
2489 *
2490 * @param array $list
e3c1e85b 2491 * @param string $region
72e86d7d 2492 */
e3c1e85b 2493 public static function coreResourceList(&$list, $region) {
be2fb01f 2494 self::singleton()->invoke(['list', 'region'], $list, $region,
e3c1e85b 2495 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
72e86d7d
CW
2496 'civicrm_coreResourceList'
2497 );
2498 }
2499
fd7c068f
CW
2500 /**
2501 * Allows the list of filters on the EntityRef widget to be altered.
2502 *
2503 * @see CRM_Core_Resources::entityRefFilters
2504 *
2505 * @param array $filters
7022db93 2506 * @param array $links
fd7c068f 2507 */
77d0bf4e
PN
2508 public static function entityRefFilters(&$filters, &$links = NULL) {
2509 self::singleton()->invoke(['filters', 'links'], $filters, $links, self::$_nullObject,
fd7c068f
CW
2510 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2511 'civicrm_entityRefFilters'
2512 );
2513 }
2514
aa00da9b 2515 /**
f3f00653 2516 * This hook is called for bypass a few civicrm urls from IDS check.
2517 *
2518 * @param array $skip list of civicrm urls
2519 *
2520 * @return mixed
aa00da9b 2521 */
2522 public static function idsException(&$skip) {
be2fb01f 2523 return self::singleton()->invoke(['skip'], $skip, self::$_nullObject,
aa00da9b 2524 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2525 'civicrm_idsException'
2526 );
2527 }
2528
e6209c6e
J
2529 /**
2530 * This hook is called when a geocoder's format method is called.
2531 *
4b62bfd8 2532 * @param string $geoProvider
e6209c6e
J
2533 * @param array $values
2534 * @param SimpleXMLElement $xml
f3f00653 2535 *
2536 * @return mixed
e6209c6e 2537 */
4b62bfd8 2538 public static function geocoderFormat($geoProvider, &$values, $xml) {
be2fb01f 2539 return self::singleton()->invoke(['geoProvider', 'values', 'xml'], $geoProvider, $values, $xml,
4b62bfd8 2540 self::$_nullObject, self::$_nullObject, self::$_nullObject,
e6209c6e
J
2541 'civicrm_geocoderFormat'
2542 );
2543 }
2544
0613768a
EE
2545 /**
2546 * This hook is called before an inbound SMS is processed.
2547 *
e97c66ff 2548 * @param \CRM_SMS_Message $message
6714d8d2 2549 * An SMS message received
caed3ddc
SL
2550 * @return mixed
2551 */
2552 public static function inboundSMS(&$message) {
be2fb01f 2553 return self::singleton()->invoke(['message'], $message, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_inboundSMS');
0613768a
EE
2554 }
2555
33f07374 2556 /**
2557 * This hook is called to modify api params of EntityRef form field
2558 *
2559 * @param array $params
6714d8d2 2560 * @param string $formName
33f07374 2561 * @return mixed
2562 */
f9585de5 2563 public static function alterEntityRefParams(&$params, $formName) {
be2fb01f 2564 return self::singleton()->invoke(['params', 'formName'], $params, $formName,
33f07374 2565 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2566 'civicrm_alterEntityRefParams'
2567 );
2568 }
2569
912d0751
RT
2570 /**
2571 * This hook is called before a scheduled job is executed
2572 *
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
2577 */
2578 public static function preJob($job, $params) {
be2fb01f 2579 return self::singleton()->invoke(['job', 'params'], $job, $params,
912d0751
RT
2580 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2581 'civicrm_preJob'
2582 );
2583 }
2584
2585 /**
2586 * This hook is called after a scheduled job is executed
2587 *
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
2594 */
2595 public static function postJob($job, $params, $result) {
be2fb01f 2596 return self::singleton()->invoke(['job', 'params', 'result'], $job, $params, $result,
912d0751
RT
2597 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2598 'civicrm_postJob'
2599 );
2600 }
2601
3417627c 2602 /**
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
2605 *
2606 * @param CRM_Mailing_DAO_Mailing $mailingObject
906298d3
TO
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")).
3417627c 2611 * @param string $context
906298d3
TO
2612 * Ex: 'pre', 'post'
2613 * @return mixed
3417627c 2614 */
906298d3 2615 public static function alterMailingRecipients(&$mailingObject, &$criteria, $context) {
be2fb01f 2616 return self::singleton()->invoke(['mailingObject', 'params', 'context'],
906298d3 2617 $mailingObject, $criteria, $context,
737f12a7 2618 self::$_nullObject, self::$_nullObject, self::$_nullObject,
3417627c 2619 'civicrm_alterMailingRecipients'
2620 );
2621 }
2622
2d39b9c0
SL
2623 /**
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
2626 * @return mixed
2627 */
2628 public static function postIPNProcess(&$IPNData) {
be2fb01f 2629 return self::singleton()->invoke(['IPNData'],
2d39b9c0
SL
2630 $IPNData, self::$_nullObject, self::$_nullObject,
2631 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2632 'civicrm_postIPNProcess'
2633 );
2634 }
2635
6a488035 2636}