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