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