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