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