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