Merge pull request #16711 from eileenmcnaughton/deprecated
[civicrm-core.git] / CRM / Utils / Hook.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CiviCRM_Hook
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17 abstract class CRM_Utils_Hook {
18
19 // Allowed values for dashboard hook content placement
20 // Default - place content below activity list
21 const DASHBOARD_BELOW = 1;
22 // Place content above activity list
23 const DASHBOARD_ABOVE = 2;
24 // Don't display activity list at all
25 const DASHBOARD_REPLACE = 3;
26
27 // by default - place content below existing content
28 const SUMMARY_BELOW = 1;
29 // place hook content above
30 const SUMMARY_ABOVE = 2;
31 /**
32 *create your own summaries
33 */
34 const SUMMARY_REPLACE = 3;
35
36 /**
37 * Object to pass when an object is required to be passed by params.
38 *
39 * This is supposed to be a convenience but note that it is a bad
40 * pattern as it can get contaminated & result in hard-to-diagnose bugs.
41 *
42 * @var null
43 */
44 public static $_nullObject = NULL;
45
46 /**
47 * We only need one instance of this object. So we use the singleton
48 * pattern and cache the instance in this variable
49 *
50 * @var CRM_Utils_Hook
51 */
52 static private $_singleton = NULL;
53
54 /**
55 * @var bool
56 */
57 private $commonIncluded = FALSE;
58
59 /**
60 * @var array|string
61 */
62 private $commonCiviModules = [];
63
64 /**
65 * @var CRM_Utils_Cache_Interface
66 */
67 protected $cache;
68
69 /**
70 * Constructor and getter for the singleton instance.
71 *
72 * @param bool $fresh
73 *
74 * @return CRM_Utils_Hook
75 * An instance of $config->userHookClass
76 */
77 public static function singleton($fresh = FALSE) {
78 if (self::$_singleton == NULL || $fresh) {
79 $config = CRM_Core_Config::singleton();
80 $class = $config->userHookClass;
81 self::$_singleton = new $class();
82 }
83 return self::$_singleton;
84 }
85
86 /**
87 * CRM_Utils_Hook constructor.
88 *
89 * @throws \CRM_Core_Exception
90 */
91 public function __construct() {
92 $this->cache = CRM_Utils_Cache::create([
93 'name' => 'hooks',
94 'type' => ['ArrayCache'],
95 'prefetch' => 1,
96 ]);
97 }
98
99 /**
100 * Invoke a hook through the UF/CMS hook system and the extension-hook
101 * system.
102 *
103 * @param int $numParams
104 * Number of parameters to pass to the hook.
105 * @param mixed $arg1
106 * Parameter to be passed to the hook.
107 * @param mixed $arg2
108 * Parameter to be passed to the hook.
109 * @param mixed $arg3
110 * Parameter to be passed to the hook.
111 * @param mixed $arg4
112 * Parameter to be passed to the hook.
113 * @param mixed $arg5
114 * Parameter to be passed to the hook.
115 * @param mixed $arg6
116 * Parameter to be passed to the hook.
117 * @param string $fnSuffix
118 * Function suffix, this is effectively the hook name.
119 *
120 * @return mixed
121 */
122 abstract public function invokeViaUF(
123 $numParams,
124 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
125 $fnSuffix
126 );
127
128 /**
129 * Invoke a hook.
130 *
131 * This is a transitional adapter. It supports the legacy syntax
132 * but also accepts enough information to support Symfony Event
133 * dispatching.
134 *
135 * @param array|int $names
136 * (Recommended) Array of parameter names, in order.
137 * Using an array is recommended because it enables full
138 * event-broadcasting behaviors.
139 * (Legacy) Number of parameters to pass to the hook.
140 * This is provided for transitional purposes.
141 * @param mixed $arg1
142 * @param mixed $arg2
143 * @param mixed $arg3
144 * @param mixed $arg4
145 * @param mixed $arg5
146 * @param mixed $arg6
147 * @param mixed $fnSuffix
148 * @return mixed
149 */
150 public function invoke(
151 $names,
152 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
153 $fnSuffix
154 ) {
155 // Per https://github.com/civicrm/civicrm-core/pull/13551 we have had ongoing significant problems where hooks from modules are
156 // invoked during upgrade but not those from extensions. The issues are both that an incorrect module list & settings are cached and that
157 // some hooks REALLY need to run during upgrade - the loss of triggers during upgrade causes significant loss of data
158 // whereas loss of logTable hooks means that log tables are created for tables specifically excluded - e.g due to large
159 // quantities of low-importance data or the table not having an id field, which could cause a fatal error.
160 // Instead of not calling any hooks we only call those we know to be frequently important - if a particular extension wanted
161 // to avoid this they could do an early return on CRM_Core_Config::singleton()->isUpgradeMode
162 // Futther discussion is happening at https://lab.civicrm.org/dev/core/issues/1460
163 $upgradeFriendlyHooks = ['civicrm_alterSettingsFolders', 'civicrm_alterSettingsMetaData', 'civicrm_triggerInfo', 'civicrm_alterLogTables', 'civicrm_container', 'civicrm_permission', 'civicrm_managed'];
164 if (CRM_Core_Config::singleton()->isUpgradeMode() && !in_array($fnSuffix, $upgradeFriendlyHooks)) {
165 return;
166 }
167 if (is_array($names) && !defined('CIVICRM_FORCE_LEGACY_HOOK') && \Civi\Core\Container::isContainerBooted()) {
168 $event = \Civi\Core\Event\GenericHookEvent::createOrdered(
169 $names,
170 array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6)
171 );
172 \Civi::dispatcher()->dispatch('hook_' . $fnSuffix, $event);
173 return $event->getReturnValues();
174 }
175 else {
176 // We need to ensure tht we will still run known bootstrap related hooks even if the container is not booted.
177 $prebootContainerHooks = array_merge($upgradeFriendlyHooks, ['civicrm_entityTypes', 'civicrm_config']);
178 if (!\Civi\Core\Container::isContainerBooted() && !in_array($fnSuffix, $prebootContainerHooks)) {
179 return;
180 }
181 $count = is_array($names) ? count($names) : $names;
182 return $this->invokeViaUF($count, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $fnSuffix);
183 }
184 }
185
186 /**
187 * @param array $numParams
188 * @param $arg1
189 * @param $arg2
190 * @param $arg3
191 * @param $arg4
192 * @param $arg5
193 * @param $arg6
194 * @param $fnSuffix
195 * @param $fnPrefix
196 *
197 * @return array|bool
198 */
199 public function commonInvoke(
200 $numParams,
201 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
202 $fnSuffix, $fnPrefix
203 ) {
204
205 $this->commonBuildModuleList($fnPrefix);
206
207 return $this->runHooks($this->commonCiviModules, $fnSuffix,
208 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
209 );
210 }
211
212 /**
213 * Build the list of modules to be processed for hooks.
214 *
215 * @param string $fnPrefix
216 */
217 public function commonBuildModuleList($fnPrefix) {
218 if (!$this->commonIncluded) {
219 // include external file
220 $this->commonIncluded = TRUE;
221
222 $config = CRM_Core_Config::singleton();
223 if (!empty($config->customPHPPathDir)) {
224 $civicrmHooksFile = CRM_Utils_File::addTrailingSlash($config->customPHPPathDir) . 'civicrmHooks.php';
225 if (file_exists($civicrmHooksFile)) {
226 @include_once $civicrmHooksFile;
227 }
228 }
229
230 if (!empty($fnPrefix)) {
231 $this->commonCiviModules[$fnPrefix] = $fnPrefix;
232 }
233
234 $this->requireCiviModules($this->commonCiviModules);
235 }
236 }
237
238 /**
239 * Run hooks.
240 *
241 * @param array $civiModules
242 * @param string $fnSuffix
243 * @param int $numParams
244 * @param mixed $arg1
245 * @param mixed $arg2
246 * @param mixed $arg3
247 * @param mixed $arg4
248 * @param mixed $arg5
249 * @param mixed $arg6
250 *
251 * @return array|bool
252 * @throws \CRM_Core_Exception
253 */
254 public function runHooks(
255 $civiModules, $fnSuffix, $numParams,
256 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
257 ) {
258 // $civiModules is *not* passed by reference because runHooks
259 // must be reentrant. PHP is finicky about running
260 // multiple loops over the same variable. The circumstances
261 // to reproduce the issue are pretty intricate.
262 $result = [];
263
264 $fnNames = $this->cache->get($fnSuffix);
265 if (!is_array($fnNames)) {
266 $fnNames = [];
267 if ($civiModules !== NULL) {
268 foreach ($civiModules as $module) {
269 $fnName = "{$module}_{$fnSuffix}";
270 if (function_exists($fnName)) {
271 $fnNames[] = $fnName;
272 }
273 }
274 $this->cache->set($fnSuffix, $fnNames);
275 }
276 }
277
278 foreach ($fnNames as $fnName) {
279 $fResult = [];
280 switch ($numParams) {
281 case 0:
282 $fResult = $fnName();
283 break;
284
285 case 1:
286 $fResult = $fnName($arg1);
287 break;
288
289 case 2:
290 $fResult = $fnName($arg1, $arg2);
291 break;
292
293 case 3:
294 $fResult = $fnName($arg1, $arg2, $arg3);
295 break;
296
297 case 4:
298 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
299 break;
300
301 case 5:
302 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
303 break;
304
305 case 6:
306 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
307 break;
308
309 default:
310 throw new CRM_Core_Exception(ts('Invalid hook invocation'));
311 }
312
313 if (!empty($fResult) &&
314 is_array($fResult)
315 ) {
316 $result = array_merge($result, $fResult);
317 }
318 }
319
320 return empty($result) ? TRUE : $result;
321 }
322
323 /**
324 * @param $moduleList
325 */
326 public function requireCiviModules(&$moduleList) {
327 $civiModules = CRM_Core_PseudoConstant::getModuleExtensions();
328 foreach ($civiModules as $civiModule) {
329 if (!file_exists($civiModule['filePath'])) {
330 CRM_Core_Session::setStatus(
331 ts('Error loading module file (%1). Please restore the file or disable the module.',
332 [1 => $civiModule['filePath']]),
333 ts('Warning'), 'error');
334 continue;
335 }
336 include_once $civiModule['filePath'];
337 $moduleList[$civiModule['prefix']] = $civiModule['prefix'];
338 }
339 }
340
341 /**
342 * This hook is called before a db write on some core objects.
343 * This hook does not allow the abort of the operation
344 *
345 * @param string $op
346 * The type of operation being performed.
347 * @param string $objectName
348 * The name of the object.
349 * @param int $id
350 * The object id if available.
351 * @param array $params
352 * The parameters used for object creation / editing.
353 *
354 * @return null
355 * the return value is ignored
356 */
357 public static function pre($op, $objectName, $id, &$params) {
358 // Dev/core#1449 DO not dispatch hook_civicrm_pre if we are in an upgrade as this cases the upgrade to fail
359 // Futher discussion is happening at https://lab.civicrm.org/dev/core/issues/1460
360 if (CRM_Core_Config::singleton()->isUpgradeMode()) {
361 return;
362 }
363 $event = new \Civi\Core\Event\PreEvent($op, $objectName, $id, $params);
364 \Civi::dispatcher()->dispatch('hook_civicrm_pre', $event);
365 return $event->getReturnValues();
366 }
367
368 /**
369 * This hook is called after a db write on some core objects.
370 *
371 * @param string $op
372 * The type of operation being performed.
373 * @param string $objectName
374 * The name of the object.
375 * @param int $objectId
376 * The unique identifier for the object.
377 * @param object $objectRef
378 * The reference to the object if available.
379 *
380 * @return mixed
381 * based on op. pre-hooks return a boolean or
382 * an error message which aborts the operation
383 */
384 public static function post($op, $objectName, $objectId, &$objectRef = NULL) {
385 // Dev/core#1449 DO not dispatch hook_civicrm_post if we are in an upgrade as this cases the upgrade to fail
386 // Futher discussion is happening at https://lab.civicrm.org/dev/core/issues/1460
387 if (CRM_Core_Config::singleton()->isUpgradeMode()) {
388 return;
389 }
390 $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef);
391 \Civi::dispatcher()->dispatch('hook_civicrm_post', $event);
392 return $event->getReturnValues();
393 }
394
395 /**
396 * This hook retrieves links from other modules and injects it into.
397 * the view contact tabs
398 *
399 * @param string $op
400 * The type of operation being performed.
401 * @param string $objectName
402 * The name of the object.
403 * @param int $objectId
404 * The unique identifier for the object.
405 * @param array $links
406 * (optional) the links array (introduced in v3.2).
407 * @param int $mask
408 * (optional) the bitmask to show/hide links.
409 * @param array $values
410 * (optional) the values to fill the links.
411 *
412 * @return null
413 * the return value is ignored
414 */
415 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = []) {
416 return self::singleton()->invoke(['op', 'objectName', 'objectId', 'links', 'mask', 'values'], $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
417 }
418
419 /**
420 * This hook is invoked during the CiviCRM form preProcess phase.
421 *
422 * @param string $formName
423 * The name of the form.
424 * @param CRM_Core_Form $form
425 * Reference to the form object.
426 *
427 * @return null
428 * the return value is ignored
429 */
430 public static function preProcess($formName, &$form) {
431 return self::singleton()
432 ->invoke(['formName', 'form'], $formName, $form, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_preProcess');
433 }
434
435 /**
436 * This hook is invoked when building a CiviCRM form. This hook should also
437 * be used to set the default values of a form element
438 *
439 * @param string $formName
440 * The name of the form.
441 * @param CRM_Core_Form $form
442 * Reference to the form object.
443 *
444 * @return null
445 * the return value is ignored
446 */
447 public static function buildForm($formName, &$form) {
448 return self::singleton()->invoke(['formName', 'form'], $formName, $form,
449 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
450 'civicrm_buildForm'
451 );
452 }
453
454 /**
455 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
456 * any form elements, this hook should save the values in the database
457 *
458 * @param string $formName
459 * The name of the form.
460 * @param CRM_Core_Form $form
461 * Reference to the form object.
462 *
463 * @return null
464 * the return value is ignored
465 */
466 public static function postProcess($formName, &$form) {
467 return self::singleton()->invoke(['formName', 'form'], $formName, $form,
468 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
469 'civicrm_postProcess'
470 );
471 }
472
473 /**
474 * This hook is invoked during all CiviCRM form validation. An array of errors
475 * detected is returned. Else we assume validation succeeded.
476 *
477 * @param string $formName
478 * The name of the form.
479 * @param array &$fields the POST parameters as filtered by QF
480 * @param array &$files the FILES parameters as sent in by POST
481 * @param array &$form the form object
482 * @param array &$errors the array of errors.
483 *
484 * @return mixed
485 * formRule hooks return a boolean or
486 * an array of error messages which display a QF Error
487 */
488 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
489 return self::singleton()
490 ->invoke(['formName', 'fields', 'files', 'form', 'errors'],
491 $formName, $fields, $files, $form, $errors, self::$_nullObject, 'civicrm_validateForm');
492 }
493
494 /**
495 * This hook is called after a db write on a custom table.
496 *
497 * @param string $op
498 * The type of operation being performed.
499 * @param string $groupID
500 * The custom group ID.
501 * @param object $entityID
502 * The entityID of the row in the custom table.
503 * @param array $params
504 * The parameters that were sent into the calling function.
505 *
506 * @return null
507 * the return value is ignored
508 */
509 public static function custom($op, $groupID, $entityID, &$params) {
510 return self::singleton()
511 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_custom');
512 }
513
514 /**
515 * This hook is called when composing the ACL where clause to restrict
516 * visibility of contacts to the logged in user
517 *
518 * @param int $type
519 * The type of permission needed.
520 * @param array $tables
521 * (reference ) add the tables that are needed for the select clause.
522 * @param array $whereTables
523 * (reference ) add the tables that are needed for the where clause.
524 * @param int $contactID
525 * The contactID for whom the check is made.
526 * @param string $where
527 * The currrent where clause.
528 *
529 * @return null
530 * the return value is ignored
531 */
532 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
533 return self::singleton()
534 ->invoke(['type', 'tables', 'whereTables', 'contactID', 'where'], $type, $tables, $whereTables, $contactID, $where, self::$_nullObject, 'civicrm_aclWhereClause');
535 }
536
537 /**
538 * This hook is called when composing the ACL where clause to restrict
539 * visibility of contacts to the logged in user
540 *
541 * @param int $type
542 * The type of permission needed.
543 * @param int $contactID
544 * The contactID for whom the check is made.
545 * @param string $tableName
546 * The tableName which is being permissioned.
547 * @param array $allGroups
548 * The set of all the objects for the above table.
549 * @param array $currentGroups
550 * The set of objects that are currently permissioned for this contact.
551 *
552 * @return null
553 * the return value is ignored
554 */
555 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
556 return self::singleton()
557 ->invoke(['type', 'contactID', 'tableName', 'allGroups', 'currentGroups'], $type, $contactID, $tableName, $allGroups, $currentGroups, self::$_nullObject, 'civicrm_aclGroup');
558 }
559
560 /**
561 * @param string|CRM_Core_DAO $entity
562 * @param array $clauses
563 * @return mixed
564 */
565 public static function selectWhereClause($entity, &$clauses) {
566 $entityName = is_object($entity) ? _civicrm_api_get_entity_name_from_dao($entity) : $entity;
567 return self::singleton()->invoke(['entity', 'clauses'], $entityName, $clauses,
568 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
569 'civicrm_selectWhereClause'
570 );
571 }
572
573 /**
574 * This hook is called when building the menu table.
575 *
576 * @param array $files
577 * The current set of files to process.
578 *
579 * @return null
580 * the return value is ignored
581 */
582 public static function xmlMenu(&$files) {
583 return self::singleton()->invoke(['files'], $files,
584 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
585 'civicrm_xmlMenu'
586 );
587 }
588
589 /**
590 * (Experimental) This hook is called when build the menu table.
591 *
592 * @param array $items
593 * List of records to include in menu table.
594 * @return null
595 * the return value is ignored
596 */
597 public static function alterMenu(&$items) {
598 return self::singleton()->invoke(['items'], $items,
599 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
600 'civicrm_alterMenu'
601 );
602 }
603
604 /**
605 * A theme is a set of CSS files which are loaded on CiviCRM pages. To register a new
606 * theme, add it to the $themes array. Use these properties:
607 *
608 * - ext: string (required)
609 * The full name of the extension which defines the theme.
610 * Ex: "org.civicrm.themes.greenwich".
611 * - title: string (required)
612 * Visible title.
613 * - help: string (optional)
614 * Description of the theme's appearance.
615 * - url_callback: mixed (optional)
616 * A function ($themes, $themeKey, $cssExt, $cssFile) which returns the URL(s) for a CSS resource.
617 * Returns either an array of URLs or PASSTHRU.
618 * Ex: \Civi\Core\Themes\Resolvers::simple (default)
619 * Ex: \Civi\Core\Themes\Resolvers::none
620 * - prefix: string (optional)
621 * A prefix within the extension folder to prepend to the file name.
622 * - search_order: array (optional)
623 * A list of themes to search.
624 * Generally, the last theme should be "*fallback*" (Civi\Core\Themes::FALLBACK).
625 * - excludes: array (optional)
626 * A list of files (eg "civicrm:css/bootstrap.css" or "$ext:$file") which should never
627 * be returned (they are excluded from display).
628 *
629 * @param array $themes
630 * List of themes, keyed by name.
631 * @return null
632 * the return value is ignored
633 */
634 public static function themes(&$themes) {
635 return self::singleton()->invoke(1, $themes,
636 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
637 'civicrm_themes'
638 );
639 }
640
641 /**
642 * The activeTheme hook determines which theme is active.
643 *
644 * @param string $theme
645 * The identifier for the theme. Alterable.
646 * Ex: 'greenwich'.
647 * @param array $context
648 * Information about the current page-request. Includes some mix of:
649 * - page: the relative path of the current Civi page (Ex: 'civicrm/dashboard').
650 * - themes: an instance of the Civi\Core\Themes service.
651 * @return null
652 * the return value is ignored
653 */
654 public static function activeTheme(&$theme, $context) {
655 return self::singleton()->invoke(array('theme', 'context'), $theme, $context,
656 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
657 'civicrm_activeTheme'
658 );
659 }
660
661 /**
662 * This hook is called for declaring managed entities via API.
663 *
664 * @param array $entities
665 * List of pending entities. Each entity is an array with keys:
666 * + '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")
667 * + 'name': string, a symbolic name which can be used to track this entity (Note: Each module creates its own namespace)
668 * + 'entity': string, an entity-type supported by the CiviCRM API (Note: this currently must be an entity which supports the 'is_active' property)
669 * + 'params': array, the entity data as supported by the CiviCRM API
670 * + 'update' (v4.5+): string, a policy which describes when to update records
671 * - 'always' (default): always update the managed-entity record; changes in $entities will override any local changes (eg by the site-admin)
672 * - 'never': never update the managed-entity record; changes made locally (eg by the site-admin) will override changes in $entities
673 * + '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)
674 * - 'always' (default): always delete orphaned records
675 * - 'never': never delete orphaned records
676 * - '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.)
677 *
678 * @return null
679 * the return value is ignored
680 */
681 public static function managed(&$entities) {
682 return self::singleton()->invoke(['entities'], $entities,
683 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
684 'civicrm_managed'
685 );
686 }
687
688 /**
689 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
690 *
691 * @param int $contactID
692 * The contactID for whom the dashboard is being rendered.
693 * @param int $contentPlacement
694 * (output parameter) where should the hook content be displayed.
695 * relative to the activity list
696 *
697 * @return string
698 * the html snippet to include in the dashboard
699 */
700 public static function dashboard($contactID, &$contentPlacement = self::DASHBOARD_BELOW) {
701 $retval = self::singleton()->invoke(['contactID', 'contentPlacement'], $contactID, $contentPlacement,
702 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
703 'civicrm_dashboard'
704 );
705
706 /*
707 * Note we need this seemingly unnecessary code because in the event that the implementation
708 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
709 * though we have a default value in this function's declaration above.
710 */
711 if (!isset($contentPlacement)) {
712 $contentPlacement = self::DASHBOARD_BELOW;
713 }
714
715 return $retval;
716 }
717
718 /**
719 * This hook is called before storing recently viewed items.
720 *
721 * @param array $recentArray
722 * An array of recently viewed or processed items, for in place modification.
723 *
724 * @return array
725 */
726 public static function recent(&$recentArray) {
727 return self::singleton()->invoke(['recentArray'], $recentArray,
728 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
729 'civicrm_recent'
730 );
731 }
732
733 /**
734 * Determine how many other records refer to a given record.
735 *
736 * @param CRM_Core_DAO $dao
737 * The item for which we want a reference count.
738 * @param array $refCounts
739 * Each item in the array is an Array with keys:
740 * - name: string, eg "sql:civicrm_email:contact_id"
741 * - type: string, eg "sql"
742 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
743 *
744 * @return mixed
745 * Return is not really intended to be used.
746 */
747 public static function referenceCounts($dao, &$refCounts) {
748 return self::singleton()->invoke(['dao', 'refCounts'], $dao, $refCounts,
749 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
750 'civicrm_referenceCounts'
751 );
752 }
753
754 /**
755 * This hook is called when building the amount structure for a Contribution or Event Page.
756 *
757 * @param int $pageType
758 * Is this a contribution or event page.
759 * @param CRM_Core_Form $form
760 * Reference to the form object.
761 * @param array $amount
762 * The amount structure to be displayed.
763 *
764 * @return null
765 */
766 public static function buildAmount($pageType, &$form, &$amount) {
767 return self::singleton()->invoke(['pageType', 'form', 'amount'], $pageType, $form, $amount, self::$_nullObject,
768 self::$_nullObject, self::$_nullObject, 'civicrm_buildAmount');
769 }
770
771 /**
772 * This hook is called when building the state list for a particular country.
773 *
774 * @param array $countryID
775 * The country id whose states are being selected.
776 * @param $states
777 *
778 * @return null
779 */
780 public static function buildStateProvinceForCountry($countryID, &$states) {
781 return self::singleton()->invoke(['countryID', 'states'], $countryID, $states,
782 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
783 'civicrm_buildStateProvinceForCountry'
784 );
785 }
786
787 /**
788 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
789 *
790 * @param array $tabs
791 * The array of tabs that will be displayed.
792 * @param int $contactID
793 * The contactID for whom the dashboard is being rendered.
794 *
795 * @return null
796 * @deprecated Use tabset() instead.
797 */
798 public static function tabs(&$tabs, $contactID) {
799 return self::singleton()->invoke(['tabs', 'contactID'], $tabs, $contactID,
800 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tabs'
801 );
802 }
803
804 /**
805 * This hook is called when rendering the tabs used for events and potentially
806 * contribution pages, etc.
807 *
808 * @param string $tabsetName
809 * Name of the screen or visual element.
810 * @param array $tabs
811 * Tabs that will be displayed.
812 * @param array $context
813 * Extra data about the screen or context in which the tab is used.
814 *
815 * @return null
816 */
817 public static function tabset($tabsetName, &$tabs, $context) {
818 return self::singleton()->invoke(['tabsetName', 'tabs', 'context'], $tabsetName, $tabs,
819 $context, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tabset'
820 );
821 }
822
823 /**
824 * This hook is called when sending an email / printing labels
825 *
826 * @param array $tokens
827 * The list of tokens that can be used for the contact.
828 *
829 * @return null
830 */
831 public static function tokens(&$tokens) {
832 return self::singleton()->invoke(['tokens'], $tokens,
833 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tokens'
834 );
835 }
836
837 /**
838 * This hook allows modification of the admin panels
839 *
840 * @param array $panels
841 * Associated array of admin panels
842 *
843 * @return mixed
844 */
845 public static function alterAdminPanel(&$panels) {
846 return self::singleton()->invoke(array('panels'), $panels,
847 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
848 'civicrm_alterAdminPanel'
849 );
850 }
851
852 /**
853 * This hook is called when sending an email / printing labels to get the values for all the
854 * tokens returned by the 'tokens' hook
855 *
856 * @param array $details
857 * The array to store the token values indexed by contactIDs (unless it a single).
858 * @param array $contactIDs
859 * An array of contactIDs.
860 * @param int $jobID
861 * The jobID if this is associated with a CiviMail mailing.
862 * @param array $tokens
863 * The list of tokens associated with the content.
864 * @param string $className
865 * The top level className from where the hook is invoked.
866 *
867 * @return null
868 */
869 public static function tokenValues(
870 &$details,
871 $contactIDs,
872 $jobID = NULL,
873 $tokens = [],
874 $className = NULL
875 ) {
876 return self::singleton()
877 ->invoke(['details', 'contactIDs', 'jobID', 'tokens', 'className'], $details, $contactIDs, $jobID, $tokens, $className, self::$_nullObject, 'civicrm_tokenValues');
878 }
879
880 /**
881 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
882 * in a template
883 *
884 * @param object $page
885 * The page that will be rendered.
886 *
887 * @return null
888 */
889 public static function pageRun(&$page) {
890 return self::singleton()->invoke(['page'], $page,
891 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
892 'civicrm_pageRun'
893 );
894 }
895
896 /**
897 * This hook is called after a copy of an object has been made. The current objects are
898 * Event, Contribution Page and UFGroup
899 *
900 * @param string $objectName
901 * Name of the object.
902 * @param object $object
903 * Reference to the copy.
904 *
905 * @return null
906 */
907 public static function copy($objectName, &$object) {
908 return self::singleton()->invoke(['objectName', 'object'], $objectName, $object,
909 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
910 'civicrm_copy'
911 );
912 }
913
914 /**
915 * This hook is called when a contact unsubscribes from a mailing. It allows modules
916 * to override what the contacts are removed from.
917 *
918 * @param string $op
919 * Ignored for now
920 * @param int $mailingId
921 * The id of the mailing to unsub from
922 * @param int $contactId
923 * The id of the contact who is unsubscribing
924 * @param array|int $groups
925 * Groups the contact will be removed from.
926 * @param array|int $baseGroups
927 * Base groups (used in smart mailings) the contact will be removed from.
928 *
929 *
930 * @return mixed
931 */
932 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
933 return self::singleton()
934 ->invoke(['op', 'mailingId', 'contactId', 'groups', 'baseGroups'], $op, $mailingId, $contactId, $groups, $baseGroups, self::$_nullObject, 'civicrm_unsubscribeGroups');
935 }
936
937 /**
938 * This hook is called when CiviCRM needs to edit/display a custom field with options
939 *
940 * @deprecated in favor of hook_civicrm_fieldOptions
941 *
942 * @param int $customFieldID
943 * The custom field ID.
944 * @param array $options
945 * The current set of options for that custom field.
946 * You can add/remove existing options.
947 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
948 * to be careful to not overwrite the array.
949 * Only add/edit/remove the specific field options you intend to affect.
950 * @param bool $detailedFormat
951 * If true, the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
952 * @param array $selectAttributes
953 * Contain select attribute(s) if any.
954 *
955 * @return mixed
956 */
957 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = []) {
958 // Weird: $selectAttributes is inputted but not outputted.
959 return self::singleton()->invoke(['customFieldID', 'options', 'detailedFormat'], $customFieldID, $options, $detailedFormat,
960 self::$_nullObject, self::$_nullObject, self::$_nullObject,
961 'civicrm_customFieldOptions'
962 );
963 }
964
965 /**
966 * Hook for modifying field options
967 *
968 * @param string $entity
969 * @param string $field
970 * @param array $options
971 * @param array $params
972 *
973 * @return mixed
974 */
975 public static function fieldOptions($entity, $field, &$options, $params) {
976 return self::singleton()->invoke(['entity', 'field', 'options', 'params'], $entity, $field, $options, $params,
977 self::$_nullObject, self::$_nullObject,
978 'civicrm_fieldOptions'
979 );
980 }
981
982 /**
983 *
984 * This hook is called to display the list of actions allowed after doing a search.
985 * This allows the module developer to inject additional actions or to remove existing actions.
986 *
987 * @param string $objectType
988 * The object type for this search.
989 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
990 * @param array $tasks
991 * The current set of tasks for that custom field.
992 * You can add/remove existing tasks.
993 * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class
994 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
995 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
996 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
997 * found in CRM/$objectType/Task.php.
998 *
999 * @return mixed
1000 */
1001 public static function searchTasks($objectType, &$tasks) {
1002 return self::singleton()->invoke(['objectType', 'tasks'], $objectType, $tasks,
1003 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1004 'civicrm_searchTasks'
1005 );
1006 }
1007
1008 /**
1009 * @param mixed $form
1010 * @param array $params
1011 *
1012 * @return mixed
1013 */
1014 public static function eventDiscount(&$form, &$params) {
1015 return self::singleton()->invoke(['form', 'params'], $form, $params,
1016 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1017 'civicrm_eventDiscount'
1018 );
1019 }
1020
1021 /**
1022 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
1023 *
1024 * @param mixed $form
1025 * The form object for which groups / mailings being displayed
1026 * @param array $groups
1027 * The list of groups being included / excluded
1028 * @param array $mailings
1029 * The list of mailings being included / excluded
1030 *
1031 * @return mixed
1032 */
1033 public static function mailingGroups(&$form, &$groups, &$mailings) {
1034 return self::singleton()->invoke(['form', 'groups', 'mailings'], $form, $groups, $mailings,
1035 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1036 'civicrm_mailingGroups'
1037 );
1038 }
1039
1040 /**
1041 * (Experimental) Modify the list of template-types used for CiviMail composition.
1042 *
1043 * @param array $types
1044 * Sequentially indexed list of template types. Each type specifies:
1045 * - name: string
1046 * - editorUrl: string, Angular template URL
1047 * - weight: int, priority when picking a default value for new mailings
1048 * @return mixed
1049 */
1050 public static function mailingTemplateTypes(&$types) {
1051 return self::singleton()->invoke(['types'], $types, self::$_nullObject, self::$_nullObject,
1052 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1053 'civicrm_mailingTemplateTypes'
1054 );
1055 }
1056
1057 /**
1058 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
1059 * (new or renewal).
1060 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
1061 * You can use it to alter the membership types when first loaded, or after submission
1062 * (for example if you want to gather data in the form and use it to alter the fees).
1063 *
1064 * @param mixed $form
1065 * The form object that is presenting the page
1066 * @param array $membershipTypes
1067 * The array of membership types and their amount
1068 *
1069 * @return mixed
1070 */
1071 public static function membershipTypeValues(&$form, &$membershipTypes) {
1072 return self::singleton()->invoke(['form', 'membershipTypes'], $form, $membershipTypes,
1073 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1074 'civicrm_membershipTypeValues'
1075 );
1076 }
1077
1078 /**
1079 * This hook is called when rendering the contact summary.
1080 *
1081 * @param int $contactID
1082 * The contactID for whom the summary is being rendered
1083 * @param mixed $content
1084 * @param int $contentPlacement
1085 * Specifies where the hook content should be displayed relative to the
1086 * existing content
1087 *
1088 * @return string
1089 * The html snippet to include in the contact summary
1090 */
1091 public static function summary($contactID, &$content, &$contentPlacement = self::SUMMARY_BELOW) {
1092 return self::singleton()->invoke(['contactID', 'content', 'contentPlacement'], $contactID, $content, $contentPlacement,
1093 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1094 'civicrm_summary'
1095 );
1096 }
1097
1098 /**
1099 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
1100 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
1101 * If you want to limit the contacts returned to a specific group, or some other criteria
1102 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
1103 * The hook is called when the query is executed to get the list of contacts to display.
1104 *
1105 * @param mixed $query
1106 * - the query that will be executed (input and output parameter);.
1107 * It's important to realize that the ACL clause is built prior to this hook being fired,
1108 * so your query will ignore any ACL rules that may be defined.
1109 * Your query must return two columns:
1110 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
1111 * the contact IDs
1112 * @param string $queryText
1113 * The name string to execute the query against (this is the value being typed in by the user).
1114 * @param string $context
1115 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
1116 * @param int $id
1117 * The id of the object for which the call is being made.
1118 * For custom fields, it will be the custom field id
1119 *
1120 * @return mixed
1121 */
1122 public static function contactListQuery(&$query, $queryText, $context, $id) {
1123 return self::singleton()->invoke(['query', 'queryText', 'context', 'id'], $query, $queryText, $context, $id,
1124 self::$_nullObject, self::$_nullObject,
1125 'civicrm_contactListQuery'
1126 );
1127 }
1128
1129 /**
1130 * Hook definition for altering payment parameters before talking to a payment processor back end.
1131 *
1132 * Definition will look like this:
1133 *
1134 * function hook_civicrm_alterPaymentProcessorParams(
1135 * $paymentObj,
1136 * &$rawParams,
1137 * &$cookedParams
1138 * );
1139 *
1140 * @param CRM_Core_Payment $paymentObj
1141 * Instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
1142 * See discussion in CRM-16224 as to whether $paymentObj should be passed by reference.
1143 * @param array &$rawParams
1144 * array of params as passed to to the processor
1145 * @param array &$cookedParams
1146 * params after the processor code has translated them into its own key/value pairs
1147 *
1148 * @return mixed
1149 * This return is not really intended to be used.
1150 */
1151 public static function alterPaymentProcessorParams(
1152 $paymentObj,
1153 &$rawParams,
1154 &$cookedParams
1155 ) {
1156 return self::singleton()->invoke(['paymentObj', 'rawParams', 'cookedParams'], $paymentObj, $rawParams, $cookedParams,
1157 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1158 'civicrm_alterPaymentProcessorParams'
1159 );
1160 }
1161
1162 /**
1163 * This hook is called when an email is about to be sent by CiviCRM.
1164 *
1165 * @param array $params
1166 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
1167 * returnPath, replyTo, headers, attachments (array)
1168 * @param string $context
1169 * The context in which the hook is being invoked, eg 'civimail'.
1170 *
1171 * @return mixed
1172 */
1173 public static function alterMailParams(&$params, $context = NULL) {
1174 return self::singleton()->invoke(['params', 'context'], $params, $context,
1175 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1176 'civicrm_alterMailParams'
1177 );
1178 }
1179
1180 /**
1181 * This hook is called when membership status is being calculated.
1182 *
1183 * @param array $membershipStatus
1184 * Membership status details as determined - alter if required.
1185 * @param array $arguments
1186 * Arguments passed in to calculate date.
1187 * - 'start_date'
1188 * - 'end_date'
1189 * - 'status_date'
1190 * - 'join_date'
1191 * - 'exclude_is_admin'
1192 * - 'membership_type_id'
1193 * @param array $membership
1194 * Membership details from the calling function.
1195 *
1196 * @return mixed
1197 */
1198 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
1199 return self::singleton()->invoke(['membershipStatus', 'arguments', 'membership'], $membershipStatus, $arguments,
1200 $membership, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1201 'civicrm_alterCalculatedMembershipStatus'
1202 );
1203 }
1204
1205 /**
1206 * This hook is called after getting the content of the mail and before tokenizing it.
1207 *
1208 * @param array $content
1209 * Array fields include: html, text, subject
1210 *
1211 * @return mixed
1212 */
1213 public static function alterMailContent(&$content) {
1214 return self::singleton()->invoke(['content'], $content,
1215 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1216 'civicrm_alterMailContent'
1217 );
1218 }
1219
1220 /**
1221 * This hook is called when rendering the Manage Case screen.
1222 *
1223 * @param int $caseID
1224 * The case ID.
1225 *
1226 * @return array
1227 * Array of data to be displayed, where the key is a unique id to be used for styling (div id's)
1228 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
1229 */
1230 public static function caseSummary($caseID) {
1231 return self::singleton()->invoke(['caseID'], $caseID,
1232 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1233 'civicrm_caseSummary'
1234 );
1235 }
1236
1237 /**
1238 * This hook is called when locating CiviCase types.
1239 *
1240 * @param array $caseTypes
1241 *
1242 * @return mixed
1243 */
1244 public static function caseTypes(&$caseTypes) {
1245 return self::singleton()
1246 ->invoke(['caseTypes'], $caseTypes, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_caseTypes');
1247 }
1248
1249 /**
1250 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1251 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
1252 *
1253 * @param CRM_Core_Config|array $config
1254 * The config object
1255 *
1256 * @return mixed
1257 */
1258 public static function config(&$config) {
1259 return self::singleton()->invoke(['config'], $config,
1260 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1261 'civicrm_config'
1262 );
1263 }
1264
1265 /**
1266 * This hooks allows to change option values.
1267 *
1268 * @deprecated in favor of hook_civicrm_fieldOptions
1269 *
1270 * @param array $options
1271 * Associated array of option values / id
1272 * @param string $groupName
1273 * Option group name
1274 *
1275 * @return mixed
1276 */
1277 public static function optionValues(&$options, $groupName) {
1278 return self::singleton()->invoke(['options', 'groupName'], $options, $groupName,
1279 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1280 'civicrm_optionValues'
1281 );
1282 }
1283
1284 /**
1285 * This hook allows modification of the navigation menu.
1286 *
1287 * @param array $params
1288 * Associated array of navigation menu entry to Modify/Add
1289 *
1290 * @return mixed
1291 */
1292 public static function navigationMenu(&$params) {
1293 return self::singleton()->invoke(['params'], $params,
1294 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1295 'civicrm_navigationMenu'
1296 );
1297 }
1298
1299 /**
1300 * This hook allows modification of the data used to perform merging of duplicates.
1301 *
1302 * @param string $type
1303 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1304 * @param array $data
1305 * The data, as described in $type.
1306 * @param int $mainId
1307 * Contact_id of the contact that survives the merge.
1308 * @param int $otherId
1309 * Contact_id of the contact that will be absorbed and deleted.
1310 * @param array $tables
1311 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
1312 *
1313 * @return mixed
1314 */
1315 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
1316 return self::singleton()->invoke(['type', 'data', 'mainId', 'otherId', 'tables'], $type, $data, $mainId, $otherId, $tables, self::$_nullObject, 'civicrm_merge');
1317 }
1318
1319 /**
1320 * This hook allows modification of the data calculated for merging locations.
1321 *
1322 * @param array $blocksDAO
1323 * Array of location DAO to be saved. These are arrays in 2 keys 'update' & 'delete'.
1324 * @param int $mainId
1325 * Contact_id of the contact that survives the merge.
1326 * @param int $otherId
1327 * Contact_id of the contact that will be absorbed and deleted.
1328 * @param array $migrationInfo
1329 * Calculated migration info, informational only.
1330 *
1331 * @return mixed
1332 */
1333 public static function alterLocationMergeData(&$blocksDAO, $mainId, $otherId, $migrationInfo) {
1334 return self::singleton()->invoke(['blocksDAO', 'mainId', 'otherId', 'migrationInfo'], $blocksDAO, $mainId, $otherId, $migrationInfo, self::$_nullObject, self::$_nullObject, 'civicrm_alterLocationMergeData');
1335 }
1336
1337 /**
1338 * This hook provides a way to override the default privacy behavior for notes.
1339 *
1340 * @param array &$noteValues
1341 * Associative array of values for this note
1342 *
1343 * @return mixed
1344 */
1345 public static function notePrivacy(&$noteValues) {
1346 return self::singleton()->invoke(['noteValues'], $noteValues,
1347 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1348 'civicrm_notePrivacy'
1349 );
1350 }
1351
1352 /**
1353 * This hook is called before record is exported as CSV.
1354 *
1355 * @param string $exportTempTable
1356 * Name of the temporary export table used during export.
1357 * @param array $headerRows
1358 * Header rows for output.
1359 * @param array $sqlColumns
1360 * SQL columns.
1361 * @param int $exportMode
1362 * Export mode ( contact, contribution, etc...).
1363 * @param string $componentTable
1364 * Name of temporary table
1365 * @param array $ids
1366 * Array of object's ids
1367 *
1368 * @return mixed
1369 */
1370 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids) {
1371 return self::singleton()->invoke(['exportTempTable', 'headerRows', 'sqlColumns', 'exportMode', 'componentTable', 'ids'],
1372 $exportTempTable, $headerRows, $sqlColumns,
1373 $exportMode, $componentTable, $ids,
1374 'civicrm_export'
1375 );
1376 }
1377
1378 /**
1379 * This hook allows modification of the queries constructed from dupe rules.
1380 *
1381 * @param string $obj
1382 * Object of rulegroup class.
1383 * @param string $type
1384 * Type of queries e.g table / threshold.
1385 * @param array $query
1386 * Set of queries.
1387 *
1388 * @return mixed
1389 */
1390 public static function dupeQuery($obj, $type, &$query) {
1391 return self::singleton()->invoke(['obj', 'type', 'query'], $obj, $type, $query,
1392 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1393 'civicrm_dupeQuery'
1394 );
1395 }
1396
1397 /**
1398 * Check for duplicate contacts
1399 *
1400 * @param array $dedupeParams
1401 * Array of params for finding duplicates: [
1402 * '{parameters returned by CRM_Dedupe_Finder::formatParams}
1403 * 'check_permission' => TRUE/FALSE;
1404 * 'contact_type' => $contactType;
1405 * 'rule' = $rule;
1406 * 'rule_group_id' => $ruleGroupID;
1407 * 'excludedContactIDs' => $excludedContactIDs;
1408 * @param array $dedupeResults
1409 * Array of results ['handled' => TRUE/FALSE, 'ids' => array of IDs of duplicate contacts]
1410 * @param array $contextParams
1411 * The context if relevant, eg. ['event_id' => X]
1412 *
1413 * @return mixed
1414 */
1415 public static function findDuplicates($dedupeParams, &$dedupeResults, $contextParams) {
1416 return self::singleton()
1417 ->invoke(['dedupeParams', 'dedupeResults', 'contextParams'], $dedupeParams, $dedupeResults, $contextParams, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_findDuplicates');
1418 }
1419
1420 /**
1421 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1422 *
1423 * @param string $type
1424 * Type of mail processed: 'activity' OR 'mailing'.
1425 * @param array &$params the params that were sent to the CiviCRM API function
1426 * @param object $mail
1427 * The mail object which is an ezcMail class.
1428 * @param array &$result the result returned by the api call
1429 * @param string $action
1430 * (optional ) the requested action to be performed if the types was 'mailing'.
1431 *
1432 * @return mixed
1433 */
1434 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
1435 return self::singleton()
1436 ->invoke(['type', 'params', 'mail', 'result', 'action'], $type, $params, $mail, $result, $action, self::$_nullObject, 'civicrm_emailProcessor');
1437 }
1438
1439 /**
1440 * This hook is called after a row has been processed and the
1441 * record (and associated records imported
1442 *
1443 * @param string $object
1444 * Object being imported (for now Contact only, later Contribution, Activity,.
1445 * Participant and Member)
1446 * @param string $usage
1447 * Hook usage/location (for now process only, later mapping and others).
1448 * @param string $objectRef
1449 * Import record object.
1450 * @param array $params
1451 * Array with various key values: currently.
1452 * contactID - contact id
1453 * importID - row id in temp table
1454 * importTempTable - name of tempTable
1455 * fieldHeaders - field headers
1456 * fields - import fields
1457 *
1458 * @return mixed
1459 */
1460 public static function import($object, $usage, &$objectRef, &$params) {
1461 return self::singleton()->invoke(['object', 'usage', 'objectRef', 'params'], $object, $usage, $objectRef, $params,
1462 self::$_nullObject, self::$_nullObject,
1463 'civicrm_import'
1464 );
1465 }
1466
1467 /**
1468 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
1469 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
1470 *
1471 * @param string $entity
1472 * The API entity (like contact).
1473 * @param string $action
1474 * The API action (like get).
1475 * @param array &$params the API parameters
1476 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
1477 *
1478 * @return mixed
1479 */
1480 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
1481 return self::singleton()->invoke(['entity', 'action', 'params', 'permissions'], $entity, $action, $params, $permissions,
1482 self::$_nullObject, self::$_nullObject,
1483 'civicrm_alterAPIPermissions'
1484 );
1485 }
1486
1487 /**
1488 * @param CRM_Core_DAO $dao
1489 *
1490 * @return mixed
1491 */
1492 public static function postSave(&$dao) {
1493 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1494 return self::singleton()->invoke(['dao'], $dao,
1495 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1496 $hookName
1497 );
1498 }
1499
1500 /**
1501 * This hook allows user to customize context menu Actions on contact summary page.
1502 *
1503 * @param array $actions
1504 * Array of all Actions in contextmenu.
1505 * @param int $contactID
1506 * ContactID for the summary page.
1507 *
1508 * @return mixed
1509 */
1510 public static function summaryActions(&$actions, $contactID = NULL) {
1511 return self::singleton()->invoke(['actions', 'contactID'], $actions, $contactID,
1512 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1513 'civicrm_summaryActions'
1514 );
1515 }
1516
1517 /**
1518 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1519 * This enables us hook implementors to modify both the headers and the rows
1520 *
1521 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1522 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1523 *
1524 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1525 * you want displayed. This is a hackish, but avoids template modification.
1526 *
1527 * @param string $objectName
1528 * The component name that we are doing the search.
1529 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
1530 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1531 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
1532 * @param array $selector
1533 * the selector object. Allows you access to the context of the search
1534 *
1535 * @return mixed
1536 * modify the header and values object to pass the data you need
1537 */
1538 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
1539 return self::singleton()->invoke(['objectName', 'headers', 'rows', 'selector'], $objectName, $headers, $rows, $selector,
1540 self::$_nullObject, self::$_nullObject,
1541 'civicrm_searchColumns'
1542 );
1543 }
1544
1545 /**
1546 * This hook is called when uf groups are being built for a module.
1547 *
1548 * @param string $moduleName
1549 * Module name.
1550 * @param array $ufGroups
1551 * Array of ufgroups for a module.
1552 *
1553 * @return null
1554 */
1555 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
1556 return self::singleton()->invoke(['moduleName', 'ufGroups'], $moduleName, $ufGroups,
1557 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1558 'civicrm_buildUFGroupsForModule'
1559 );
1560 }
1561
1562 /**
1563 * This hook is called when we are determining the contactID for a specific
1564 * email address
1565 *
1566 * @param string $email
1567 * The email address.
1568 * @param int $contactID
1569 * The contactID that matches this email address, IF it exists.
1570 * @param array $result
1571 * (reference) has two fields.
1572 * contactID - the new (or same) contactID
1573 * action - 3 possible values:
1574 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1575 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1576 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
1577 *
1578 * @return null
1579 */
1580 public static function emailProcessorContact($email, $contactID, &$result) {
1581 return self::singleton()->invoke(['email', 'contactID', 'result'], $email, $contactID, $result,
1582 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1583 'civicrm_emailProcessorContact'
1584 );
1585 }
1586
1587 /**
1588 * Hook definition for altering the generation of Mailing Labels.
1589 *
1590 * @param array $args
1591 * An array of the args in the order defined for the tcpdf multiCell api call.
1592 * with the variable names below converted into string keys (ie $w become 'w'
1593 * as the first key for $args)
1594 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1595 * float $h Cell minimum height. The cell extends automatically if needed.
1596 * string $txt String to print
1597 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1598 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1599 * a string containing some or all of the following characters (in any order):
1600 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1601 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1602 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1603 * (default value when $ishtml=false)</li></ul>
1604 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1605 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1606 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1607 * float $x x position in user units
1608 * float $y y position in user units
1609 * boolean $reseth if true reset the last cell height (default true).
1610 * int $stretch stretch character mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
1611 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1612 * necessary</li><li>4 = forced character spacing</li></ul>
1613 * boolean $ishtml set to true if $txt is HTML content (default = false).
1614 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1615 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1616 * or 0 for disable this feature. This feature works only when $ishtml=false.
1617 *
1618 * @return mixed
1619 */
1620 public static function alterMailingLabelParams(&$args) {
1621 return self::singleton()->invoke(['args'], $args,
1622 self::$_nullObject, self::$_nullObject,
1623 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1624 'civicrm_alterMailingLabelParams'
1625 );
1626 }
1627
1628 /**
1629 * This hooks allows alteration of generated page content.
1630 *
1631 * @param $content
1632 * Previously generated content.
1633 * @param $context
1634 * Context of content - page or form.
1635 * @param $tplName
1636 * The file name of the tpl.
1637 * @param $object
1638 * A reference to the page or form object.
1639 *
1640 * @return mixed
1641 */
1642 public static function alterContent(&$content, $context, $tplName, &$object) {
1643 return self::singleton()->invoke(['content', 'context', 'tplName', 'object'], $content, $context, $tplName, $object,
1644 self::$_nullObject, self::$_nullObject,
1645 'civicrm_alterContent'
1646 );
1647 }
1648
1649 /**
1650 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1651 * altercontent hook as the content has already been rendered through the tpl at that point
1652 *
1653 * @param $formName
1654 * Previously generated content.
1655 * @param $form
1656 * Reference to the form object.
1657 * @param $context
1658 * Context of content - page or form.
1659 * @param $tplName
1660 * Reference the file name of the tpl.
1661 *
1662 * @return mixed
1663 */
1664 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
1665 return self::singleton()->invoke(['formName', 'form', 'context', 'tplName'], $formName, $form, $context, $tplName,
1666 self::$_nullObject, self::$_nullObject,
1667 'civicrm_alterTemplateFile'
1668 );
1669 }
1670
1671 /**
1672 * This hook collects the trigger definition from all components.
1673 *
1674 * @param $info
1675 * @param string $tableName
1676 * (optional) the name of the table that we are interested in only.
1677 *
1678 * @internal param \reference $triggerInfo to an array of trigger information
1679 * each element has 4 fields:
1680 * table - array of tableName
1681 * when - BEFORE or AFTER
1682 * event - array of eventName - INSERT OR UPDATE OR DELETE
1683 * sql - array of statements optionally terminated with a ;
1684 * a statement can use the tokes {tableName} and {eventName}
1685 * to do token replacement with the table / event. This allows
1686 * templatizing logging and other hooks
1687 * @return mixed
1688 */
1689 public static function triggerInfo(&$info, $tableName = NULL) {
1690 return self::singleton()->invoke(['info', 'tableName'], $info, $tableName,
1691 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1692 self::$_nullObject,
1693 'civicrm_triggerInfo'
1694 );
1695 }
1696
1697 /**
1698 * This hook allows changes to the spec of which tables to log.
1699 *
1700 * @param array $logTableSpec
1701 *
1702 * @return mixed
1703 */
1704 public static function alterLogTables(&$logTableSpec) {
1705 return self::singleton()->invoke(['logTableSpec'], $logTableSpec, $_nullObject,
1706 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1707 self::$_nullObject,
1708 'civicrm_alterLogTables'
1709 );
1710 }
1711
1712 /**
1713 * This hook is called when a module-extension is installed.
1714 * Each module will receive hook_civicrm_install during its own installation (but not during the
1715 * installation of unrelated modules).
1716 */
1717 public static function install() {
1718 return self::singleton()->invoke(0, self::$_nullObject,
1719 self::$_nullObject, self::$_nullObject,
1720 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1721 'civicrm_install'
1722 );
1723 }
1724
1725 /**
1726 * This hook is called when a module-extension is uninstalled.
1727 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1728 * uninstallation of unrelated modules).
1729 */
1730 public static function uninstall() {
1731 return self::singleton()->invoke(0, self::$_nullObject,
1732 self::$_nullObject, self::$_nullObject,
1733 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1734 'civicrm_uninstall'
1735 );
1736 }
1737
1738 /**
1739 * This hook is called when a module-extension is re-enabled.
1740 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1741 * re-enablement of unrelated modules).
1742 */
1743 public static function enable() {
1744 return self::singleton()->invoke(0, self::$_nullObject,
1745 self::$_nullObject, self::$_nullObject,
1746 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1747 'civicrm_enable'
1748 );
1749 }
1750
1751 /**
1752 * This hook is called when a module-extension is disabled.
1753 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1754 * disablement of unrelated modules).
1755 */
1756 public static function disable() {
1757 return self::singleton()->invoke(0, self::$_nullObject,
1758 self::$_nullObject, self::$_nullObject,
1759 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1760 'civicrm_disable'
1761 );
1762 }
1763
1764 /**
1765 * Alter redirect.
1766 *
1767 * This hook is called when the browser is being re-directed and allows the url
1768 * to be altered.
1769 *
1770 * @param \Psr\Http\Message\UriInterface $url
1771 * @param array $context
1772 * Additional information about context
1773 * - output - if this is 'json' then it will return json.
1774 *
1775 * @return null
1776 * the return value is ignored
1777 */
1778 public static function alterRedirect(&$url, &$context) {
1779 return self::singleton()->invoke(['url', 'context'], $url,
1780 $context, self::$_nullObject,
1781 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1782 'civicrm_alterRedirect'
1783 );
1784 }
1785
1786 /**
1787 * @param $varType
1788 * @param $var
1789 * @param $object
1790 *
1791 * @return mixed
1792 */
1793 public static function alterReportVar($varType, &$var, &$object) {
1794 return self::singleton()->invoke(['varType', 'var', 'object'], $varType, $var, $object,
1795 self::$_nullObject,
1796 self::$_nullObject, self::$_nullObject,
1797 'civicrm_alterReportVar'
1798 );
1799 }
1800
1801 /**
1802 * This hook is called to drive database upgrades for extension-modules.
1803 *
1804 * @param string $op
1805 * The type of operation being performed; 'check' or 'enqueue'.
1806 * @param CRM_Queue_Queue $queue
1807 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
1808 *
1809 * @return bool|null
1810 * NULL, if $op is 'enqueue'.
1811 * TRUE, if $op is 'check' and upgrades are pending.
1812 * FALSE, if $op is 'check' and upgrades are not pending.
1813 */
1814 public static function upgrade($op, CRM_Queue_Queue $queue = NULL) {
1815 return self::singleton()->invoke(['op', 'queue'], $op, $queue,
1816 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1817 self::$_nullObject,
1818 'civicrm_upgrade'
1819 );
1820 }
1821
1822 /**
1823 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1824 *
1825 * @param array $params
1826 * The mailing parameters. Array fields include: groupName, from, toName,
1827 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1828 * attachments (array)
1829 *
1830 * @return mixed
1831 */
1832 public static function postEmailSend(&$params) {
1833 return self::singleton()->invoke(['params'], $params,
1834 self::$_nullObject, self::$_nullObject,
1835 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1836 'civicrm_postEmailSend'
1837 );
1838 }
1839
1840 /**
1841 * This hook is called when a CiviMail mailing has completed
1842 *
1843 * @param int $mailingId
1844 * Mailing ID
1845 *
1846 * @return mixed
1847 */
1848 public static function postMailing($mailingId) {
1849 return self::singleton()->invoke(['mailingId'], $mailingId,
1850 self::$_nullObject, self::$_nullObject,
1851 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1852 'civicrm_postMailing'
1853 );
1854 }
1855
1856 /**
1857 * This hook is called when Settings specifications are loaded.
1858 *
1859 * @param array $settingsFolders
1860 * List of paths from which to derive metadata
1861 *
1862 * @return mixed
1863 */
1864 public static function alterSettingsFolders(&$settingsFolders) {
1865 return self::singleton()->invoke(['settingsFolders'], $settingsFolders,
1866 self::$_nullObject, self::$_nullObject,
1867 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1868 'civicrm_alterSettingsFolders'
1869 );
1870 }
1871
1872 /**
1873 * This hook is called when Settings have been loaded from the xml
1874 * It is an opportunity for hooks to alter the data
1875 *
1876 * @param array $settingsMetaData
1877 * Settings Metadata.
1878 * @param int $domainID
1879 * @param mixed $profile
1880 *
1881 * @return mixed
1882 */
1883 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
1884 return self::singleton()->invoke(['settingsMetaData', 'domainID', 'profile'], $settingsMetaData,
1885 $domainID, $profile,
1886 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1887 'civicrm_alterSettingsMetaData'
1888 );
1889 }
1890
1891 /**
1892 * This hook is called before running an api call.
1893 *
1894 * @param API_Wrapper[] $wrappers
1895 * (see CRM_Utils_API_ReloadOption as an example)
1896 * @param mixed $apiRequest
1897 *
1898 * @return null
1899 * The return value is ignored
1900 */
1901 public static function apiWrappers(&$wrappers, $apiRequest) {
1902 return self::singleton()
1903 ->invoke(['wrappers', 'apiRequest'], $wrappers, $apiRequest, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1904 self::$_nullObject, 'civicrm_apiWrappers'
1905 );
1906 }
1907
1908 /**
1909 * This hook is called before running pending cron jobs.
1910 *
1911 * @param CRM_Core_JobManager $jobManager
1912 *
1913 * @return null
1914 * The return value is ignored.
1915 */
1916 public static function cron($jobManager) {
1917 return self::singleton()->invoke(['jobManager'],
1918 $jobManager, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1919 'civicrm_cron'
1920 );
1921 }
1922
1923 /**
1924 * This hook is called when loading CMS permissions; use this hook to modify
1925 * the array of system permissions for CiviCRM.
1926 *
1927 * @param array $permissions
1928 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1929 * the format of this array.
1930 *
1931 * @return null
1932 * The return value is ignored
1933 */
1934 public static function permission(&$permissions) {
1935 return self::singleton()->invoke(['permissions'], $permissions,
1936 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1937 'civicrm_permission'
1938 );
1939 }
1940
1941 /**
1942 * This hook is called when checking permissions; use this hook to dynamically
1943 * escalate user permissions in certain use cases (cf. CRM-19256).
1944 *
1945 * @param string $permission
1946 * The name of an atomic permission, ie. 'access deleted contacts'
1947 * @param bool $granted
1948 * Whether this permission is currently granted. The hook can change this value.
1949 * @param int $contactId
1950 * Contact whose permissions we are checking (if null, assume current user).
1951 *
1952 * @return null
1953 * The return value is ignored
1954 */
1955 public static function permission_check($permission, &$granted, $contactId) {
1956 return self::singleton()->invoke(['permission', 'granted', 'contactId'], $permission, $granted, $contactId,
1957 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1958 'civicrm_permission_check'
1959 );
1960 }
1961
1962 /**
1963 * @param CRM_Core_Exception $exception
1964 * @param mixed $request
1965 * Reserved for future use.
1966 */
1967 public static function unhandledException($exception, $request = NULL) {
1968 $event = new \Civi\Core\Event\UnhandledExceptionEvent($exception, self::$_nullObject);
1969 \Civi::dispatcher()->dispatch('hook_civicrm_unhandled_exception', $event);
1970 }
1971
1972 /**
1973 * This hook is called for declaring managed entities via API.
1974 *
1975 * Note: This is a pre-boot hook. It will dispatch via the extension/module
1976 * subsystem but *not* the Symfony EventDispatcher.
1977 *
1978 * @param array[] $entityTypes
1979 * List of entity types; each entity-type is an array with keys:
1980 * - name: string, a unique short name (e.g. "ReportInstance")
1981 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
1982 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
1983 * - fields_callback: array, list of callables which manipulates field list
1984 * - links_callback: array, list of callables which manipulates fk list
1985 *
1986 * @return null
1987 * The return value is ignored
1988 */
1989 public static function entityTypes(&$entityTypes) {
1990 return self::singleton()->invoke(['entityTypes'], $entityTypes, self::$_nullObject, self::$_nullObject,
1991 self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_entityTypes'
1992 );
1993 }
1994
1995 /**
1996 * Build a description of available hooks.
1997 *
1998 * @param \Civi\Core\CiviEventInspector $inspector
1999 */
2000 public static function eventDefs($inspector) {
2001 $event = \Civi\Core\Event\GenericHookEvent::create([
2002 'inspector' => $inspector,
2003 ]);
2004 Civi::dispatcher()->dispatch('hook_civicrm_eventDefs', $event);
2005 }
2006
2007 /**
2008 * This hook is called while preparing a profile form.
2009 *
2010 * @param string $profileName
2011 * @return mixed
2012 */
2013 public static function buildProfile($profileName) {
2014 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2015 self::$_nullObject, self::$_nullObject, 'civicrm_buildProfile');
2016 }
2017
2018 /**
2019 * This hook is called while validating a profile form submission.
2020 *
2021 * @param string $profileName
2022 * @return mixed
2023 */
2024 public static function validateProfile($profileName) {
2025 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2026 self::$_nullObject, self::$_nullObject, 'civicrm_validateProfile');
2027 }
2028
2029 /**
2030 * This hook is called processing a valid profile form submission.
2031 *
2032 * @param string $profileName
2033 * @return mixed
2034 */
2035 public static function processProfile($profileName) {
2036 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2037 self::$_nullObject, self::$_nullObject, 'civicrm_processProfile');
2038 }
2039
2040 /**
2041 * This hook is called while preparing a read-only profile screen
2042 *
2043 * @param string $profileName
2044 * @return mixed
2045 */
2046 public static function viewProfile($profileName) {
2047 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2048 self::$_nullObject, self::$_nullObject, 'civicrm_viewProfile');
2049 }
2050
2051 /**
2052 * This hook is called while preparing a list of contacts (based on a profile)
2053 *
2054 * @param string $profileName
2055 * @return mixed
2056 */
2057 public static function searchProfile($profileName) {
2058 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2059 self::$_nullObject, self::$_nullObject, 'civicrm_searchProfile');
2060 }
2061
2062 /**
2063 * This hook is invoked when building a CiviCRM name badge.
2064 *
2065 * @param string $labelName
2066 * String referencing name of badge format.
2067 * @param object $label
2068 * Reference to the label object.
2069 * @param array $format
2070 * Array of format data.
2071 * @param array $participant
2072 * Array of participant values.
2073 *
2074 * @return null
2075 * the return value is ignored
2076 */
2077 public static function alterBadge($labelName, &$label, &$format, &$participant) {
2078 return self::singleton()
2079 ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self::$_nullObject, self::$_nullObject, 'civicrm_alterBadge');
2080 }
2081
2082 /**
2083 * This hook is called before encoding data in barcode.
2084 *
2085 * @param array $data
2086 * Associated array of values available for encoding.
2087 * @param string $type
2088 * Type of barcode, classic barcode or QRcode.
2089 * @param string $context
2090 * Where this hooks is invoked.
2091 *
2092 * @return mixed
2093 */
2094 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
2095 return self::singleton()->invoke(['data', 'type', 'context'], $data, $type, $context, self::$_nullObject,
2096 self::$_nullObject, self::$_nullObject, 'civicrm_alterBarcode');
2097 }
2098
2099 /**
2100 * Modify or replace the Mailer object used for outgoing mail.
2101 *
2102 * @param object $mailer
2103 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2104 * @param string $driver
2105 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2106 * @param array $params
2107 * The default mailer config options
2108 *
2109 * @return mixed
2110 * @see Mail::factory
2111 */
2112 public static function alterMailer(&$mailer, $driver, $params) {
2113 return self::singleton()
2114 ->invoke(['mailer', 'driver', 'params'], $mailer, $driver, $params, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_alterMailer');
2115 }
2116
2117 /**
2118 * Deprecated: Misnamed version of alterMailer(). Remove post-4.7.x.
2119 * Modify or replace the Mailer object used for outgoing mail.
2120 *
2121 * @param object $mailer
2122 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2123 * @param string $driver
2124 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2125 * @param array $params
2126 * The default mailer config options
2127 *
2128 * @return mixed
2129 * @see Mail::factory
2130 * @deprecated
2131 */
2132 public static function alterMail(&$mailer, $driver, $params) {
2133 // This has been deprecated on the premise it MIGHT be called externally for a long time.
2134 // We don't have a clear policy on how much we support external extensions calling internal
2135 // hooks (ie. in general we say 'don't call internal functions', but some hooks like pre hooks
2136 // are expected to be called externally.
2137 // It's really really unlikely anyone uses this - but let's add deprecations for a couple
2138 // of releases first.
2139 CRM_Core_Error::deprecatedFunctionWarning('CRM_Utils_Hook::alterMailer');
2140 return CRM_Utils_Hook::alterMailer($mailer, $driver, $params);
2141 }
2142
2143 /**
2144 * This hook is called while building the core search query,
2145 * so hook implementers can provide their own query objects which alters/extends core search.
2146 *
2147 * @param array $queryObjects
2148 * @param string $type
2149 *
2150 * @return mixed
2151 */
2152 public static function queryObjects(&$queryObjects, $type = 'Contact') {
2153 return self::singleton()
2154 ->invoke(['queryObjects', 'type'], $queryObjects, $type, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_queryObjects');
2155 }
2156
2157 /**
2158 * This hook is called while viewing contact dashboard.
2159 *
2160 * @param array $availableDashlets
2161 * List of dashlets; each is formatted per api/v3/Dashboard
2162 * @param array $defaultDashlets
2163 * List of dashlets; each is formatted per api/v3/DashboardContact
2164 *
2165 * @return mixed
2166 */
2167 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
2168 return self::singleton()
2169 ->invoke(['availableDashlets', 'defaultDashlets'], $availableDashlets, $defaultDashlets, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_dashboard_defaults');
2170 }
2171
2172 /**
2173 * This hook is called before a case merge (or a case reassign)
2174 *
2175 * @param int $mainContactId
2176 * @param int $mainCaseId
2177 * @param int $otherContactId
2178 * @param int $otherCaseId
2179 * @param bool $changeClient
2180 *
2181 * @return mixed
2182 */
2183 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2184 return self::singleton()
2185 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_pre_case_merge');
2186 }
2187
2188 /**
2189 * This hook is called after a case merge (or a case reassign)
2190 *
2191 * @param int $mainContactId
2192 * @param int $mainCaseId
2193 * @param int $otherContactId
2194 * @param int $otherCaseId
2195 * @param bool $changeClient
2196 *
2197 * @return mixed
2198 */
2199 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2200 return self::singleton()
2201 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_post_case_merge');
2202 }
2203
2204 /**
2205 * Issue CRM-14276
2206 * Add a hook for altering the display name
2207 *
2208 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
2209 *
2210 * @param string $displayName
2211 * @param int $contactId
2212 * @param object $dao
2213 * The contact object.
2214 *
2215 * @return mixed
2216 */
2217 public static function alterDisplayName(&$displayName, $contactId, $dao) {
2218 return self::singleton()->invoke(['displayName', 'contactId', 'dao'],
2219 $displayName, $contactId, $dao, self::$_nullObject, self::$_nullObject,
2220 self::$_nullObject, 'civicrm_contact_get_displayname'
2221 );
2222 }
2223
2224 /**
2225 * Modify the CRM_Core_Resources settings data.
2226 *
2227 * @param array $data
2228 * @see CRM_Core_Resources::addSetting
2229 */
2230 public static function alterResourceSettings(&$data) {
2231 $event = \Civi\Core\Event\GenericHookEvent::create([
2232 'data' => &$data,
2233 ]);
2234 Civi::dispatcher()->dispatch('hook_civicrm_alterResourceSettings', $event);
2235 }
2236
2237 /**
2238 * EXPERIMENTAL: This hook allows one to register additional Angular modules
2239 *
2240 * @param array $angularModules
2241 * List of modules. Each module defines:
2242 * - ext: string, the CiviCRM extension which hosts the files.
2243 * - js: array, list of JS files or globs.
2244 * - css: array, list of CSS files or globs.
2245 * - partials: array, list of base-dirs containing HTML.
2246 * - partialsCallback: mixed, a callback function which generates a list of HTML
2247 * function(string $moduleName, array $moduleDefn) => array(string $file => string $html)
2248 * For future-proofing, use a serializable callback (e.g. string/array).
2249 * See also: Civi\Core\Resolver.
2250 * - requires: array, list of required Angular modules.
2251 * - basePages: array, uncondtionally load this module onto the given Angular pages. [v4.7.21+]
2252 * If omitted, default to "array('civicrm/a')" for backward compat.
2253 * For a utility that should only be loaded on-demand, use "array()".
2254 * For a utility that should be loaded in all pages use, "array('*')".
2255 * @return null
2256 * the return value is ignored
2257 *
2258 * @code
2259 * function mymod_civicrm_angularModules(&$angularModules) {
2260 * $angularModules['myAngularModule'] = array(
2261 * 'ext' => 'org.example.mymod',
2262 * 'js' => array('js/myAngularModule.js'),
2263 * );
2264 * $angularModules['myBigAngularModule'] = array(
2265 * 'ext' => 'org.example.mymod',
2266 * 'js' => array('js/part1.js', 'js/part2.js', 'ext://other.ext.name/file.js', 'assetBuilder://dynamicAsset.js'),
2267 * 'css' => array('css/myAngularModule.css', 'ext://other.ext.name/file.css', 'assetBuilder://dynamicAsset.css'),
2268 * 'partials' => array('partials/myBigAngularModule'),
2269 * 'requires' => array('otherModuleA', 'otherModuleB'),
2270 * 'basePages' => array('civicrm/a'),
2271 * );
2272 * }
2273 * @endcode
2274 */
2275 public static function angularModules(&$angularModules) {
2276 return self::singleton()->invoke(['angularModules'], $angularModules,
2277 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2278 'civicrm_angularModules'
2279 );
2280 }
2281
2282 /**
2283 * Alter the definition of some Angular HTML partials.
2284 *
2285 * @param \Civi\Angular\Manager $angular
2286 *
2287 * @code
2288 * function example_civicrm_alterAngular($angular) {
2289 * $changeSet = \Civi\Angular\ChangeSet::create('mychanges')
2290 * ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) {
2291 * $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')');
2292 * })
2293 * );
2294 * $angular->add($changeSet);
2295 * }
2296 * @endCode
2297 */
2298 public static function alterAngular($angular) {
2299 $event = \Civi\Core\Event\GenericHookEvent::create([
2300 'angular' => $angular,
2301 ]);
2302 Civi::dispatcher()->dispatch('hook_civicrm_alterAngular', $event);
2303 }
2304
2305 /**
2306 * This hook is called when building a link to a semi-static asset.
2307 *
2308 * @param string $asset
2309 * The name of the asset.
2310 * Ex: 'angular.json'
2311 * @param array $params
2312 * List of optional arguments which influence the content.
2313 * @return null
2314 * the return value is ignored
2315 */
2316 public static function getAssetUrl(&$asset, &$params) {
2317 return self::singleton()->invoke(['asset', 'params'],
2318 $asset, $params, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2319 'civicrm_getAssetUrl'
2320 );
2321 }
2322
2323 /**
2324 * This hook is called whenever the system builds a new copy of
2325 * semi-static asset.
2326 *
2327 * @param string $asset
2328 * The name of the asset.
2329 * Ex: 'angular.json'
2330 * @param array $params
2331 * List of optional arguments which influence the content.
2332 * Note: Params are immutable because they are part of the cache-key.
2333 * @param string $mimeType
2334 * Initially, NULL. Modify to specify the mime-type.
2335 * @param string $content
2336 * Initially, NULL. Modify to specify the rendered content.
2337 * @return null
2338 * the return value is ignored
2339 */
2340 public static function buildAsset($asset, $params, &$mimeType, &$content) {
2341 return self::singleton()->invoke(['asset', 'params', 'mimeType', 'content'],
2342 $asset, $params, $mimeType, $content, self::$_nullObject, self::$_nullObject,
2343 'civicrm_buildAsset'
2344 );
2345 }
2346
2347 /**
2348 * This hook fires whenever a record in a case changes.
2349 *
2350 * @param \Civi\CCase\Analyzer $analyzer
2351 * A bundle of data about the case (such as the case and activity records).
2352 */
2353 public static function caseChange(\Civi\CCase\Analyzer $analyzer) {
2354 $event = new \Civi\CCase\Event\CaseChangeEvent($analyzer);
2355 \Civi::dispatcher()->dispatch('hook_civicrm_caseChange', $event);
2356 }
2357
2358 /**
2359 * Generate a default CRUD URL for an entity.
2360 *
2361 * @param array $spec
2362 * With keys:.
2363 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
2364 * - entity_table: string
2365 * - entity_id: int
2366 * @param CRM_Core_DAO $bao
2367 * @param array $link
2368 * To define the link, add these keys to $link:.
2369 * - title: string
2370 * - path: string
2371 * - query: array
2372 * - url: string (used in lieu of "path"/"query")
2373 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
2374 * @return mixed
2375 */
2376 public static function crudLink($spec, $bao, &$link) {
2377 return self::singleton()->invoke(['spec', 'bao', 'link'], $spec, $bao, $link,
2378 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2379 'civicrm_crudLink'
2380 );
2381 }
2382
2383 /**
2384 * Modify the CiviCRM container - add new services, parameters, extensions, etc.
2385 *
2386 * @code
2387 * use Symfony\Component\Config\Resource\FileResource;
2388 * use Symfony\Component\DependencyInjection\Definition;
2389 *
2390 * function mymodule_civicrm_container($container) {
2391 * $container->addResource(new FileResource(__FILE__));
2392 * $container->setDefinition('mysvc', new Definition('My\Class', array()));
2393 * }
2394 * @endcode
2395 *
2396 * Tip: The container configuration will be compiled/cached. The default cache
2397 * behavior is aggressive. When you first implement the hook, be sure to
2398 * flush the cache. Additionally, you should relax caching during development.
2399 * In `civicrm.settings.php`, set define('CIVICRM_CONTAINER_CACHE', 'auto').
2400 *
2401 * Note: This is a preboot hook. It will dispatch via the extension/module
2402 * subsystem but *not* the Symfony EventDispatcher.
2403 *
2404 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
2405 * @see http://symfony.com/doc/current/components/dependency_injection/index.html
2406 */
2407 public static function container(\Symfony\Component\DependencyInjection\ContainerBuilder $container) {
2408 self::singleton()->invoke(['container'], $container, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_container');
2409 }
2410
2411 /**
2412 * @param array $fileSearches CRM_Core_FileSearchInterface
2413 * @return mixed
2414 */
2415 public static function fileSearches(&$fileSearches) {
2416 return self::singleton()->invoke(['fileSearches'], $fileSearches,
2417 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2418 'civicrm_fileSearches'
2419 );
2420 }
2421
2422 /**
2423 * Check system status.
2424 *
2425 * @param array $messages
2426 * Array<CRM_Utils_Check_Message>. A list of messages regarding system status.
2427 * @return mixed
2428 */
2429 public static function check(&$messages) {
2430 return self::singleton()
2431 ->invoke(['messages'], $messages, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_check');
2432 }
2433
2434 /**
2435 * This hook is called when a query string of the CSV Batch export is generated.
2436 *
2437 * @param string $query
2438 *
2439 * @return mixed
2440 */
2441 public static function batchQuery(&$query) {
2442 return self::singleton()->invoke(['query'], $query, self::$_nullObject,
2443 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2444 'civicrm_batchQuery'
2445 );
2446 }
2447
2448 /**
2449 * This hook is called to alter Deferred revenue item values just before they are
2450 * inserted in civicrm_financial_trxn table
2451 *
2452 * @param array $deferredRevenues
2453 *
2454 * @param array $contributionDetails
2455 *
2456 * @param bool $update
2457 *
2458 * @param string $context
2459 *
2460 * @return mixed
2461 */
2462 public static function alterDeferredRevenueItems(&$deferredRevenues, $contributionDetails, $update, $context) {
2463 return self::singleton()->invoke(['deferredRevenues', 'contributionDetails', 'update', 'context'], $deferredRevenues, $contributionDetails, $update, $context,
2464 self::$_nullObject, self::$_nullObject, 'civicrm_alterDeferredRevenueItems'
2465 );
2466 }
2467
2468 /**
2469 * This hook is called when the entries of the CSV Batch export are mapped.
2470 *
2471 * @param array $results
2472 * @param array $items
2473 *
2474 * @return mixed
2475 */
2476 public static function batchItems(&$results, &$items) {
2477 return self::singleton()->invoke(['results', 'items'], $results, $items,
2478 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2479 'civicrm_batchItems'
2480 );
2481 }
2482
2483 /**
2484 * This hook is called when core resources are being loaded
2485 *
2486 * @see CRM_Core_Resources::coreResourceList
2487 *
2488 * @param array $list
2489 * @param string $region
2490 */
2491 public static function coreResourceList(&$list, $region) {
2492 self::singleton()->invoke(['list', 'region'], $list, $region,
2493 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2494 'civicrm_coreResourceList'
2495 );
2496 }
2497
2498 /**
2499 * Allows the list of filters on the EntityRef widget to be altered.
2500 *
2501 * @see CRM_Core_Resources::entityRefFilters
2502 *
2503 * @param array $filters
2504 * @param array $links
2505 */
2506 public static function entityRefFilters(&$filters, &$links = NULL) {
2507 self::singleton()->invoke(['filters', 'links'], $filters, $links, self::$_nullObject,
2508 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2509 'civicrm_entityRefFilters'
2510 );
2511 }
2512
2513 /**
2514 * This hook is called for bypass a few civicrm urls from IDS check.
2515 *
2516 * @param array $skip list of civicrm urls
2517 *
2518 * @return mixed
2519 */
2520 public static function idsException(&$skip) {
2521 return self::singleton()->invoke(['skip'], $skip, self::$_nullObject,
2522 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2523 'civicrm_idsException'
2524 );
2525 }
2526
2527 /**
2528 * This hook is called when a geocoder's format method is called.
2529 *
2530 * @param string $geoProvider
2531 * @param array $values
2532 * @param SimpleXMLElement $xml
2533 *
2534 * @return mixed
2535 */
2536 public static function geocoderFormat($geoProvider, &$values, $xml) {
2537 return self::singleton()->invoke(['geoProvider', 'values', 'xml'], $geoProvider, $values, $xml,
2538 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2539 'civicrm_geocoderFormat'
2540 );
2541 }
2542
2543 /**
2544 * This hook is called before an inbound SMS is processed.
2545 *
2546 * @param \CRM_SMS_Message $message
2547 * An SMS message received
2548 * @return mixed
2549 */
2550 public static function inboundSMS(&$message) {
2551 return self::singleton()->invoke(['message'], $message, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_inboundSMS');
2552 }
2553
2554 /**
2555 * This hook is called to modify api params of EntityRef form field
2556 *
2557 * @param array $params
2558 * @param string $formName
2559 * @return mixed
2560 */
2561 public static function alterEntityRefParams(&$params, $formName) {
2562 return self::singleton()->invoke(['params', 'formName'], $params, $formName,
2563 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2564 'civicrm_alterEntityRefParams'
2565 );
2566 }
2567
2568 /**
2569 * This hook is called before a scheduled job is executed
2570 *
2571 * @param CRM_Core_DAO_Job $job
2572 * The job to be executed
2573 * @param array $params
2574 * The arguments to be given to the job
2575 */
2576 public static function preJob($job, $params) {
2577 return self::singleton()->invoke(['job', 'params'], $job, $params,
2578 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2579 'civicrm_preJob'
2580 );
2581 }
2582
2583 /**
2584 * This hook is called after a scheduled job is executed
2585 *
2586 * @param CRM_Core_DAO_Job $job
2587 * The job that was executed
2588 * @param array $params
2589 * The arguments given to the job
2590 * @param array $result
2591 * The result of the API call, or the thrown exception if any
2592 */
2593 public static function postJob($job, $params, $result) {
2594 return self::singleton()->invoke(['job', 'params', 'result'], $job, $params, $result,
2595 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2596 'civicrm_postJob'
2597 );
2598 }
2599
2600 /**
2601 * This hook is called before and after constructing mail recipients.
2602 * Allows user to alter filter and/or search query to fetch mail recipients
2603 *
2604 * @param CRM_Mailing_DAO_Mailing $mailingObject
2605 * @param array $criteria
2606 * A list of SQL criteria; you can add/remove/replace/modify criteria.
2607 * Array(string $name => CRM_Utils_SQL_Select $criterion).
2608 * Ex: array('do_not_email' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_email = 0")).
2609 * @param string $context
2610 * Ex: 'pre', 'post'
2611 * @return mixed
2612 */
2613 public static function alterMailingRecipients(&$mailingObject, &$criteria, $context) {
2614 return self::singleton()->invoke(['mailingObject', 'params', 'context'],
2615 $mailingObject, $criteria, $context,
2616 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2617 'civicrm_alterMailingRecipients'
2618 );
2619 }
2620
2621 /**
2622 * ALlow Extensions to custom process IPN hook data such as sending Google Analyitcs information based on the IPN
2623 * @param array $IPNData - Array of IPN Data
2624 * @return mixed
2625 */
2626 public static function postIPNProcess(&$IPNData) {
2627 return self::singleton()->invoke(['IPNData'],
2628 $IPNData, self::$_nullObject, self::$_nullObject,
2629 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2630 'civicrm_postIPNProcess'
2631 );
2632 }
2633
2634 /**
2635 * Allow extensions to modify the array of acceptable fields to be included on profiles
2636 * @param array $fields
2637 * format is [Entity => array of DAO fields]
2638 * @return mixed
2639 */
2640 public static function alterUFFields(&$fields) {
2641 return self::singleton()->invoke(['fields'],
2642 $fields, self::$_nullObject, self::$_nullObject,
2643 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2644 'civicrm_alterUFFields'
2645 );
2646 }
2647
2648 }