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