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