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