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