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