CRM-14707 - CRM_Utils_Hook::runHooks - Cache function names
[civicrm-core.git] / CRM / Utils / Hook.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
7e9e8871 4 | CiviCRM version 4.7 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CiviCRM_Hook
e7112fa7 31 * @copyright CiviCRM LLC (c) 2004-2015
6a488035 32 */
6a488035
TO
33abstract class CRM_Utils_Hook {
34
35 // Allowed values for dashboard hook content placement
36 // Default - place content below activity list
7da04cde 37 const DASHBOARD_BELOW = 1;
6a488035 38 // Place content above activity list
7da04cde 39 const DASHBOARD_ABOVE = 2;
6a488035 40 // Don't display activity list at all
7da04cde 41 const DASHBOARD_REPLACE = 3;
6a488035
TO
42
43 // by default - place content below existing content
7da04cde 44 const SUMMARY_BELOW = 1;
6a488035 45 // pace hook content above
7da04cde 46 const SUMMARY_ABOVE = 2;
6a488035 47 // create your own summarys
7da04cde 48 const SUMMARY_REPLACE = 3;
6a488035
TO
49
50 static $_nullObject = NULL;
51
52 /**
53 * We only need one instance of this object. So we use the singleton
54 * pattern and cache the instance in this variable
55 *
56 * @var object
6a488035
TO
57 */
58 static private $_singleton = NULL;
59
60 /**
61 * @var bool
62 */
63 private $commonIncluded = FALSE;
64
65 /**
66 * @var array(string)
67 */
68 private $commonCiviModules = array();
69
ad8ccc04
TO
70 /**
71 * @var CRM_Utils_Cache_Interface
72 */
73 protected $cache;
74
6a488035 75 /**
fe482240 76 * Constructor and getter for the singleton instance.
6a488035 77 *
72536736
AH
78 * @param bool $fresh
79 *
80 * @return self
81 * An instance of $config->userHookClass
6a488035 82 */
00be9182 83 public static function singleton($fresh = FALSE) {
6a488035
TO
84 if (self::$_singleton == NULL || $fresh) {
85 $config = CRM_Core_Config::singleton();
86 $class = $config->userHookClass;
6a488035
TO
87 self::$_singleton = new $class();
88 }
89 return self::$_singleton;
90 }
91
ad8ccc04
TO
92 public function __construct() {
93 $this->cache = CRM_Utils_Cache::create(array(
94 'name' => 'hooks',
95 'type' => array('ArrayCache'),
96 'prefetch' => 1,
97 ));
98 }
99
72536736 100 /**
fe482240 101 * Invoke hooks.
f0a7a0c9 102 *
77855840
TO
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.
72536736
AH
119 *
120 * @return mixed
121 */
37cd2432 122 public abstract function invoke(
a3e55d9c 123 $numParams,
87dab4a4 124 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
6a488035
TO
125 $fnSuffix
126 );
127
5bc392e6 128 /**
100fef9d 129 * @param array $numParams
5bc392e6
EM
130 * @param $arg1
131 * @param $arg2
132 * @param $arg3
133 * @param $arg4
134 * @param $arg5
135 * @param $arg6
136 * @param $fnSuffix
137 * @param $fnPrefix
138 *
139 * @return array|bool
140 */
37cd2432 141 public function commonInvoke(
a3e55d9c 142 $numParams,
87dab4a4 143 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
6a488035
TO
144 $fnSuffix, $fnPrefix
145 ) {
146
147 $this->commonBuildModuleList($fnPrefix);
4636d4fd 148
6a488035 149 return $this->runHooks($this->commonCiviModules, $fnSuffix,
87dab4a4 150 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
6a488035
TO
151 );
152 }
153
154 /**
155 * Build the list of modules to be processed for hooks.
72536736
AH
156 *
157 * @param string $fnPrefix
6a488035 158 */
00be9182 159 public function commonBuildModuleList($fnPrefix) {
6a488035
TO
160 if (!$this->commonIncluded) {
161 // include external file
162 $this->commonIncluded = TRUE;
163
164 $config = CRM_Core_Config::singleton();
165 if (!empty($config->customPHPPathDir) &&
166 file_exists("{$config->customPHPPathDir}/civicrmHooks.php")
167 ) {
e7292422 168 @include_once "civicrmHooks.php";
6a488035
TO
169 }
170
171 if (!empty($fnPrefix)) {
172 $this->commonCiviModules[$fnPrefix] = $fnPrefix;
173 }
174
175 $this->requireCiviModules($this->commonCiviModules);
176 }
177 }
178
72536736
AH
179 /**
180 * @param $civiModules
181 * @param $fnSuffix
100fef9d 182 * @param array $numParams
72536736
AH
183 * @param $arg1
184 * @param $arg2
185 * @param $arg3
186 * @param $arg4
187 * @param $arg5
188 * @param $arg6
189 *
190 * @return array|bool
191 */
37cd2432 192 public function runHooks(
a3e55d9c 193 $civiModules, $fnSuffix, $numParams,
87dab4a4 194 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
6a488035 195 ) {
3ac9ab1c
TO
196 // $civiModules is *not* passed by reference because runHooks
197 // must be reentrant. PHP is finicky about running
198 // multiple loops over the same variable. The circumstances
199 // to reproduce the issue are pretty intricate.
1cba072e 200 $result = array();
6a488035 201
ad8ccc04
TO
202 $fnNames = $this->cache->get($fnSuffix);
203 if (!is_array($fnNames)) {
204 $fnNames = array();
205 if ($civiModules !== NULL) {
206 foreach ($civiModules as $module) {
207 $fnName = "{$module}_{$fnSuffix}";
208 if (function_exists($fnName)) {
209 $fnNames[] = $fnName;
1cba072e 210 }
4636d4fd 211 }
ad8ccc04
TO
212 $this->cache->set($fnSuffix, $fnNames);
213 }
214 }
215
216 foreach ($fnNames as $fnName) {
217 $fResult = array();
218 switch ($numParams) {
219 case 0:
220 $fResult = $fnName();
221 break;
222
223 case 1:
224 $fResult = $fnName($arg1);
225 break;
226
227 case 2:
228 $fResult = $fnName($arg1, $arg2);
229 break;
230
231 case 3:
232 $fResult = $fnName($arg1, $arg2, $arg3);
233 break;
234
235 case 4:
236 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
237 break;
238
239 case 5:
240 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
241 break;
242
243 case 6:
244 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
245 break;
246
247 default:
248 CRM_Core_Error::fatal(ts('Invalid hook invocation'));
249 break;
250 }
251
252 if (!empty($fResult) &&
253 is_array($fResult)
254 ) {
255 $result = array_merge($result, $fResult);
6a488035
TO
256 }
257 }
258
259 return empty($result) ? TRUE : $result;
260 }
261
5bc392e6
EM
262 /**
263 * @param $moduleList
264 */
00be9182 265 public function requireCiviModules(&$moduleList) {
6a488035
TO
266 $civiModules = CRM_Core_PseudoConstant::getModuleExtensions();
267 foreach ($civiModules as $civiModule) {
268 if (!file_exists($civiModule['filePath'])) {
269 CRM_Core_Session::setStatus(
481a74f4
TO
270 ts('Error loading module file (%1). Please restore the file or disable the module.',
271 array(1 => $civiModule['filePath'])),
272 ts('Warning'), 'error');
6a488035
TO
273 continue;
274 }
275 include_once $civiModule['filePath'];
276 $moduleList[$civiModule['prefix']] = $civiModule['prefix'];
6a488035 277 }
e7292422 278 }
6a488035
TO
279
280 /**
281 * This hook is called before a db write on some core objects.
282 * This hook does not allow the abort of the operation
283 *
77855840
TO
284 * @param string $op
285 * The type of operation being performed.
286 * @param string $objectName
287 * The name of the object.
288 * @param int $id
289 * The object id if available.
290 * @param array $params
291 * The parameters used for object creation / editing.
6a488035 292 *
a6c01b45
CW
293 * @return null
294 * the return value is ignored
6a488035 295 */
00be9182 296 public static function pre($op, $objectName, $id, &$params) {
fd901044 297 $event = new \Civi\Core\Event\PreEvent($op, $objectName, $id, $params);
048222df
TO
298 \Civi::service('dispatcher')->dispatch("hook_civicrm_pre", $event);
299 \Civi::service('dispatcher')->dispatch("hook_civicrm_pre::$objectName", $event);
37cd2432
TO
300 return self::singleton()
301 ->invoke(4, $op, $objectName, $id, $params, self::$_nullObject, self::$_nullObject, 'civicrm_pre');
6a488035
TO
302 }
303
304 /**
305 * This hook is called after a db write on some core objects.
306 *
77855840
TO
307 * @param string $op
308 * The type of operation being performed.
309 * @param string $objectName
310 * The name of the object.
311 * @param int $objectId
312 * The unique identifier for the object.
313 * @param object $objectRef
314 * The reference to the object if available.
6a488035 315 *
72b3a70c
CW
316 * @return mixed
317 * based on op. pre-hooks return a boolean or
6a488035 318 * an error message which aborts the operation
6a488035 319 */
00be9182 320 public static function post($op, $objectName, $objectId, &$objectRef) {
fd901044 321 $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef);
048222df
TO
322 \Civi::service('dispatcher')->dispatch("hook_civicrm_post", $event);
323 \Civi::service('dispatcher')->dispatch("hook_civicrm_post::$objectName", $event);
37cd2432
TO
324 return self::singleton()
325 ->invoke(4, $op, $objectName, $objectId, $objectRef, self::$_nullObject, self::$_nullObject, 'civicrm_post');
6a488035
TO
326 }
327
6a488035 328 /**
fe482240 329 * This hook retrieves links from other modules and injects it into.
6a488035
TO
330 * the view contact tabs
331 *
77855840
TO
332 * @param string $op
333 * The type of operation being performed.
334 * @param string $objectName
335 * The name of the object.
336 * @param int $objectId
337 * The unique identifier for the object.
338 * @param array $links
339 * (optional) the links array (introduced in v3.2).
340 * @param int $mask
341 * (optional) the bitmask to show/hide links.
342 * @param array $values
343 * (optional) the values to fill the links.
6a488035 344 *
a6c01b45
CW
345 * @return null
346 * the return value is ignored
6a488035 347 */
00be9182 348 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = array()) {
87dab4a4 349 return self::singleton()->invoke(6, $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
6a488035
TO
350 }
351
21d2903d
AN
352 /**
353 * This hook is invoked during the CiviCRM form preProcess phase.
354 *
77855840
TO
355 * @param string $formName
356 * The name of the form.
357 * @param CRM_Core_Form $form
358 * Reference to the form object.
21d2903d 359 *
a6c01b45
CW
360 * @return null
361 * the return value is ignored
21d2903d 362 */
00be9182 363 public static function preProcess($formName, &$form) {
37cd2432 364 return self::singleton()
353ffa53 365 ->invoke(2, $formName, $form, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_preProcess');
21d2903d
AN
366 }
367
6a488035
TO
368 /**
369 * This hook is invoked when building a CiviCRM form. This hook should also
370 * be used to set the default values of a form element
371 *
77855840
TO
372 * @param string $formName
373 * The name of the form.
374 * @param CRM_Core_Form $form
375 * Reference to the form object.
6a488035 376 *
a6c01b45
CW
377 * @return null
378 * the return value is ignored
6a488035 379 */
00be9182 380 public static function buildForm($formName, &$form) {
37cd2432
TO
381 return self::singleton()->invoke(2, $formName, $form,
382 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
383 'civicrm_buildForm'
384 );
6a488035
TO
385 }
386
387 /**
388 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
389 * any form elements, this hook should save the values in the database
390 *
77855840
TO
391 * @param string $formName
392 * The name of the form.
393 * @param CRM_Core_Form $form
394 * Reference to the form object.
6a488035 395 *
a6c01b45
CW
396 * @return null
397 * the return value is ignored
6a488035 398 */
00be9182 399 public static function postProcess($formName, &$form) {
37cd2432
TO
400 return self::singleton()->invoke(2, $formName, $form,
401 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
402 'civicrm_postProcess'
403 );
6a488035
TO
404 }
405
406 /**
407 * This hook is invoked during all CiviCRM form validation. An array of errors
6a488035
TO
408 * detected is returned. Else we assume validation succeeded.
409 *
77855840
TO
410 * @param string $formName
411 * The name of the form.
412 * @param array &$fields the POST parameters as filtered by QF
413 * @param array &$files the FILES parameters as sent in by POST
414 * @param array &$form the form object
415 * @param array &$errors the array of errors.
6a488035 416 *
72b3a70c
CW
417 * @return mixed
418 * formRule hooks return a boolean or
6a488035 419 * an array of error messages which display a QF Error
6a488035 420 */
00be9182 421 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
37cd2432
TO
422 return self::singleton()
423 ->invoke(5, $formName, $fields, $files, $form, $errors, self::$_nullObject, 'civicrm_validateForm');
6a488035
TO
424 }
425
426 /**
42bc70d4 427 * This hook is called after a db write on a custom table.
6a488035 428 *
77855840
TO
429 * @param string $op
430 * The type of operation being performed.
431 * @param string $groupID
432 * The custom group ID.
433 * @param object $entityID
434 * The entityID of the row in the custom table.
435 * @param array $params
436 * The parameters that were sent into the calling function.
6a488035 437 *
a6c01b45
CW
438 * @return null
439 * the return value is ignored
6a488035 440 */
00be9182 441 public static function custom($op, $groupID, $entityID, &$params) {
37cd2432
TO
442 return self::singleton()
443 ->invoke(4, $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_custom');
6a488035
TO
444 }
445
446 /**
447 * This hook is called when composing the ACL where clause to restrict
448 * visibility of contacts to the logged in user
449 *
77855840
TO
450 * @param int $type
451 * The type of permission needed.
452 * @param array $tables
453 * (reference ) add the tables that are needed for the select clause.
454 * @param array $whereTables
455 * (reference ) add the tables that are needed for the where clause.
456 * @param int $contactID
457 * The contactID for whom the check is made.
458 * @param string $where
459 * The currrent where clause.
6a488035 460 *
a6c01b45
CW
461 * @return null
462 * the return value is ignored
6a488035 463 */
00be9182 464 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
37cd2432
TO
465 return self::singleton()
466 ->invoke(5, $type, $tables, $whereTables, $contactID, $where, self::$_nullObject, 'civicrm_aclWhereClause');
6a488035
TO
467 }
468
469 /**
470 * This hook is called when composing the ACL where clause to restrict
471 * visibility of contacts to the logged in user
472 *
77855840
TO
473 * @param int $type
474 * The type of permission needed.
475 * @param int $contactID
476 * The contactID for whom the check is made.
477 * @param string $tableName
478 * The tableName which is being permissioned.
479 * @param array $allGroups
480 * The set of all the objects for the above table.
481 * @param array $currentGroups
482 * The set of objects that are currently permissioned for this contact.
6a488035 483 *
a6c01b45
CW
484 * @return null
485 * the return value is ignored
6a488035 486 */
00be9182 487 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
37cd2432
TO
488 return self::singleton()
489 ->invoke(5, $type, $contactID, $tableName, $allGroups, $currentGroups, self::$_nullObject, 'civicrm_aclGroup');
6a488035
TO
490 }
491
492 /**
fe482240 493 * This hook is called when building the menu table.
6a488035 494 *
77855840
TO
495 * @param array $files
496 * The current set of files to process.
6a488035 497 *
a6c01b45
CW
498 * @return null
499 * the return value is ignored
6a488035 500 */
00be9182 501 public static function xmlMenu(&$files) {
6a488035 502 return self::singleton()->invoke(1, $files,
87dab4a4 503 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
504 'civicrm_xmlMenu'
505 );
506 }
507
508 /**
88718db2 509 * This hook is called for declaring managed entities via API.
6a488035 510 *
77855840 511 * @param array $entities
88718db2
TO
512 * List of pending entities. Each entity is an array with keys:
513 * + '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")
514 * + 'name': string, a symbolic name which can be used to track this entity (Note: Each module creates its own namespace)
515 * + 'entity': string, an entity-type supported by the CiviCRM API (Note: this currently must be an entity which supports the 'is_active' property)
516 * + 'params': array, the entity data as supported by the CiviCRM API
517 * + 'update' (v4.5+): string, a policy which describes when to update records
518 * - 'always' (default): always update the managed-entity record; changes in $entities will override any local changes (eg by the site-admin)
519 * - 'never': never update the managed-entity record; changes made locally (eg by the site-admin) will override changes in $entities
520 * + '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)
521 * - 'always' (default): always delete orphaned records
522 * - 'never': never delete orphaned records
523 * - 'unused': only delete orphaned records if there are no other references to it in the DB. (This is determined by calling the API's "getrefcount" action.)
6a488035 524 *
a6c01b45
CW
525 * @return null
526 * the return value is ignored
6a488035 527 */
00be9182 528 public static function managed(&$entities) {
6a488035 529 return self::singleton()->invoke(1, $entities,
87dab4a4 530 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
531 'civicrm_managed'
532 );
533 }
534
535 /**
536 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
537 *
77855840
TO
538 * @param int $contactID
539 * The contactID for whom the dashboard is being rendered.
540 * @param int $contentPlacement
541 * (output parameter) where should the hook content be displayed.
9399901d 542 * relative to the activity list
6a488035 543 *
a6c01b45
CW
544 * @return string
545 * the html snippet to include in the dashboard
6a488035 546 */
00be9182 547 public static function dashboard($contactID, &$contentPlacement = self::DASHBOARD_BELOW) {
6a488035 548 $retval = self::singleton()->invoke(2, $contactID, $contentPlacement,
87dab4a4 549 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
550 'civicrm_dashboard'
551 );
552
553 /*
554 * Note we need this seemingly unnecessary code because in the event that the implementation
555 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
556 * though we have a default value in this function's declaration above.
557 */
558 if (!isset($contentPlacement)) {
559 $contentPlacement = self::DASHBOARD_BELOW;
560 }
561
562 return $retval;
563 }
564
565 /**
566 * This hook is called before storing recently viewed items.
567 *
77855840
TO
568 * @param array $recentArray
569 * An array of recently viewed or processed items, for in place modification.
6a488035
TO
570 *
571 * @return array
6a488035 572 */
00be9182 573 public static function recent(&$recentArray) {
6a488035 574 return self::singleton()->invoke(1, $recentArray,
87dab4a4 575 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
576 'civicrm_recent'
577 );
578 }
579
91dee34b 580 /**
fe482240 581 * Determine how many other records refer to a given record.
91dee34b 582 *
77855840
TO
583 * @param CRM_Core_DAO $dao
584 * The item for which we want a reference count.
585 * @param array $refCounts
16b10e64 586 * Each item in the array is an Array with keys:
91dee34b
TO
587 * - name: string, eg "sql:civicrm_email:contact_id"
588 * - type: string, eg "sql"
589 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
153b262f
EM
590 *
591 * @return mixed
592 * Return is not really intended to be used.
91dee34b 593 */
00be9182 594 public static function referenceCounts($dao, &$refCounts) {
91dee34b
TO
595 return self::singleton()->invoke(2, $dao, $refCounts,
596 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
597 'civicrm_referenceCounts'
598 );
599 }
600
6a488035 601 /**
fe482240 602 * This hook is called when building the amount structure for a Contribution or Event Page.
6a488035 603 *
77855840
TO
604 * @param int $pageType
605 * Is this a contribution or event page.
606 * @param CRM_Core_Form $form
607 * Reference to the form object.
608 * @param array $amount
609 * The amount structure to be displayed.
6a488035
TO
610 *
611 * @return null
6a488035 612 */
00be9182 613 public static function buildAmount($pageType, &$form, &$amount) {
9399901d 614 return self::singleton()->invoke(3, $pageType, $form, $amount, self::$_nullObject,
87dab4a4 615 self::$_nullObject, self::$_nullObject, 'civicrm_buildAmount');
6a488035
TO
616 }
617
618 /**
619 * This hook is called when building the state list for a particular country.
620 *
72536736
AH
621 * @param array $countryID
622 * The country id whose states are being selected.
623 * @param $states
6a488035
TO
624 *
625 * @return null
6a488035 626 */
00be9182 627 public static function buildStateProvinceForCountry($countryID, &$states) {
6a488035 628 return self::singleton()->invoke(2, $countryID, $states,
87dab4a4 629 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
630 'civicrm_buildStateProvinceForCountry'
631 );
632 }
633
634 /**
635 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
636 *
77855840
TO
637 * @param array $tabs
638 * The array of tabs that will be displayed.
639 * @param int $contactID
640 * The contactID for whom the dashboard is being rendered.
6a488035
TO
641 *
642 * @return null
6a488035 643 */
00be9182 644 public static function tabs(&$tabs, $contactID) {
6a488035 645 return self::singleton()->invoke(2, $tabs, $contactID,
87dab4a4 646 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tabs'
6a488035
TO
647 );
648 }
649
fa3dbfbd 650 /**
72536736
AH
651 * This hook is called when rendering the tabs used for events and potentially
652 * contribution pages, etc.
653 *
654 * @param string $tabsetName
655 * Name of the screen or visual element.
656 * @param array $tabs
657 * Tabs that will be displayed.
658 * @param array $context
659 * Extra data about the screen or context in which the tab is used.
fa3dbfbd 660 *
2efcf0c2 661 * @return null
fa3dbfbd 662 */
00be9182 663 public static function tabset($tabsetName, &$tabs, $context) {
379a8439 664 return self::singleton()->invoke(3, $tabsetName, $tabs,
87dab4a4 665 $context, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tabset'
fa3dbfbd 666 );
667 }
668
6a488035
TO
669 /**
670 * This hook is called when sending an email / printing labels
671 *
77855840
TO
672 * @param array $tokens
673 * The list of tokens that can be used for the contact.
6a488035
TO
674 *
675 * @return null
6a488035 676 */
00be9182 677 public static function tokens(&$tokens) {
6a488035 678 return self::singleton()->invoke(1, $tokens,
87dab4a4 679 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tokens'
6a488035
TO
680 );
681 }
682
683 /**
684 * This hook is called when sending an email / printing labels to get the values for all the
685 * tokens returned by the 'tokens' hook
686 *
77855840
TO
687 * @param array $details
688 * The array to store the token values indexed by contactIDs (unless it a single).
689 * @param array $contactIDs
690 * An array of contactIDs.
691 * @param int $jobID
692 * The jobID if this is associated with a CiviMail mailing.
693 * @param array $tokens
694 * The list of tokens associated with the content.
695 * @param string $className
696 * The top level className from where the hook is invoked.
6a488035
TO
697 *
698 * @return null
6a488035 699 */
37cd2432 700 public static function tokenValues(
a3e55d9c 701 &$details,
6a488035 702 $contactIDs,
e7292422
TO
703 $jobID = NULL,
704 $tokens = array(),
6a488035
TO
705 $className = NULL
706 ) {
37cd2432
TO
707 return self::singleton()
708 ->invoke(5, $details, $contactIDs, $jobID, $tokens, $className, self::$_nullObject, 'civicrm_tokenValues');
6a488035
TO
709 }
710
711 /**
712 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
713 * in a template
714 *
77855840
TO
715 * @param object $page
716 * The page that will be rendered.
6a488035
TO
717 *
718 * @return null
6a488035 719 */
00be9182 720 public static function pageRun(&$page) {
6a488035 721 return self::singleton()->invoke(1, $page,
87dab4a4 722 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
723 'civicrm_pageRun'
724 );
725 }
726
727 /**
728 * This hook is called after a copy of an object has been made. The current objects are
729 * Event, Contribution Page and UFGroup
730 *
77855840
TO
731 * @param string $objectName
732 * Name of the object.
733 * @param object $object
734 * Reference to the copy.
6a488035
TO
735 *
736 * @return null
6a488035 737 */
00be9182 738 public static function copy($objectName, &$object) {
6a488035 739 return self::singleton()->invoke(2, $objectName, $object,
87dab4a4 740 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
741 'civicrm_copy'
742 );
743 }
744
745 /**
746 * This hook is called when a contact unsubscribes from a mailing. It allows modules
747 * to override what the contacts are removed from.
748 *
72536736
AH
749 * @param string $op
750 * Ignored for now
751 * @param int $mailingId
752 * The id of the mailing to unsub from
753 * @param int $contactId
754 * The id of the contact who is unsubscribing
755 * @param array|int $groups
756 * Groups the contact will be removed from.
757 * @param array|int $baseGroups
758 * Base groups (used in smart mailings) the contact will be removed from.
759 *
dcbd3a55 760 *
72536736
AH
761 * @return mixed
762 */
00be9182 763 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
37cd2432
TO
764 return self::singleton()
765 ->invoke(5, $op, $mailingId, $contactId, $groups, $baseGroups, self::$_nullObject, 'civicrm_unsubscribeGroups');
6a488035
TO
766 }
767
768 /**
9399901d
KJ
769 * This hook is called when CiviCRM needs to edit/display a custom field with options (select, radio, checkbox,
770 * adv multiselect)
6a488035 771 *
77855840
TO
772 * @param int $customFieldID
773 * The custom field ID.
774 * @param array $options
775 * The current set of options for that custom field.
6a488035 776 * You can add/remove existing options.
9399901d
KJ
777 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
778 * to be careful to not overwrite the array.
6a488035 779 * Only add/edit/remove the specific field options you intend to affect.
77855840
TO
780 * @param bool $detailedFormat
781 * If true,.
9399901d 782 * the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
77855840
TO
783 * @param array $selectAttributes
784 * Contain select attribute(s) if any.
72536736
AH
785 *
786 * @return mixed
6a488035 787 */
00be9182 788 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = array()) {
6a488035 789 return self::singleton()->invoke(3, $customFieldID, $options, $detailedFormat,
87dab4a4 790 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
791 'civicrm_customFieldOptions'
792 );
793 }
794
795 /**
796 *
797 * This hook is called to display the list of actions allowed after doing a search.
798 * This allows the module developer to inject additional actions or to remove existing actions.
799 *
77855840
TO
800 * @param string $objectType
801 * The object type for this search.
6a488035 802 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
77855840
TO
803 * @param array $tasks
804 * The current set of tasks for that custom field.
6a488035 805 * You can add/remove existing tasks.
7f82e636 806 * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class
9399901d 807 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
6a488035 808 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
9399901d
KJ
809 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
810 * found in CRM/$objectType/Task.php.
72536736
AH
811 *
812 * @return mixed
6a488035 813 */
00be9182 814 public static function searchTasks($objectType, &$tasks) {
6a488035 815 return self::singleton()->invoke(2, $objectType, $tasks,
87dab4a4 816 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
817 'civicrm_searchTasks'
818 );
819 }
820
72536736
AH
821 /**
822 * @param mixed $form
823 * @param array $params
824 *
825 * @return mixed
826 */
00be9182 827 public static function eventDiscount(&$form, &$params) {
6a488035 828 return self::singleton()->invoke(2, $form, $params,
87dab4a4 829 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
830 'civicrm_eventDiscount'
831 );
832 }
833
834 /**
835 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
836 *
72536736
AH
837 * @param mixed $form
838 * The form object for which groups / mailings being displayed
839 * @param array $groups
840 * The list of groups being included / excluded
841 * @param array $mailings
842 * The list of mailings being included / excluded
843 *
844 * @return mixed
6a488035 845 */
00be9182 846 public static function mailingGroups(&$form, &$groups, &$mailings) {
6a488035 847 return self::singleton()->invoke(3, $form, $groups, $mailings,
87dab4a4 848 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
849 'civicrm_mailingGroups'
850 );
851 }
852
853 /**
9399901d
KJ
854 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
855 * (new or renewal).
6a488035
TO
856 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
857 * You can use it to alter the membership types when first loaded, or after submission
858 * (for example if you want to gather data in the form and use it to alter the fees).
859 *
72536736
AH
860 * @param mixed $form
861 * The form object that is presenting the page
862 * @param array $membershipTypes
863 * The array of membership types and their amount
864 *
865 * @return mixed
6a488035 866 */
00be9182 867 public static function membershipTypeValues(&$form, &$membershipTypes) {
6a488035 868 return self::singleton()->invoke(2, $form, $membershipTypes,
87dab4a4 869 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
870 'civicrm_membershipTypeValues'
871 );
872 }
873
874 /**
fe482240 875 * This hook is called when rendering the contact summary.
6a488035 876 *
72536736
AH
877 * @param int $contactID
878 * The contactID for whom the summary is being rendered
879 * @param mixed $content
880 * @param int $contentPlacement
881 * Specifies where the hook content should be displayed relative to the
882 * existing content
6a488035 883 *
72536736
AH
884 * @return string
885 * The html snippet to include in the contact summary
6a488035 886 */
00be9182 887 public static function summary($contactID, &$content, &$contentPlacement = self::SUMMARY_BELOW) {
6a488035 888 return self::singleton()->invoke(3, $contactID, $content, $contentPlacement,
87dab4a4 889 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
890 'civicrm_summary'
891 );
892 }
893
894 /**
895 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
896 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
897 * If you want to limit the contacts returned to a specific group, or some other criteria
898 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
899 * The hook is called when the query is executed to get the list of contacts to display.
900 *
77855840
TO
901 * @param mixed $query
902 * - the query that will be executed (input and output parameter);.
6a488035
TO
903 * It's important to realize that the ACL clause is built prior to this hook being fired,
904 * so your query will ignore any ACL rules that may be defined.
905 * Your query must return two columns:
906 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
907 * the contact IDs
77855840
TO
908 * @param string $name
909 * The name string to execute the query against (this is the value being typed in by the user).
910 * @param string $context
911 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
912 * @param int $id
913 * The id of the object for which the call is being made.
6a488035 914 * For custom fields, it will be the custom field id
72536736
AH
915 *
916 * @return mixed
6a488035 917 */
00be9182 918 public static function contactListQuery(&$query, $name, $context, $id) {
6a488035 919 return self::singleton()->invoke(4, $query, $name, $context, $id,
87dab4a4 920 self::$_nullObject, self::$_nullObject,
6a488035
TO
921 'civicrm_contactListQuery'
922 );
923 }
924
925 /**
926 * Hook definition for altering payment parameters before talking to a payment processor back end.
927 *
928 * Definition will look like this:
929 *
153b262f
EM
930 * function hook_civicrm_alterPaymentProcessorParams(
931 * $paymentObj,
932 * &$rawParams,
933 * &$cookedParams
934 * );
80bcd255 935 *
153b262f
EM
936 * @param CRM_Core_Payment $paymentObj
937 * Instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
938 * See discussion in CRM-16224 as to whether $paymentObj should be passed by reference.
6a488035
TO
939 * @param array &$rawParams
940 * array of params as passed to to the processor
72536736 941 * @param array &$cookedParams
6a488035
TO
942 * params after the processor code has translated them into its own key/value pairs
943 *
72536736 944 * @return mixed
80bcd255 945 * This return is not really intended to be used.
6a488035 946 */
37cd2432 947 public static function alterPaymentProcessorParams(
a3e55d9c 948 $paymentObj,
6a488035
TO
949 &$rawParams,
950 &$cookedParams
951 ) {
952 return self::singleton()->invoke(3, $paymentObj, $rawParams, $cookedParams,
87dab4a4 953 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
954 'civicrm_alterPaymentProcessorParams'
955 );
956 }
957
958 /**
959 * This hook is called when an email is about to be sent by CiviCRM.
960 *
72536736
AH
961 * @param array $params
962 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
16b10e64 963 * returnPath, replyTo, headers, attachments (array)
77855840
TO
964 * @param string $context
965 * The context in which the hook is being invoked, eg 'civimail'.
72536736
AH
966 *
967 * @return mixed
6a488035 968 */
00be9182 969 public static function alterMailParams(&$params, $context = NULL) {
6a488035 970 return self::singleton()->invoke(2, $params, $context,
87dab4a4 971 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
972 'civicrm_alterMailParams'
973 );
974 }
975
5f11bbcc 976 /**
fe482240 977 * This hook is called when membership status is being calculated.
5f11bbcc 978 *
77855840
TO
979 * @param array $membershipStatus
980 * Membership status details as determined - alter if required.
981 * @param array $arguments
982 * Arguments passed in to calculate date.
5f11bbcc
EM
983 * - 'start_date'
984 * - 'end_date'
985 * - 'status_date'
986 * - 'join_date'
987 * - 'exclude_is_admin'
988 * - 'membership_type_id'
77855840
TO
989 * @param array $membership
990 * Membership details from the calling function.
f4aaa82a
EM
991 *
992 * @return mixed
5f11bbcc 993 */
00be9182 994 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
5f11bbcc 995 return self::singleton()->invoke(3, $membershipStatus, $arguments,
fc6a608f 996 $membership, self::$_nullObject, self::$_nullObject, self::$_nullObject,
5f11bbcc
EM
997 'civicrm_alterCalculatedMembershipStatus'
998 );
999 }
1000
6a488035 1001 /**
fe482240 1002 * This hook is called when rendering the Manage Case screen.
6a488035 1003 *
77855840
TO
1004 * @param int $caseID
1005 * The case ID.
6a488035 1006 *
a6c01b45 1007 * @return array
16b10e64
CW
1008 * Array of data to be displayed, where the key is a unique id to be used for styling (div id's)
1009 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
6a488035 1010 */
00be9182 1011 public static function caseSummary($caseID) {
6a488035 1012 return self::singleton()->invoke(1, $caseID,
87dab4a4 1013 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1014 'civicrm_caseSummary'
1015 );
1016 }
1017
6b86870e
TO
1018 /**
1019 * This hook is called when locating CiviCase types.
1020 *
1021 * @param array $caseTypes
72536736
AH
1022 *
1023 * @return mixed
6b86870e 1024 */
00be9182 1025 public static function caseTypes(&$caseTypes) {
37cd2432
TO
1026 return self::singleton()
1027 ->invoke(1, $caseTypes, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_caseTypes');
6b86870e
TO
1028 }
1029
6a488035
TO
1030 /**
1031 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1032 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
72536736
AH
1033 *
1034 * @param CRM_Core_Config|array $config
1035 * The config object
1036 *
1037 * @return mixed
6a488035 1038 */
00be9182 1039 public static function config(&$config) {
6a488035 1040 return self::singleton()->invoke(1, $config,
87dab4a4 1041 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1042 'civicrm_config'
1043 );
1044 }
1045
6a488035 1046 /**
fe482240 1047 * This hooks allows to change option values.
6a488035 1048 *
72536736
AH
1049 * @param array $options
1050 * Associated array of option values / id
1051 * @param string $name
1052 * Option group name
6a488035 1053 *
72536736 1054 * @return mixed
6a488035 1055 */
00be9182 1056 public static function optionValues(&$options, $name) {
6a488035 1057 return self::singleton()->invoke(2, $options, $name,
87dab4a4 1058 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1059 'civicrm_optionValues'
1060 );
1061 }
1062
1063 /**
1064 * This hook allows modification of the navigation menu.
1065 *
72536736
AH
1066 * @param array $params
1067 * Associated array of navigation menu entry to Modify/Add
1068 *
1069 * @return mixed
6a488035 1070 */
00be9182 1071 public static function navigationMenu(&$params) {
6a488035 1072 return self::singleton()->invoke(1, $params,
87dab4a4 1073 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1074 'civicrm_navigationMenu'
1075 );
1076 }
1077
1078 /**
1079 * This hook allows modification of the data used to perform merging of duplicates.
1080 *
77855840
TO
1081 * @param string $type
1082 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1083 * @param array $data
1084 * The data, as described in $type.
1085 * @param int $mainId
1086 * Contact_id of the contact that survives the merge.
1087 * @param int $otherId
1088 * Contact_id of the contact that will be absorbed and deleted.
1089 * @param array $tables
1090 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
6a488035 1091 *
72536736 1092 * @return mixed
6a488035 1093 */
00be9182 1094 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
87dab4a4 1095 return self::singleton()->invoke(5, $type, $data, $mainId, $otherId, $tables, self::$_nullObject, 'civicrm_merge');
6a488035
TO
1096 }
1097
1098 /**
1099 * This hook provides a way to override the default privacy behavior for notes.
1100 *
72536736
AH
1101 * @param array &$noteValues
1102 * Associative array of values for this note
6a488035 1103 *
72536736 1104 * @return mixed
6a488035 1105 */
00be9182 1106 public static function notePrivacy(&$noteValues) {
6a488035 1107 return self::singleton()->invoke(1, $noteValues,
87dab4a4 1108 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1109 'civicrm_notePrivacy'
1110 );
1111 }
1112
1113 /**
fe482240 1114 * This hook is called before record is exported as CSV.
6a488035 1115 *
77855840
TO
1116 * @param string $exportTempTable
1117 * Name of the temporary export table used during export.
1118 * @param array $headerRows
1119 * Header rows for output.
1120 * @param array $sqlColumns
1121 * SQL columns.
1122 * @param int $exportMode
1123 * Export mode ( contact, contribution, etc...).
6a488035 1124 *
72536736 1125 * @return mixed
6a488035 1126 */
00be9182 1127 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, &$exportMode) {
6a488035 1128 return self::singleton()->invoke(4, $exportTempTable, $headerRows, $sqlColumns, $exportMode,
87dab4a4 1129 self::$_nullObject, self::$_nullObject,
6a488035
TO
1130 'civicrm_export'
1131 );
1132 }
1133
1134 /**
1135 * This hook allows modification of the queries constructed from dupe rules.
1136 *
77855840
TO
1137 * @param string $obj
1138 * Object of rulegroup class.
1139 * @param string $type
1140 * Type of queries e.g table / threshold.
1141 * @param array $query
1142 * Set of queries.
6a488035 1143 *
f4aaa82a 1144 * @return mixed
6a488035 1145 */
00be9182 1146 public static function dupeQuery($obj, $type, &$query) {
6a488035 1147 return self::singleton()->invoke(3, $obj, $type, $query,
87dab4a4 1148 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1149 'civicrm_dupeQuery'
1150 );
1151 }
1152
1153 /**
1154 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1155 *
77855840
TO
1156 * @param string $type
1157 * Type of mail processed: 'activity' OR 'mailing'.
f4aaa82a 1158 * @param array &$params the params that were sent to the CiviCRM API function
77855840
TO
1159 * @param object $mail
1160 * The mail object which is an ezcMail class.
f4aaa82a 1161 * @param array &$result the result returned by the api call
77855840
TO
1162 * @param string $action
1163 * (optional ) the requested action to be performed if the types was 'mailing'.
6a488035 1164 *
f4aaa82a 1165 * @return mixed
6a488035 1166 */
00be9182 1167 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
37cd2432
TO
1168 return self::singleton()
1169 ->invoke(5, $type, $params, $mail, $result, $action, self::$_nullObject, 'civicrm_emailProcessor');
6a488035
TO
1170 }
1171
1172 /**
1173 * This hook is called after a row has been processed and the
1174 * record (and associated records imported
1175 *
77855840
TO
1176 * @param string $object
1177 * Object being imported (for now Contact only, later Contribution, Activity,.
9399901d 1178 * Participant and Member)
77855840
TO
1179 * @param string $usage
1180 * Hook usage/location (for now process only, later mapping and others).
1181 * @param string $objectRef
1182 * Import record object.
1183 * @param array $params
1184 * Array with various key values: currently.
6a488035
TO
1185 * contactID - contact id
1186 * importID - row id in temp table
1187 * importTempTable - name of tempTable
1188 * fieldHeaders - field headers
1189 * fields - import fields
1190 *
b8c71ffa 1191 * @return mixed
6a488035 1192 */
00be9182 1193 public static function import($object, $usage, &$objectRef, &$params) {
6a488035 1194 return self::singleton()->invoke(4, $object, $usage, $objectRef, $params,
87dab4a4 1195 self::$_nullObject, self::$_nullObject,
6a488035
TO
1196 'civicrm_import'
1197 );
1198 }
1199
1200 /**
1201 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
aa5ba569 1202 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
6a488035 1203 *
77855840
TO
1204 * @param string $entity
1205 * The API entity (like contact).
1206 * @param string $action
1207 * The API action (like get).
f4aaa82a 1208 * @param array &$params the API parameters
c490a46a 1209 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
f4aaa82a
EM
1210 *
1211 * @return mixed
6a488035 1212 */
00be9182 1213 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
6a488035 1214 return self::singleton()->invoke(4, $entity, $action, $params, $permissions,
87dab4a4 1215 self::$_nullObject, self::$_nullObject,
6a488035
TO
1216 'civicrm_alterAPIPermissions'
1217 );
1218 }
1219
5bc392e6 1220 /**
c490a46a 1221 * @param CRM_Core_DAO $dao
5bc392e6
EM
1222 *
1223 * @return mixed
1224 */
00be9182 1225 public static function postSave(&$dao) {
6a488035
TO
1226 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1227 return self::singleton()->invoke(1, $dao,
87dab4a4 1228 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1229 $hookName
1230 );
1231 }
1232
1233 /**
1234 * This hook allows user to customize context menu Actions on contact summary page.
1235 *
77855840
TO
1236 * @param array $actions
1237 * Array of all Actions in contextmenu.
1238 * @param int $contactID
1239 * ContactID for the summary page.
f4aaa82a
EM
1240 *
1241 * @return mixed
6a488035 1242 */
00be9182 1243 public static function summaryActions(&$actions, $contactID = NULL) {
6a488035 1244 return self::singleton()->invoke(2, $actions, $contactID,
87dab4a4 1245 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1246 'civicrm_summaryActions'
1247 );
1248 }
1249
1250 /**
1251 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1252 * This enables us hook implementors to modify both the headers and the rows
1253 *
1254 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1255 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1256 *
1257 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1258 * you want displayed. This is a hackish, but avoids template modification.
1259 *
77855840
TO
1260 * @param string $objectName
1261 * The component name that we are doing the search.
6a488035 1262 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
f4aaa82a
EM
1263 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1264 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
16b10e64
CW
1265 * @param array $selector
1266 * the selector object. Allows you access to the context of the search
6a488035 1267 *
b8c71ffa 1268 * @return mixed
a6c01b45 1269 * modify the header and values object to pass the data u need
6a488035 1270 */
00be9182 1271 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
6a488035 1272 return self::singleton()->invoke(4, $objectName, $headers, $rows, $selector,
87dab4a4 1273 self::$_nullObject, self::$_nullObject,
6a488035
TO
1274 'civicrm_searchColumns'
1275 );
1276 }
1277
1278 /**
1279 * This hook is called when uf groups are being built for a module.
1280 *
77855840
TO
1281 * @param string $moduleName
1282 * Module name.
1283 * @param array $ufGroups
1284 * Array of ufgroups for a module.
6a488035
TO
1285 *
1286 * @return null
6a488035 1287 */
00be9182 1288 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
6a488035 1289 return self::singleton()->invoke(2, $moduleName, $ufGroups,
87dab4a4 1290 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1291 'civicrm_buildUFGroupsForModule'
1292 );
1293 }
1294
1295 /**
1296 * This hook is called when we are determining the contactID for a specific
1297 * email address
1298 *
77855840
TO
1299 * @param string $email
1300 * The email address.
1301 * @param int $contactID
1302 * The contactID that matches this email address, IF it exists.
1303 * @param array $result
1304 * (reference) has two fields.
6a488035
TO
1305 * contactID - the new (or same) contactID
1306 * action - 3 possible values:
9399901d
KJ
1307 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1308 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1309 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
6a488035
TO
1310 *
1311 * @return null
6a488035 1312 */
00be9182 1313 public static function emailProcessorContact($email, $contactID, &$result) {
6a488035 1314 return self::singleton()->invoke(3, $email, $contactID, $result,
87dab4a4 1315 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1316 'civicrm_emailProcessorContact'
1317 );
1318 }
1319
1320 /**
fe482240 1321 * Hook definition for altering the generation of Mailing Labels.
6a488035 1322 *
77855840
TO
1323 * @param array $args
1324 * An array of the args in the order defined for the tcpdf multiCell api call.
6a488035
TO
1325 * with the variable names below converted into string keys (ie $w become 'w'
1326 * as the first key for $args)
1327 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1328 * float $h Cell minimum height. The cell extends automatically if needed.
1329 * string $txt String to print
1330 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1331 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1332 * a string containing some or all of the following characters (in any order):
1333 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1334 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1335 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1336 * (default value when $ishtml=false)</li></ul>
1337 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1338 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1339 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1340 * float $x x position in user units
1341 * float $y y position in user units
1342 * boolean $reseth if true reset the last cell height (default true).
b44e3f84 1343 * int $stretch stretch character mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
6a488035
TO
1344 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1345 * necessary</li><li>4 = forced character spacing</li></ul>
1346 * boolean $ishtml set to true if $txt is HTML content (default = false).
1347 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1348 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1349 * or 0 for disable this feature. This feature works only when $ishtml=false.
1350 *
f4aaa82a 1351 * @return mixed
6a488035 1352 */
00be9182 1353 public static function alterMailingLabelParams(&$args) {
6a488035
TO
1354 return self::singleton()->invoke(1, $args,
1355 self::$_nullObject, self::$_nullObject,
87dab4a4 1356 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1357 'civicrm_alterMailingLabelParams'
1358 );
1359 }
1360
1361 /**
fe482240 1362 * This hooks allows alteration of generated page content.
6a488035 1363 *
77855840
TO
1364 * @param $content
1365 * Previously generated content.
1366 * @param $context
1367 * Context of content - page or form.
1368 * @param $tplName
1369 * The file name of the tpl.
1370 * @param $object
1371 * A reference to the page or form object.
6a488035 1372 *
f4aaa82a 1373 * @return mixed
6a488035 1374 */
00be9182 1375 public static function alterContent(&$content, $context, $tplName, &$object) {
6a488035 1376 return self::singleton()->invoke(4, $content, $context, $tplName, $object,
87dab4a4 1377 self::$_nullObject, self::$_nullObject,
6a488035
TO
1378 'civicrm_alterContent'
1379 );
1380 }
1381
8aac22c8 1382 /**
1383 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1384 * altercontent hook as the content has already been rendered through the tpl at that point
1385 *
77855840
TO
1386 * @param $formName
1387 * Previously generated content.
1388 * @param $form
1389 * Reference to the form object.
1390 * @param $context
1391 * Context of content - page or form.
1392 * @param $tplName
1393 * Reference the file name of the tpl.
8aac22c8 1394 *
f4aaa82a 1395 * @return mixed
8aac22c8 1396 */
00be9182 1397 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
8aac22c8 1398 return self::singleton()->invoke(4, $formName, $form, $context, $tplName,
87dab4a4 1399 self::$_nullObject, self::$_nullObject,
8aac22c8 1400 'civicrm_alterTemplateFile'
1401 );
1402 }
f4aaa82a 1403
6a488035 1404 /**
fe482240 1405 * This hook collects the trigger definition from all components.
6a488035 1406 *
f4aaa82a 1407 * @param $info
77855840
TO
1408 * @param string $tableName
1409 * (optional) the name of the table that we are interested in only.
f4aaa82a
EM
1410 *
1411 * @internal param \reference $triggerInfo to an array of trigger information
6a488035
TO
1412 * each element has 4 fields:
1413 * table - array of tableName
1414 * when - BEFORE or AFTER
1415 * event - array of eventName - INSERT OR UPDATE OR DELETE
1416 * sql - array of statements optionally terminated with a ;
1417 * a statement can use the tokes {tableName} and {eventName}
1418 * to do token replacement with the table / event. This allows
1419 * templatizing logging and other hooks
f4aaa82a 1420 * @return mixed
6a488035 1421 */
00be9182 1422 public static function triggerInfo(&$info, $tableName = NULL) {
6a488035 1423 return self::singleton()->invoke(2, $info, $tableName,
87dab4a4 1424 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1425 self::$_nullObject,
1426 'civicrm_triggerInfo'
1427 );
1428 }
1429
1430 /**
1431 * This hook is called when a module-extension is installed.
9399901d
KJ
1432 * Each module will receive hook_civicrm_install during its own installation (but not during the
1433 * installation of unrelated modules).
6a488035 1434 */
00be9182 1435 public static function install() {
6a488035
TO
1436 return self::singleton()->invoke(0, self::$_nullObject,
1437 self::$_nullObject, self::$_nullObject,
87dab4a4 1438 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1439 'civicrm_install'
1440 );
1441 }
1442
1443 /**
1444 * This hook is called when a module-extension is uninstalled.
9399901d
KJ
1445 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1446 * uninstallation of unrelated modules).
6a488035 1447 */
00be9182 1448 public static function uninstall() {
6a488035
TO
1449 return self::singleton()->invoke(0, self::$_nullObject,
1450 self::$_nullObject, self::$_nullObject,
87dab4a4 1451 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1452 'civicrm_uninstall'
1453 );
1454 }
1455
1456 /**
1457 * This hook is called when a module-extension is re-enabled.
9399901d
KJ
1458 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1459 * re-enablement of unrelated modules).
6a488035 1460 */
00be9182 1461 public static function enable() {
6a488035
TO
1462 return self::singleton()->invoke(0, self::$_nullObject,
1463 self::$_nullObject, self::$_nullObject,
87dab4a4 1464 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1465 'civicrm_enable'
1466 );
1467 }
1468
1469 /**
1470 * This hook is called when a module-extension is disabled.
9399901d
KJ
1471 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1472 * disablement of unrelated modules).
6a488035 1473 */
00be9182 1474 public static function disable() {
6a488035
TO
1475 return self::singleton()->invoke(0, self::$_nullObject,
1476 self::$_nullObject, self::$_nullObject,
87dab4a4 1477 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1478 'civicrm_disable'
1479 );
1480 }
1481
5bc392e6
EM
1482 /**
1483 * @param $varType
1484 * @param $var
1485 * @param $object
1486 *
1487 * @return mixed
1488 */
00be9182 1489 public static function alterReportVar($varType, &$var, &$object) {
6a488035
TO
1490 return self::singleton()->invoke(3, $varType, $var, $object,
1491 self::$_nullObject,
87dab4a4 1492 self::$_nullObject, self::$_nullObject,
6a488035
TO
1493 'civicrm_alterReportVar'
1494 );
1495 }
1496
1497 /**
1498 * This hook is called to drive database upgrades for extension-modules.
1499 *
72536736
AH
1500 * @param string $op
1501 * The type of operation being performed; 'check' or 'enqueue'.
1502 * @param CRM_Queue_Queue $queue
1503 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
6a488035 1504 *
72536736
AH
1505 * @return bool|null
1506 * NULL, if $op is 'enqueue'.
1507 * TRUE, if $op is 'check' and upgrades are pending.
1508 * FALSE, if $op is 'check' and upgrades are not pending.
6a488035 1509 */
00be9182 1510 public static function upgrade($op, CRM_Queue_Queue $queue = NULL) {
6a488035 1511 return self::singleton()->invoke(2, $op, $queue,
87dab4a4 1512 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1513 self::$_nullObject,
1514 'civicrm_upgrade'
1515 );
1516 }
1517
1518 /**
1519 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1520 *
72536736
AH
1521 * @param array $params
1522 * The mailing parameters. Array fields include: groupName, from, toName,
1523 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1524 * attachments (array)
1525 *
1526 * @return mixed
6a488035 1527 */
00be9182 1528 public static function postEmailSend(&$params) {
6a488035
TO
1529 return self::singleton()->invoke(1, $params,
1530 self::$_nullObject, self::$_nullObject,
87dab4a4 1531 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1532 'civicrm_postEmailSend'
1533 );
1534 }
1535
1536 /**
fe482240 1537 * This hook is called when Settings specifications are loaded.
6a488035 1538 *
72536736
AH
1539 * @param array $settingsFolders
1540 * List of paths from which to derive metadata
1541 *
1542 * @return mixed
6a488035 1543 */
00be9182 1544 public static function alterSettingsFolders(&$settingsFolders) {
6a488035 1545 return self::singleton()->invoke(1, $settingsFolders,
37cd2432
TO
1546 self::$_nullObject, self::$_nullObject,
1547 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1548 'civicrm_alterSettingsFolders'
6a488035
TO
1549 );
1550 }
1551
1552 /**
1553 * This hook is called when Settings have been loaded from the xml
1554 * It is an opportunity for hooks to alter the data
1555 *
77855840
TO
1556 * @param array $settingsMetaData
1557 * Settings Metadata.
72536736
AH
1558 * @param int $domainID
1559 * @param mixed $profile
1560 *
1561 * @return mixed
6a488035 1562 */
00be9182 1563 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
6a488035 1564 return self::singleton()->invoke(3, $settingsMetaData,
37cd2432
TO
1565 $domainID, $profile,
1566 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1567 'civicrm_alterSettingsMetaData'
6a488035
TO
1568 );
1569 }
1570
5270c026
XD
1571 /**
1572 * This hook is called before running an api call.
1573 *
72536736
AH
1574 * @param API_Wrapper[] $wrappers
1575 * (see CRM_Utils_API_ReloadOption as an example)
1576 * @param mixed $apiRequest
5270c026 1577 *
72536736
AH
1578 * @return null
1579 * The return value is ignored
5270c026 1580 */
00be9182 1581 public static function apiWrappers(&$wrappers, $apiRequest) {
09f8c8dc
TO
1582 return self::singleton()
1583 ->invoke(2, $wrappers, $apiRequest, self::$_nullObject, self::$_nullObject, self::$_nullObject,
37cd2432
TO
1584 self::$_nullObject, 'civicrm_apiWrappers'
1585 );
5270c026
XD
1586 }
1587
6a488035
TO
1588 /**
1589 * This hook is called before running pending cron jobs.
1590 *
1591 * @param CRM_Core_JobManager $jobManager
1592 *
72536736
AH
1593 * @return null
1594 * The return value is ignored.
6a488035 1595 */
00be9182 1596 public static function cron($jobManager) {
6a488035 1597 return self::singleton()->invoke(1,
87dab4a4 1598 $jobManager, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1599 'civicrm_cron'
1600 );
1601 }
1602
1603 /**
1604 * This hook is called when loading CMS permissions; use this hook to modify
1605 * the array of system permissions for CiviCRM.
1606 *
72536736
AH
1607 * @param array $permissions
1608 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1609 * the format of this array.
6a488035 1610 *
72536736
AH
1611 * @return null
1612 * The return value is ignored
6a488035 1613 */
00be9182 1614 public static function permission(&$permissions) {
6a488035 1615 return self::singleton()->invoke(1, $permissions,
87dab4a4 1616 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1617 'civicrm_permission'
1618 );
1619 }
fed67e4d 1620
4b57bc9f
EM
1621 /**
1622 * @param CRM_Core_Exception Exception $exception
77855840
TO
1623 * @param mixed $request
1624 * Reserved for future use.
4b57bc9f 1625 */
37cd2432
TO
1626 public static function unhandledException($exception, $request = NULL) {
1627 self::singleton()
1628 ->invoke(2, $exception, $request, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_unhandled_exception');
4caeca04
TO
1629 // == 4.4 ==
1630 //$event = new stdClass();
1631 //$event->exception = $exception;
1632 //CRM_Core_LegacyErrorHandler::handleException($event);
1633
665b4982 1634 // == 4.5+ ==
4caeca04 1635 $event = new \Civi\Core\Event\UnhandledExceptionEvent($exception, self::$_nullObject);
048222df 1636 \Civi::service('dispatcher')->dispatch("hook_civicrm_unhandled_exception", $event);
4b57bc9f 1637 }
fed67e4d
TO
1638
1639 /**
fe482240 1640 * This hook is called for declaring managed entities via API.
fed67e4d 1641 *
72536736
AH
1642 * @param array[] $entityTypes
1643 * List of entity types; each entity-type is an array with keys:
fed67e4d
TO
1644 * - name: string, a unique short name (e.g. "ReportInstance")
1645 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
1646 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
1647 *
72536736
AH
1648 * @return null
1649 * The return value is ignored
fed67e4d 1650 */
00be9182 1651 public static function entityTypes(&$entityTypes) {
9399901d 1652 return self::singleton()->invoke(1, $entityTypes, self::$_nullObject, self::$_nullObject,
87dab4a4 1653 self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_entityTypes'
fed67e4d
TO
1654 );
1655 }
a8387f19
TO
1656
1657 /**
fe482240 1658 * This hook is called while preparing a profile form.
a8387f19
TO
1659 *
1660 * @param string $name
72536736 1661 * @return mixed
a8387f19 1662 */
00be9182 1663 public static function buildProfile($name) {
9399901d 1664 return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 1665 self::$_nullObject, self::$_nullObject, 'civicrm_buildProfile');
a8387f19
TO
1666 }
1667
1668 /**
fe482240 1669 * This hook is called while validating a profile form submission.
a8387f19
TO
1670 *
1671 * @param string $name
72536736 1672 * @return mixed
a8387f19 1673 */
00be9182 1674 public static function validateProfile($name) {
9399901d 1675 return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 1676 self::$_nullObject, self::$_nullObject, 'civicrm_validateProfile');
a8387f19
TO
1677 }
1678
1679 /**
fe482240 1680 * This hook is called processing a valid profile form submission.
a8387f19
TO
1681 *
1682 * @param string $name
72536736 1683 * @return mixed
a8387f19 1684 */
00be9182 1685 public static function processProfile($name) {
9399901d 1686 return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 1687 self::$_nullObject, self::$_nullObject, 'civicrm_processProfile');
a8387f19
TO
1688 }
1689
1690 /**
1691 * This hook is called while preparing a read-only profile screen
1692 *
1693 * @param string $name
72536736 1694 * @return mixed
a8387f19 1695 */
00be9182 1696 public static function viewProfile($name) {
9399901d 1697 return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 1698 self::$_nullObject, self::$_nullObject, 'civicrm_viewProfile');
a8387f19
TO
1699 }
1700
1701 /**
1702 * This hook is called while preparing a list of contacts (based on a profile)
1703 *
1704 * @param string $name
72536736 1705 * @return mixed
a8387f19 1706 */
00be9182 1707 public static function searchProfile($name) {
9399901d 1708 return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 1709 self::$_nullObject, self::$_nullObject, 'civicrm_searchProfile');
9399901d
KJ
1710 }
1711
d0fc33e2
M
1712 /**
1713 * This hook is invoked when building a CiviCRM name badge.
1714 *
77855840
TO
1715 * @param string $labelName
1716 * String referencing name of badge format.
1717 * @param object $label
1718 * Reference to the label object.
1719 * @param array $format
1720 * Array of format data.
1721 * @param array $participant
1722 * Array of participant values.
d0fc33e2 1723 *
a6c01b45
CW
1724 * @return null
1725 * the return value is ignored
d0fc33e2 1726 */
00be9182 1727 public static function alterBadge($labelName, &$label, &$format, &$participant) {
37cd2432
TO
1728 return self::singleton()
1729 ->invoke(4, $labelName, $label, $format, $participant, self::$_nullObject, self::$_nullObject, 'civicrm_alterBadge');
d0fc33e2
M
1730 }
1731
1732
9399901d 1733 /**
fe482240 1734 * This hook is called before encoding data in barcode.
9399901d 1735 *
77855840
TO
1736 * @param array $data
1737 * Associated array of values available for encoding.
1738 * @param string $type
1739 * Type of barcode, classic barcode or QRcode.
1740 * @param string $context
1741 * Where this hooks is invoked.
9399901d 1742 *
72536736 1743 * @return mixed
9399901d 1744 */
e7292422 1745 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
9399901d 1746 return self::singleton()->invoke(3, $data, $type, $context, self::$_nullObject,
87dab4a4 1747 self::$_nullObject, self::$_nullObject, 'civicrm_alterBarcode');
a8387f19 1748 }
99e9587a 1749
72ad6c1b
TO
1750 /**
1751 * Modify or replace the Mailer object used for outgoing mail.
1752 *
1753 * @param object $mailer
1754 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
1755 * @param string $driver
1756 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
1757 * @param array $params
1758 * The default mailer config options
72536736
AH
1759 *
1760 * @return mixed
72ad6c1b
TO
1761 * @see Mail::factory
1762 */
00be9182 1763 public static function alterMail(&$mailer, $driver, $params) {
c8e4bea0 1764 return self::singleton()
87dab4a4 1765 ->invoke(3, $mailer, $driver, $params, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_alterMailer');
72ad6c1b
TO
1766 }
1767
99e9587a 1768 /**
2efcf0c2 1769 * This hook is called while building the core search query,
99e9587a
DS
1770 * so hook implementers can provide their own query objects which alters/extends core search.
1771 *
72536736
AH
1772 * @param array $queryObjects
1773 * @param string $type
1774 *
1775 * @return mixed
99e9587a 1776 */
00be9182 1777 public static function queryObjects(&$queryObjects, $type = 'Contact') {
37cd2432
TO
1778 return self::singleton()
1779 ->invoke(2, $queryObjects, $type, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_queryObjects');
99e9587a 1780 }
15d9b3ae
N
1781
1782 /**
fe482240 1783 * This hook is called while viewing contact dashboard.
15d9b3ae 1784 *
72536736
AH
1785 * @param array $availableDashlets
1786 * List of dashlets; each is formatted per api/v3/Dashboard
1787 * @param array $defaultDashlets
1788 * List of dashlets; each is formatted per api/v3/DashboardContact
1789 *
1790 * @return mixed
15d9b3ae 1791 */
00be9182 1792 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
37cd2432
TO
1793 return self::singleton()
1794 ->invoke(2, $availableDashlets, $defaultDashlets, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_dashboard_defaults');
15d9b3ae 1795 }
02094cdb
JJ
1796
1797 /**
1798 * This hook is called before a case merge (or a case reassign)
f4aaa82a 1799 *
77855840
TO
1800 * @param int $mainContactId
1801 * @param int $mainCaseId
1802 * @param int $otherContactId
1803 * @param int $otherCaseId
3d0d359e 1804 * @param bool $changeClient
f4aaa82a 1805 *
b8c71ffa 1806 * @return mixed
02094cdb 1807 */
00be9182 1808 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
37cd2432
TO
1809 return self::singleton()
1810 ->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_pre_case_merge');
02094cdb 1811 }
f4aaa82a 1812
02094cdb
JJ
1813 /**
1814 * This hook is called after a case merge (or a case reassign)
f4aaa82a 1815 *
77855840
TO
1816 * @param int $mainContactId
1817 * @param int $mainCaseId
1818 * @param int $otherContactId
1819 * @param int $otherCaseId
3d0d359e 1820 * @param bool $changeClient
77b97be7 1821 *
b8c71ffa 1822 * @return mixed
02094cdb 1823 */
00be9182 1824 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
37cd2432
TO
1825 return self::singleton()
1826 ->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_post_case_merge');
02094cdb 1827 }
250b3b1f 1828
1829 /**
1830 * Issue CRM-14276
1831 * Add a hook for altering the display name
1832 *
1833 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
f4aaa82a 1834 *
250b3b1f 1835 * @param string $displayName
1836 * @param int $contactId
77855840
TO
1837 * @param object $dao
1838 * The contact object.
f4aaa82a
EM
1839 *
1840 * @return mixed
250b3b1f 1841 */
267578ea 1842 public static function alterDisplayName(&$displayName, $contactId, $dao) {
250b3b1f 1843 return self::singleton()->invoke(3,
1844 $displayName, $contactId, $dao, self::$_nullObject, self::$_nullObject,
1845 self::$_nullObject, 'civicrm_contact_get_displayname'
1846 );
1847 }
e7ff7042
TO
1848
1849 /**
1850 * EXPERIMENTAL: This hook allows one to register additional Angular modules
1851 *
77855840
TO
1852 * @param array $angularModules
1853 * List of modules.
a6c01b45
CW
1854 * @return null
1855 * the return value is ignored
e7ff7042
TO
1856 *
1857 * @code
1858 * function mymod_civicrm_angularModules(&$angularModules) {
8671b4f2
TO
1859 * $angularModules['myAngularModule'] = array(
1860 * 'ext' => 'org.example.mymod',
1861 * 'js' => array('js/myAngularModule.js'),
1862 * );
1863 * $angularModules['myBigAngularModule'] = array(
1864 * 'ext' => 'org.example.mymod',
1865 * 'js' => array('js/part1.js', 'js/part2.js'),
1866 * 'css' => array('css/myAngularModule.css'),
1867 * 'partials' => array('partials/myBigAngularModule'),
1868 * );
e7ff7042
TO
1869 * }
1870 * @endcode
1871 */
00be9182 1872 public static function angularModules(&$angularModules) {
e7ff7042
TO
1873 return self::singleton()->invoke(1, $angularModules,
1874 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1875 'civicrm_angularModules'
1876 );
1877 }
1878
708d8fa2
TO
1879 /**
1880 * This hook fires whenever a record in a case changes.
1881 *
1882 * @param \Civi\CCase\Analyzer $analyzer
1883 */
00be9182 1884 public static function caseChange(\Civi\CCase\Analyzer $analyzer) {
708d8fa2 1885 $event = new \Civi\CCase\Event\CaseChangeEvent($analyzer);
048222df 1886 \Civi::service('dispatcher')->dispatch("hook_civicrm_caseChange", $event);
708d8fa2
TO
1887
1888 return self::singleton()->invoke(1, $angularModules,
1889 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1890 'civicrm_caseChange'
1891 );
1892 }
688ad538
TO
1893
1894 /**
fe482240 1895 * Generate a default CRUD URL for an entity.
688ad538 1896 *
77855840
TO
1897 * @param array $spec
1898 * With keys:.
688ad538
TO
1899 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
1900 * - entity_table: string
1901 * - entity_id: int
1902 * @param CRM_Core_DAO $bao
77855840
TO
1903 * @param array $link
1904 * To define the link, add these keys to $link:.
16b10e64
CW
1905 * - title: string
1906 * - path: string
1907 * - query: array
1908 * - url: string (used in lieu of "path"/"query")
688ad538
TO
1909 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
1910 * @return mixed
1911 */
00be9182 1912 public static function crudLink($spec, $bao, &$link) {
688ad538
TO
1913 return self::singleton()->invoke(3, $spec, $bao, $link,
1914 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1915 'civicrm_crudLink'
1916 );
1917 }
6cccc6d4 1918
40787e18
TO
1919 /**
1920 * Modify the CiviCRM container - add new services, parameters, extensions, etc.
1921 *
1922 * @code
1923 * use Symfony\Component\Config\Resource\FileResource;
1924 * use Symfony\Component\DependencyInjection\Definition;
1925 *
1926 * function mymodule_civicrm_container($container) {
1927 * $container->addResource(new FileResource(__FILE__));
1928 * $container->setDefinition('mysvc', new Definition('My\Class', array()));
1929 * }
1930 * @endcode
1931 *
1932 * Tip: The container configuration will be compiled/cached. The default cache
1933 * behavior is aggressive. When you first implement the hook, be sure to
1934 * flush the cache. Additionally, you should relax caching during development.
1935 * In `civicrm.settings.php`, set define('CIVICRM_CONTAINER_CACHE', 'auto').
1936 *
1937 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
1938 * @see http://symfony.com/doc/current/components/dependency_injection/index.html
1939 */
1940 public static function container(\Symfony\Component\DependencyInjection\ContainerBuilder $container) {
1941 self::singleton()->invoke(1, $container, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_container');
1942 }
1943
6cccc6d4 1944 /**
37cd2432 1945 * @param array <CRM_Core_FileSearchInterface> $fileSearches
6cccc6d4
TO
1946 * @return mixed
1947 */
00be9182 1948 public static function fileSearches(&$fileSearches) {
6cccc6d4
TO
1949 return self::singleton()->invoke(1, $fileSearches,
1950 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1951 'civicrm_fileSearches'
1952 );
1953 }
96025800 1954
260e353b
TO
1955 /**
1956 * Check system status.
1957 *
1958 * @param array $messages
1959 * Array<CRM_Utils_Check_Message>. A list of messages regarding system status.
1960 * @return mixed
1961 */
1962 public static function check(&$messages) {
1963 return self::singleton()
1964 ->invoke(1, $messages, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_check');
1965 }
1966
75c8a3f7
GC
1967 /**
1968 * This hook is called when a query string of the CSV Batch export is generated.
1969 */
1970 public static function batchQuery(&$query) {
1971 return self::singleton()->invoke(1, $query, self::$_nullObject,
1972 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1973 'civicrm_batchQuery'
1974 );
1975 }
1976
1977 /**
1978 * This hook is called when the entries of the CSV Batch export are mapped.
1979 */
1980 public static function batchItems(&$results, &$items) {
1981 return self::singleton()->invoke(2, $results, $items,
1982 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1983 'civicrm_batchItems'
1984 );
1985 }
1986
72e86d7d
CW
1987 /**
1988 * This hook is called when core resources are being loaded
1989 *
1990 * @see CRM_Core_Resources::coreResourceList
1991 *
1992 * @param array $list
e3c1e85b 1993 * @param string $region
72e86d7d 1994 */
e3c1e85b 1995 public static function coreResourceList(&$list, $region) {
72e86d7d
CW
1996 // First allow the cms integration to add to the list
1997 CRM_Core_Config::singleton()->userSystem->appendCoreResources($list);
1998
e3c1e85b
CW
1999 self::singleton()->invoke(2, $list, $region,
2000 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
72e86d7d
CW
2001 'civicrm_coreResourceList'
2002 );
2003 }
2004
6a488035 2005}