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