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