Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
232624b1 | 4 | | CiviCRM version 4.4 | |
6a488035 TO |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 | |
31 | * @copyright CiviCRM LLC (c) 2004-2013 | |
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 | |
40 | CONST DASHBOARD_BELOW = 1; | |
41 | // Place content above activity list | |
42 | CONST DASHBOARD_ABOVE = 2; | |
43 | // Don't display activity list at all | |
44 | CONST DASHBOARD_REPLACE = 3; | |
45 | ||
46 | // by default - place content below existing content | |
47 | CONST SUMMARY_BELOW = 1; | |
48 | // pace hook content above | |
49 | CONST SUMMARY_ABOVE = 2; | |
50 | // create your own summarys | |
51 | CONST SUMMARY_REPLACE = 3; | |
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 | * | |
77 | * @return instance of $config->userHookClass | |
78 | */ | |
79 | static function singleton($fresh = FALSE) { | |
80 | if (self::$_singleton == NULL || $fresh) { | |
81 | $config = CRM_Core_Config::singleton(); | |
82 | $class = $config->userHookClass; | |
83 | require_once (str_replace('_', DIRECTORY_SEPARATOR, $config->userHookClass) . '.php'); | |
84 | self::$_singleton = new $class(); | |
85 | } | |
86 | return self::$_singleton; | |
87 | } | |
88 | ||
89 | abstract function invoke($numParams, | |
87dab4a4 | 90 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, |
6a488035 TO |
91 | $fnSuffix |
92 | ); | |
93 | ||
6a488035 | 94 | function commonInvoke($numParams, |
87dab4a4 | 95 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, |
6a488035 TO |
96 | $fnSuffix, $fnPrefix |
97 | ) { | |
98 | ||
99 | $this->commonBuildModuleList($fnPrefix); | |
4636d4fd | 100 | |
6a488035 | 101 | return $this->runHooks($this->commonCiviModules, $fnSuffix, |
87dab4a4 | 102 | $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6 |
6a488035 TO |
103 | ); |
104 | } | |
105 | ||
106 | /** | |
107 | * Build the list of modules to be processed for hooks. | |
108 | */ | |
109 | function commonBuildModuleList($fnPrefix) { | |
110 | if (!$this->commonIncluded) { | |
111 | // include external file | |
112 | $this->commonIncluded = TRUE; | |
113 | ||
114 | $config = CRM_Core_Config::singleton(); | |
115 | if (!empty($config->customPHPPathDir) && | |
116 | file_exists("{$config->customPHPPathDir}/civicrmHooks.php") | |
117 | ) { | |
118 | @include_once ("civicrmHooks.php"); | |
119 | } | |
120 | ||
121 | if (!empty($fnPrefix)) { | |
122 | $this->commonCiviModules[$fnPrefix] = $fnPrefix; | |
123 | } | |
124 | ||
125 | $this->requireCiviModules($this->commonCiviModules); | |
126 | } | |
127 | } | |
128 | ||
3ac9ab1c | 129 | function runHooks($civiModules, $fnSuffix, $numParams, |
87dab4a4 | 130 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6 |
6a488035 | 131 | ) { |
3ac9ab1c TO |
132 | // $civiModules is *not* passed by reference because runHooks |
133 | // must be reentrant. PHP is finicky about running | |
134 | // multiple loops over the same variable. The circumstances | |
135 | // to reproduce the issue are pretty intricate. | |
6a488035 TO |
136 | $result = $fResult = array(); |
137 | ||
4636d4fd DL |
138 | if ($civiModules !== NULL) { |
139 | foreach ($civiModules as $module) { | |
140 | $fnName = "{$module}_{$fnSuffix}"; | |
141 | if (function_exists($fnName)) { | |
142 | switch ($numParams) { | |
143 | case 0: | |
144 | $fResult = $fnName(); | |
145 | break; | |
146 | ||
147 | case 1: | |
148 | $fResult = $fnName($arg1); | |
149 | break; | |
150 | ||
151 | case 2: | |
152 | $fResult = $fnName($arg1, $arg2); | |
153 | break; | |
154 | ||
155 | case 3: | |
156 | $fResult = $fnName($arg1, $arg2, $arg3); | |
157 | break; | |
158 | ||
159 | case 4: | |
160 | $fResult = $fnName($arg1, $arg2, $arg3, $arg4); | |
161 | break; | |
162 | ||
163 | case 5: | |
164 | $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5); | |
165 | break; | |
166 | ||
87dab4a4 AH |
167 | case 6: |
168 | $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6); | |
169 | break; | |
170 | ||
4636d4fd DL |
171 | default: |
172 | CRM_Core_Error::fatal(ts('Invalid hook invocation')); | |
173 | break; | |
174 | } | |
6a488035 | 175 | } |
6a488035 | 176 | |
4636d4fd | 177 | if (!empty($fResult) && |
6a488035 | 178 | is_array($fResult)) { |
4636d4fd DL |
179 | $result = array_merge($result, $fResult); |
180 | } | |
6a488035 TO |
181 | } |
182 | } | |
183 | ||
184 | return empty($result) ? TRUE : $result; | |
185 | } | |
186 | ||
187 | function requireCiviModules(&$moduleList) { | |
188 | $civiModules = CRM_Core_PseudoConstant::getModuleExtensions(); | |
189 | foreach ($civiModules as $civiModule) { | |
190 | if (!file_exists($civiModule['filePath'])) { | |
191 | CRM_Core_Session::setStatus( | |
9399901d KJ |
192 | ts( 'Error loading module file (%1). Please restore the file or disable the module.', |
193 | array(1 => $civiModule['filePath']) ), | |
1393e47e | 194 | ts( 'Warning'), 'error'); |
6a488035 TO |
195 | continue; |
196 | } | |
197 | include_once $civiModule['filePath']; | |
198 | $moduleList[$civiModule['prefix']] = $civiModule['prefix']; | |
199 | } | |
200 | } | |
201 | ||
202 | /** | |
203 | * This hook is called before a db write on some core objects. | |
204 | * This hook does not allow the abort of the operation | |
205 | * | |
206 | * @param string $op the type of operation being performed | |
207 | * @param string $objectName the name of the object | |
208 | * @param object $id the object id if available | |
209 | * @param array $params the parameters used for object creation / editing | |
210 | * | |
211 | * @return null the return value is ignored | |
212 | * @access public | |
213 | */ | |
214 | static function pre($op, $objectName, $id, &$params) { | |
87dab4a4 | 215 | return self::singleton()->invoke(4, $op, $objectName, $id, $params, self::$_nullObject, self::$_nullObject, 'civicrm_pre'); |
6a488035 TO |
216 | } |
217 | ||
218 | /** | |
219 | * This hook is called after a db write on some core objects. | |
220 | * | |
221 | * @param string $op the type of operation being performed | |
222 | * @param string $objectName the name of the object | |
223 | * @param int $objectId the unique identifier for the object | |
224 | * @param object $objectRef the reference to the object if available | |
225 | * | |
226 | * @return mixed based on op. pre-hooks return a boolean or | |
227 | * an error message which aborts the operation | |
228 | * @access public | |
229 | */ | |
230 | static function post($op, $objectName, $objectId, &$objectRef) { | |
87dab4a4 | 231 | return self::singleton()->invoke(4, $op, $objectName, $objectId, $objectRef, self::$_nullObject, self::$_nullObject, 'civicrm_post'); |
6a488035 TO |
232 | } |
233 | ||
6a488035 TO |
234 | /** |
235 | * This hook retrieves links from other modules and injects it into | |
236 | * the view contact tabs | |
237 | * | |
238 | * @param string $op the type of operation being performed | |
239 | * @param string $objectName the name of the object | |
240 | * @param int $objectId the unique identifier for the object | |
87dab4a4 AH |
241 | * @param array $links (optional) the links array (introduced in v3.2) |
242 | * @param int $mask (optional) the bitmask to show/hide links | |
243 | * @param array $values (optional) the values to fill the links | |
6a488035 | 244 | * |
de8e002f | 245 | * @return null the return value is ignored |
6a488035 TO |
246 | * |
247 | * @access public | |
248 | */ | |
87dab4a4 AH |
249 | static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = array()) { |
250 | return self::singleton()->invoke(6, $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links'); | |
6a488035 TO |
251 | } |
252 | ||
253 | /** | |
254 | * This hook is invoked when building a CiviCRM form. This hook should also | |
255 | * be used to set the default values of a form element | |
256 | * | |
257 | * @param string $formName the name of the form | |
258 | * @param object $form reference to the form object | |
259 | * | |
260 | * @return null the return value is ignored | |
261 | */ | |
262 | static function buildForm($formName, &$form) { | |
87dab4a4 | 263 | return self::singleton()->invoke(2, $formName, $form, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_buildForm'); |
6a488035 TO |
264 | } |
265 | ||
266 | /** | |
267 | * This hook is invoked when a CiviCRM form is submitted. If the module has injected | |
268 | * any form elements, this hook should save the values in the database | |
269 | * | |
270 | * @param string $formName the name of the form | |
271 | * @param object $form reference to the form object | |
272 | * | |
273 | * @return null the return value is ignored | |
274 | */ | |
275 | static function postProcess($formName, &$form) { | |
87dab4a4 | 276 | return self::singleton()->invoke(2, $formName, $form, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_postProcess'); |
6a488035 TO |
277 | } |
278 | ||
279 | /** | |
280 | * This hook is invoked during all CiviCRM form validation. An array of errors | |
281 | * detected is returned. Else we assume validation succeeded. | |
282 | * | |
283 | * @param string $formName the name of the form | |
284 | * @param array &$fields the POST parameters as filtered by QF | |
285 | * @param array &$files the FILES parameters as sent in by POST | |
286 | * @param array &$form the form object | |
287 | * | |
288 | * @return mixed formRule hooks return a boolean or | |
289 | * an array of error messages which display a QF Error | |
290 | * @access public | |
291 | */ | |
292 | static function validate($formName, &$fields, &$files, &$form) { | |
87dab4a4 | 293 | return self::singleton()->invoke(4, $formName, $fields, $files, $form, self::$_nullObject, self::$_nullObject, 'civicrm_validate'); |
6a488035 TO |
294 | } |
295 | ||
296 | /** | |
297 | * This hook is invoked during all CiviCRM form validation. An array of errors | |
298 | * detected is returned. Else we assume validation succeeded. | |
299 | * | |
300 | * @param string $formName the name of the form | |
301 | * @param array &$fields the POST parameters as filtered by QF | |
302 | * @param array &$files the FILES parameters as sent in by POST | |
303 | * @param array &$form the form object | |
304 | * @param array &$errors the array of errors. | |
305 | * | |
306 | * @return mixed formRule hooks return a boolean or | |
307 | * an array of error messages which display a QF Error | |
308 | * @access public | |
309 | */ | |
310 | static function validateForm($formName, &$fields, &$files, &$form, &$errors) { | |
87dab4a4 | 311 | return self::singleton()->invoke(5, $formName, $fields, $files, $form, $errors, self::$_nullObject, 'civicrm_validateForm'); |
6a488035 TO |
312 | } |
313 | ||
314 | /** | |
315 | * This hook is called before a db write on a custom table | |
316 | * | |
317 | * @param string $op the type of operation being performed | |
318 | * @param string $groupID the custom group ID | |
319 | * @param object $entityID the entityID of the row in the custom table | |
320 | * @param array $params the parameters that were sent into the calling function | |
321 | * | |
322 | * @return null the return value is ignored | |
323 | * @access public | |
324 | */ | |
325 | static function custom($op, $groupID, $entityID, &$params) { | |
87dab4a4 | 326 | return self::singleton()->invoke(4, $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_custom'); |
6a488035 TO |
327 | } |
328 | ||
329 | /** | |
330 | * This hook is called when composing the ACL where clause to restrict | |
331 | * visibility of contacts to the logged in user | |
332 | * | |
333 | * @param int $type the type of permission needed | |
334 | * @param array $tables (reference ) add the tables that are needed for the select clause | |
335 | * @param array $whereTables (reference ) add the tables that are needed for the where clause | |
336 | * @param int $contactID the contactID for whom the check is made | |
337 | * @param string $where the currrent where clause | |
338 | * | |
339 | * @return null the return value is ignored | |
340 | * @access public | |
341 | */ | |
342 | static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) { | |
87dab4a4 | 343 | return self::singleton()->invoke(5, $type, $tables, $whereTables, $contactID, $where, self::$_nullObject, 'civicrm_aclWhereClause'); |
6a488035 TO |
344 | } |
345 | ||
346 | /** | |
347 | * This hook is called when composing the ACL where clause to restrict | |
348 | * visibility of contacts to the logged in user | |
349 | * | |
350 | * @param int $type the type of permission needed | |
351 | * @param int $contactID the contactID for whom the check is made | |
352 | * @param string $tableName the tableName which is being permissioned | |
353 | * @param array $allGroups the set of all the objects for the above table | |
354 | * @param array $currentGroups the set of objects that are currently permissioned for this contact | |
355 | * | |
356 | * @return null the return value is ignored | |
357 | * @access public | |
358 | */ | |
359 | static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) { | |
87dab4a4 | 360 | return self::singleton()->invoke(5, $type, $contactID, $tableName, $allGroups, $currentGroups, self::$_nullObject, 'civicrm_aclGroup'); |
6a488035 TO |
361 | } |
362 | ||
363 | /** | |
364 | * This hook is called when building the menu table | |
365 | * | |
366 | * @param array $files The current set of files to process | |
367 | * | |
368 | * @return null the return value is ignored | |
369 | * @access public | |
370 | */ | |
371 | static function xmlMenu(&$files) { | |
372 | return self::singleton()->invoke(1, $files, | |
87dab4a4 | 373 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
374 | 'civicrm_xmlMenu' |
375 | ); | |
376 | } | |
377 | ||
378 | /** | |
379 | * This hook is called for declaring managed entities via API | |
380 | * | |
381 | * @param array $entities List of pending entities | |
382 | * | |
383 | * @return null the return value is ignored | |
384 | * @access public | |
385 | */ | |
386 | static function managed(&$entities) { | |
387 | return self::singleton()->invoke(1, $entities, | |
87dab4a4 | 388 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
389 | 'civicrm_managed' |
390 | ); | |
391 | } | |
392 | ||
393 | /** | |
394 | * This hook is called when rendering the dashboard (q=civicrm/dashboard) | |
395 | * | |
396 | * @param int $contactID - the contactID for whom the dashboard is being rendered | |
9399901d KJ |
397 | * @param int $contentPlacement - (output parameter) where should the hook content be displayed |
398 | * relative to the activity list | |
6a488035 TO |
399 | * |
400 | * @return string the html snippet to include in the dashboard | |
401 | * @access public | |
402 | */ | |
403 | static function dashboard($contactID, &$contentPlacement = self::DASHBOARD_BELOW) { | |
404 | $retval = self::singleton()->invoke(2, $contactID, $contentPlacement, | |
87dab4a4 | 405 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
406 | 'civicrm_dashboard' |
407 | ); | |
408 | ||
409 | /* | |
410 | * Note we need this seemingly unnecessary code because in the event that the implementation | |
411 | * of the hook declares the second parameter but doesn't set it, then it comes back unset even | |
412 | * though we have a default value in this function's declaration above. | |
413 | */ | |
414 | if (!isset($contentPlacement)) { | |
415 | $contentPlacement = self::DASHBOARD_BELOW; | |
416 | } | |
417 | ||
418 | return $retval; | |
419 | } | |
420 | ||
421 | /** | |
422 | * This hook is called before storing recently viewed items. | |
423 | * | |
424 | * @param array $recentArray - an array of recently viewed or processed items, for in place modification | |
425 | * | |
426 | * @return array | |
427 | * @access public | |
428 | */ | |
429 | static function recent(&$recentArray) { | |
430 | return self::singleton()->invoke(1, $recentArray, | |
87dab4a4 | 431 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
432 | 'civicrm_recent' |
433 | ); | |
434 | } | |
435 | ||
436 | /** | |
437 | * This hook is called when building the amount structure for a Contribution or Event Page | |
438 | * | |
439 | * @param int $pageType - is this a contribution or event page | |
440 | * @param object $form - reference to the form object | |
441 | * @param array $amount - the amount structure to be displayed | |
442 | * | |
443 | * @return null | |
444 | * @access public | |
445 | */ | |
446 | static function buildAmount($pageType, &$form, &$amount) { | |
9399901d | 447 | return self::singleton()->invoke(3, $pageType, $form, $amount, self::$_nullObject, |
87dab4a4 | 448 | self::$_nullObject, self::$_nullObject, 'civicrm_buildAmount'); |
6a488035 TO |
449 | } |
450 | ||
451 | /** | |
452 | * This hook is called when building the state list for a particular country. | |
453 | * | |
454 | * @param array $countryID - the country id whose states are being selected. | |
455 | * | |
456 | * @return null | |
457 | * @access public | |
458 | */ | |
459 | static function buildStateProvinceForCountry($countryID, &$states) { | |
460 | return self::singleton()->invoke(2, $countryID, $states, | |
87dab4a4 | 461 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
462 | 'civicrm_buildStateProvinceForCountry' |
463 | ); | |
464 | } | |
465 | ||
466 | /** | |
467 | * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c | |
468 | * | |
469 | * @param array $tabs - the array of tabs that will be displayed | |
470 | * @param int $contactID - the contactID for whom the dashboard is being rendered | |
471 | * | |
472 | * @return null | |
473 | * @access public | |
474 | */ | |
475 | static function tabs(&$tabs, $contactID) { | |
476 | return self::singleton()->invoke(2, $tabs, $contactID, | |
87dab4a4 | 477 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tabs' |
6a488035 TO |
478 | ); |
479 | } | |
480 | ||
fa3dbfbd | 481 | /** |
e91083ac | 482 | * This hook is called when rendering the tabs |
483 | * used for events and potentially contribution pages, etc | |
484 | * @param string $tabset - name of the screen or visual element | |
2efcf0c2 | 485 | * @param array $tabs - the array of tabs that will be displayed |
e91083ac | 486 | * @param array $context - extra data about the screen or context in which the tab is used |
fa3dbfbd | 487 | * |
2efcf0c2 | 488 | * @return null |
fa3dbfbd | 489 | * @access public |
490 | */ | |
379a8439 | 491 | static function tabset($tabsetName, &$tabs, $context) { |
492 | return self::singleton()->invoke(3, $tabsetName, $tabs, | |
87dab4a4 | 493 | $context, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tabset' |
fa3dbfbd | 494 | ); |
495 | } | |
496 | ||
6a488035 TO |
497 | /** |
498 | * This hook is called when sending an email / printing labels | |
499 | * | |
500 | * @param array $tokens - the list of tokens that can be used for the contact | |
501 | * | |
502 | * @return null | |
503 | * @access public | |
504 | */ | |
505 | static function tokens(&$tokens) { | |
506 | return self::singleton()->invoke(1, $tokens, | |
87dab4a4 | 507 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tokens' |
6a488035 TO |
508 | ); |
509 | } | |
510 | ||
511 | /** | |
512 | * This hook is called when sending an email / printing labels to get the values for all the | |
513 | * tokens returned by the 'tokens' hook | |
514 | * | |
515 | * @param array $details - the array to store the token values indexed by contactIDs (unless it a single) | |
516 | * @param array $contactIDs - an array of contactIDs | |
517 | * @param int $jobID - the jobID if this is associated with a CiviMail mailing | |
518 | * @param array $tokens - the list of tokens associated with the content | |
519 | * @param string $className - the top level className from where the hook is invoked | |
520 | * | |
521 | * @return null | |
522 | * @access public | |
523 | */ | |
524 | static function tokenValues(&$details, | |
525 | $contactIDs, | |
526 | $jobID = NULL, | |
527 | $tokens = array(), | |
528 | $className = NULL | |
529 | ) { | |
87dab4a4 | 530 | return self::singleton()->invoke(5, $details, $contactIDs, $jobID, $tokens, $className, self::$_nullObject, 'civicrm_tokenValues'); |
6a488035 TO |
531 | } |
532 | ||
533 | /** | |
534 | * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables | |
535 | * in a template | |
536 | * | |
537 | * @param object $page - the page that will be rendered | |
538 | * | |
539 | * @return null | |
540 | * @access public | |
541 | */ | |
542 | static function pageRun(&$page) { | |
543 | return self::singleton()->invoke(1, $page, | |
87dab4a4 | 544 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
545 | 'civicrm_pageRun' |
546 | ); | |
547 | } | |
548 | ||
549 | /** | |
550 | * This hook is called after a copy of an object has been made. The current objects are | |
551 | * Event, Contribution Page and UFGroup | |
552 | * | |
553 | * @param string $objectName - name of the object | |
554 | * @param object $object - reference to the copy | |
555 | * | |
556 | * @return null | |
557 | * @access public | |
558 | */ | |
559 | static function copy($objectName, &$object) { | |
560 | return self::singleton()->invoke(2, $objectName, $object, | |
87dab4a4 | 561 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
562 | 'civicrm_copy' |
563 | ); | |
564 | } | |
565 | ||
566 | /** | |
567 | * This hook is called when a contact unsubscribes from a mailing. It allows modules | |
568 | * to override what the contacts are removed from. | |
569 | * | |
dcbd3a55 | 570 | * @param string $op - ignored for now |
6a488035 TO |
571 | * @param int $mailing_id - the id of the mailing to unsub from |
572 | * @param int $contact_id - the id of the contact who is unsubscribing | |
573 | * @param array / int $groups - array of groups the contact will be removed from | |
dcbd3a55 DL |
574 | * @param array / int $baseGroups - array of base groups (used in smart mailings) the contact will be removed from |
575 | * | |
6a488035 TO |
576 | **/ |
577 | static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) { | |
87dab4a4 | 578 | return self::singleton()->invoke(5, $op, $mailingId, $contactId, $groups, $baseGroups, self::$_nullObject, 'civicrm_unsubscribeGroups'); |
6a488035 TO |
579 | } |
580 | ||
581 | /** | |
9399901d KJ |
582 | * This hook is called when CiviCRM needs to edit/display a custom field with options (select, radio, checkbox, |
583 | * adv multiselect) | |
6a488035 TO |
584 | * |
585 | * @param int $customFieldID - the custom field ID | |
586 | * @param array $options - the current set of options for that custom field. | |
587 | * You can add/remove existing options. | |
9399901d KJ |
588 | * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important |
589 | * to be careful to not overwrite the array. | |
6a488035 | 590 | * Only add/edit/remove the specific field options you intend to affect. |
9399901d KJ |
591 | * @param boolean $detailedFormat - if true, |
592 | * the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format | |
6a488035 TO |
593 | */ |
594 | static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE) { | |
595 | return self::singleton()->invoke(3, $customFieldID, $options, $detailedFormat, | |
87dab4a4 | 596 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
597 | 'civicrm_customFieldOptions' |
598 | ); | |
599 | } | |
600 | ||
601 | /** | |
602 | * | |
603 | * This hook is called to display the list of actions allowed after doing a search. | |
604 | * This allows the module developer to inject additional actions or to remove existing actions. | |
605 | * | |
606 | * @param string $objectType - the object type for this search | |
607 | * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported. | |
608 | * @param array $tasks - the current set of tasks for that custom field. | |
609 | * You can add/remove existing tasks. | |
9399901d KJ |
610 | * Each task needs to have a title (eg 'title' => ts( 'Add Contacts to Group')) and a class |
611 | * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup'). | |
6a488035 | 612 | * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ). |
9399901d KJ |
613 | * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be |
614 | * found in CRM/$objectType/Task.php. | |
6a488035 TO |
615 | */ |
616 | static function searchTasks($objectType, &$tasks) { | |
617 | return self::singleton()->invoke(2, $objectType, $tasks, | |
87dab4a4 | 618 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
619 | 'civicrm_searchTasks' |
620 | ); | |
621 | } | |
622 | ||
623 | static function eventDiscount(&$form, &$params) { | |
624 | return self::singleton()->invoke(2, $form, $params, | |
87dab4a4 | 625 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
626 | 'civicrm_eventDiscount' |
627 | ); | |
628 | } | |
629 | ||
630 | /** | |
631 | * This hook is called when composing a mailing. You can include / exclude other groups as needed. | |
632 | * | |
633 | * @param unknown_type $form - the form object for which groups / mailings being displayed | |
634 | * @param array $groups - the list of groups being included / excluded | |
635 | * @param array $mailings - the list of mailings being included / excluded | |
636 | */ | |
637 | static function mailingGroups(&$form, &$groups, &$mailings) { | |
638 | return self::singleton()->invoke(3, $form, $groups, $mailings, | |
87dab4a4 | 639 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
640 | 'civicrm_mailingGroups' |
641 | ); | |
642 | } | |
643 | ||
644 | /** | |
9399901d KJ |
645 | * This hook is called when composing the array of membershipTypes and their cost during a membership registration |
646 | * (new or renewal). | |
6a488035 TO |
647 | * Note the hook is called on initial page load and also reloaded after submit (PRG pattern). |
648 | * You can use it to alter the membership types when first loaded, or after submission | |
649 | * (for example if you want to gather data in the form and use it to alter the fees). | |
650 | * | |
651 | * @param unknown_type $form - the form object that is presenting the page | |
652 | * @param array $membershipTypes - the array of membership types and their amount | |
653 | */ | |
654 | static function membershipTypeValues(&$form, &$membershipTypes) { | |
655 | return self::singleton()->invoke(2, $form, $membershipTypes, | |
87dab4a4 | 656 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
657 | 'civicrm_membershipTypeValues' |
658 | ); | |
659 | } | |
660 | ||
661 | /** | |
662 | * This hook is called when rendering the contact summary | |
663 | * | |
664 | * @param int $contactID - the contactID for whom the summary is being rendered | |
9399901d KJ |
665 | * @param int $contentPlacement - (output parameter) where should the hook content be displayed relative to |
666 | * the existing content | |
6a488035 TO |
667 | * |
668 | * @return string the html snippet to include in the contact summary | |
669 | * @access public | |
670 | */ | |
671 | static function summary($contactID, &$content, &$contentPlacement = self::SUMMARY_BELOW) { | |
672 | return self::singleton()->invoke(3, $contactID, $content, $contentPlacement, | |
87dab4a4 | 673 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
674 | 'civicrm_summary' |
675 | ); | |
676 | } | |
677 | ||
678 | /** | |
679 | * Use this hook to populate the list of contacts returned by Contact Reference custom fields. | |
680 | * By default, Contact Reference fields will search on and return all CiviCRM contacts. | |
681 | * If you want to limit the contacts returned to a specific group, or some other criteria | |
682 | * - you can override that behavior by providing a SQL query that returns some subset of your contacts. | |
683 | * The hook is called when the query is executed to get the list of contacts to display. | |
684 | * | |
685 | * @param unknown_type $query - - the query that will be executed (input and output parameter); | |
686 | * It's important to realize that the ACL clause is built prior to this hook being fired, | |
687 | * so your query will ignore any ACL rules that may be defined. | |
688 | * Your query must return two columns: | |
689 | * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data') | |
690 | * the contact IDs | |
691 | * @param string $name - the name string to execute the query against (this is the value being typed in by the user) | |
692 | * @param string $context - the context in which this ajax call is being made (for example: 'customfield', 'caseview') | |
693 | * @param int $id - the id of the object for which the call is being made. | |
694 | * For custom fields, it will be the custom field id | |
695 | */ | |
696 | static function contactListQuery(&$query, $name, $context, $id) { | |
697 | return self::singleton()->invoke(4, $query, $name, $context, $id, | |
87dab4a4 | 698 | self::$_nullObject, self::$_nullObject, |
6a488035 TO |
699 | 'civicrm_contactListQuery' |
700 | ); | |
701 | } | |
702 | ||
703 | /** | |
704 | * Hook definition for altering payment parameters before talking to a payment processor back end. | |
705 | * | |
706 | * Definition will look like this: | |
707 | * | |
708 | * function hook_civicrm_alterPaymentProcessorParams($paymentObj, | |
709 | * &$rawParams, &$cookedParams); | |
710 | * | |
711 | * @param string $paymentObj | |
712 | * instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy') | |
713 | * @param array &$rawParams | |
714 | * array of params as passed to to the processor | |
715 | * @params array &$cookedParams | |
716 | * params after the processor code has translated them into its own key/value pairs | |
717 | * | |
718 | * @return void | |
719 | */ | |
720 | static function alterPaymentProcessorParams($paymentObj, | |
721 | &$rawParams, | |
722 | &$cookedParams | |
723 | ) { | |
724 | return self::singleton()->invoke(3, $paymentObj, $rawParams, $cookedParams, | |
87dab4a4 | 725 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
726 | 'civicrm_alterPaymentProcessorParams' |
727 | ); | |
728 | } | |
729 | ||
730 | /** | |
731 | * This hook is called when an email is about to be sent by CiviCRM. | |
732 | * | |
9399901d KJ |
733 | * @param array $params - array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html, |
734 | * returnPath, replyTo, headers, attachments (array) | |
6a488035 TO |
735 | * @param string $context - the context in which the hook is being invoked, eg 'civimail' |
736 | */ | |
737 | static function alterMailParams(&$params, $context = NULL) { | |
738 | return self::singleton()->invoke(2, $params, $context, | |
87dab4a4 | 739 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
740 | 'civicrm_alterMailParams' |
741 | ); | |
742 | } | |
743 | ||
744 | /** | |
745 | * This hook is called when rendering the Manage Case screen | |
746 | * | |
747 | * @param int $caseID - the case ID | |
748 | * | |
9399901d KJ |
749 | * @return array of data to be displayed, where the key is a unique id to be used for styling (div id's) |
750 | * and the value is an array with keys 'label' and 'value' specifying label/value pairs | |
6a488035 TO |
751 | * @access public |
752 | */ | |
753 | static function caseSummary($caseID) { | |
754 | return self::singleton()->invoke(1, $caseID, | |
87dab4a4 | 755 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
756 | 'civicrm_caseSummary' |
757 | ); | |
758 | } | |
759 | ||
6b86870e TO |
760 | /** |
761 | * This hook is called when locating CiviCase types. | |
762 | * | |
763 | * @param array $caseTypes | |
764 | * @return void | |
765 | */ | |
766 | static function caseTypes(&$caseTypes) { | |
87dab4a4 | 767 | return self::singleton()->invoke(1, $caseTypes, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_caseTypes'); |
6b86870e TO |
768 | } |
769 | ||
6a488035 TO |
770 | /** |
771 | * This hook is called soon after the CRM_Core_Config object has ben initialized. | |
772 | * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically. | |
773 | ||
774 | * @param array $config - the config object | |
775 | */ | |
776 | static function config(&$config) { | |
777 | return self::singleton()->invoke(1, $config, | |
87dab4a4 | 778 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
779 | 'civicrm_config' |
780 | ); | |
781 | } | |
782 | ||
783 | static function enableDisable($recordBAO, $recordID, $isActive) { | |
784 | return self::singleton()->invoke(3, $recordBAO, $recordID, $isActive, | |
87dab4a4 | 785 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
786 | 'civicrm_enableDisable' |
787 | ); | |
788 | } | |
789 | ||
790 | /** | |
791 | * This hooks allows to change option values | |
792 | * | |
793 | * @param $options associated array of option values / id | |
794 | * @param $name option group name | |
795 | * | |
796 | * @access public | |
797 | */ | |
798 | static function optionValues(&$options, $name) { | |
799 | return self::singleton()->invoke(2, $options, $name, | |
87dab4a4 | 800 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
801 | 'civicrm_optionValues' |
802 | ); | |
803 | } | |
804 | ||
805 | /** | |
806 | * This hook allows modification of the navigation menu. | |
807 | * | |
808 | * @param $params associated array of navigation menu entry to Modify/Add | |
809 | * @access public | |
810 | */ | |
811 | static function navigationMenu(&$params) { | |
812 | return self::singleton()->invoke(1, $params, | |
87dab4a4 | 813 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
814 | 'civicrm_navigationMenu' |
815 | ); | |
816 | } | |
817 | ||
818 | /** | |
819 | * This hook allows modification of the data used to perform merging of duplicates. | |
820 | * | |
821 | * @param string $type the type of data being passed (cidRefs|eidRefs|relTables|sqls) | |
822 | * @param array $data the data, as described in $type | |
823 | * @param int $mainId contact_id of the contact that survives the merge | |
824 | * @param int $otherId contact_id of the contact that will be absorbed and deleted | |
825 | * @param array $tables when $type is "sqls", an array of tables as it may have been handed to the calling function | |
826 | * | |
827 | * @access public | |
828 | */ | |
829 | static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) { | |
87dab4a4 | 830 | return self::singleton()->invoke(5, $type, $data, $mainId, $otherId, $tables, self::$_nullObject, 'civicrm_merge'); |
6a488035 TO |
831 | } |
832 | ||
833 | /** | |
834 | * This hook provides a way to override the default privacy behavior for notes. | |
835 | * | |
836 | * @param array $note (reference) Associative array of values for this note | |
837 | * | |
838 | * @access public | |
839 | */ | |
840 | static function notePrivacy(&$noteValues) { | |
841 | return self::singleton()->invoke(1, $noteValues, | |
87dab4a4 | 842 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
843 | 'civicrm_notePrivacy' |
844 | ); | |
845 | } | |
846 | ||
847 | /** | |
848 | * This hook is called before record is exported as CSV | |
849 | * | |
850 | * @param string $exportTempTable - name of the temporary export table used during export | |
851 | * @param array $headerRows - header rows for output | |
852 | * @param array $sqlColumns - SQL columns | |
853 | * @param int $exportMode - export mode ( contact, contribution, etc...) | |
854 | * | |
855 | * @return void | |
856 | * @access public | |
857 | */ | |
858 | static function export(&$exportTempTable, &$headerRows, &$sqlColumns, &$exportMode) { | |
859 | return self::singleton()->invoke(4, $exportTempTable, $headerRows, $sqlColumns, $exportMode, | |
87dab4a4 | 860 | self::$_nullObject, self::$_nullObject, |
6a488035 TO |
861 | 'civicrm_export' |
862 | ); | |
863 | } | |
864 | ||
865 | /** | |
866 | * This hook allows modification of the queries constructed from dupe rules. | |
867 | * | |
868 | * @param string $obj object of rulegroup class | |
869 | * @param string $type type of queries e.g table / threshold | |
870 | * @param array $query set of queries | |
871 | * | |
872 | * @access public | |
873 | */ | |
874 | static function dupeQuery($obj, $type, &$query) { | |
875 | return self::singleton()->invoke(3, $obj, $type, $query, | |
87dab4a4 | 876 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
877 | 'civicrm_dupeQuery' |
878 | ); | |
879 | } | |
880 | ||
881 | /** | |
882 | * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php | |
883 | * | |
884 | * @param string $type type of mail processed: 'activity' OR 'mailing' | |
885 | * @param array &$params the params that were sent to the CiviCRM API function | |
886 | * @param object $mail the mail object which is an ezcMail class | |
887 | * @param array &$result the result returned by the api call | |
888 | * @param string $action (optional ) the requested action to be performed if the types was 'mailing' | |
889 | * | |
890 | * @access public | |
891 | */ | |
892 | static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) { | |
87dab4a4 | 893 | return self::singleton()->invoke(5, $type, $params, $mail, $result, $action, self::$_nullObject, 'civicrm_emailProcessor'); |
6a488035 TO |
894 | } |
895 | ||
896 | /** | |
897 | * This hook is called after a row has been processed and the | |
898 | * record (and associated records imported | |
899 | * | |
9399901d KJ |
900 | * @param string $object - object being imported (for now Contact only, later Contribution, Activity, |
901 | * Participant and Member) | |
6a488035 TO |
902 | * @param string $usage - hook usage/location (for now process only, later mapping and others) |
903 | * @param string $objectRef - import record object | |
904 | * @param array $params - array with various key values: currently | |
905 | * contactID - contact id | |
906 | * importID - row id in temp table | |
907 | * importTempTable - name of tempTable | |
908 | * fieldHeaders - field headers | |
909 | * fields - import fields | |
910 | * | |
911 | * @return void | |
912 | * @access public | |
913 | */ | |
914 | static function import($object, $usage, &$objectRef, &$params) { | |
915 | return self::singleton()->invoke(4, $object, $usage, $objectRef, $params, | |
87dab4a4 | 916 | self::$_nullObject, self::$_nullObject, |
6a488035 TO |
917 | 'civicrm_import' |
918 | ); | |
919 | } | |
920 | ||
921 | /** | |
922 | * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission() | |
aa5ba569 | 923 | * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php). |
6a488035 TO |
924 | * |
925 | * @param string $entity the API entity (like contact) | |
926 | * @param string $action the API action (like get) | |
927 | * @param array &$params the API parameters | |
928 | * @param array &$permisisons the associative permissions array (probably to be altered by this hook) | |
929 | */ | |
930 | static function alterAPIPermissions($entity, $action, &$params, &$permissions) { | |
931 | return self::singleton()->invoke(4, $entity, $action, $params, $permissions, | |
87dab4a4 | 932 | self::$_nullObject, self::$_nullObject, |
6a488035 TO |
933 | 'civicrm_alterAPIPermissions' |
934 | ); | |
935 | } | |
936 | ||
937 | static function postSave(&$dao) { | |
938 | $hookName = 'civicrm_postSave_' . $dao->getTableName(); | |
939 | return self::singleton()->invoke(1, $dao, | |
87dab4a4 | 940 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
941 | $hookName |
942 | ); | |
943 | } | |
944 | ||
945 | /** | |
946 | * This hook allows user to customize context menu Actions on contact summary page. | |
947 | * | |
948 | * @param array $actions Array of all Actions in contextmenu. | |
949 | * @param int $contactID ContactID for the summary page | |
950 | */ | |
951 | static function summaryActions(&$actions, $contactID = NULL) { | |
952 | return self::singleton()->invoke(2, $actions, $contactID, | |
87dab4a4 | 953 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
954 | 'civicrm_summaryActions' |
955 | ); | |
956 | } | |
957 | ||
958 | /** | |
959 | * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go. | |
960 | * This enables us hook implementors to modify both the headers and the rows | |
961 | * | |
962 | * The BIGGEST drawback with this hook is that you may need to modify the result template to include your | |
963 | * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl | |
964 | * | |
965 | * However, if you use the same number of columns, you can overwrite the existing columns with the values that | |
966 | * you want displayed. This is a hackish, but avoids template modification. | |
967 | * | |
968 | * @param string $objectName the component name that we are doing the search | |
969 | * activity, campaign, case, contact, contribution, event, grant, membership, and pledge | |
970 | * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order ) | |
971 | * @param array &$rows the list of values, an associate array with fields that are displayed for that component | |
972 | * @param array &$seletor the selector object. Allows you access to the context of the search | |
973 | * | |
974 | * @return void modify the header and values object to pass the data u need | |
975 | */ | |
976 | static function searchColumns($objectName, &$headers, &$rows, &$selector) { | |
977 | return self::singleton()->invoke(4, $objectName, $headers, $rows, $selector, | |
87dab4a4 | 978 | self::$_nullObject, self::$_nullObject, |
6a488035 TO |
979 | 'civicrm_searchColumns' |
980 | ); | |
981 | } | |
982 | ||
983 | /** | |
984 | * This hook is called when uf groups are being built for a module. | |
985 | * | |
986 | * @param string $moduleName module name. | |
987 | * @param array $ufGroups array of ufgroups for a module. | |
988 | * | |
989 | * @return null | |
990 | * @access public | |
991 | */ | |
992 | static function buildUFGroupsForModule($moduleName, &$ufGroups) { | |
993 | return self::singleton()->invoke(2, $moduleName, $ufGroups, | |
87dab4a4 | 994 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
995 | 'civicrm_buildUFGroupsForModule' |
996 | ); | |
997 | } | |
998 | ||
999 | /** | |
1000 | * This hook is called when we are determining the contactID for a specific | |
1001 | * email address | |
1002 | * | |
1003 | * @param string $email the email address | |
1004 | * @param int $contactID the contactID that matches this email address, IF it exists | |
1005 | * @param array $result (reference) has two fields | |
1006 | * contactID - the new (or same) contactID | |
1007 | * action - 3 possible values: | |
9399901d KJ |
1008 | * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record |
1009 | * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID | |
1010 | * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address | |
6a488035 TO |
1011 | * |
1012 | * @return null | |
1013 | * @access public | |
1014 | */ | |
1015 | static function emailProcessorContact($email, $contactID, &$result) { | |
1016 | return self::singleton()->invoke(3, $email, $contactID, $result, | |
87dab4a4 | 1017 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1018 | 'civicrm_emailProcessorContact' |
1019 | ); | |
1020 | } | |
1021 | ||
1022 | /** | |
1023 | * Hook definition for altering the generation of Mailing Labels | |
1024 | * | |
1025 | * @param array $args an array of the args in the order defined for the tcpdf multiCell api call | |
1026 | * with the variable names below converted into string keys (ie $w become 'w' | |
1027 | * as the first key for $args) | |
1028 | * float $w Width of cells. If 0, they extend up to the right margin of the page. | |
1029 | * float $h Cell minimum height. The cell extends automatically if needed. | |
1030 | * string $txt String to print | |
1031 | * mixed $border Indicates if borders must be drawn around the cell block. The value can | |
1032 | * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or | |
1033 | * a string containing some or all of the following characters (in any order): | |
1034 | * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> | |
1035 | * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string: | |
1036 | * left align</li><li>C: center</li><li>R: right align</li><li>J: justification | |
1037 | * (default value when $ishtml=false)</li></ul> | |
1038 | * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0. | |
1039 | * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0: | |
1040 | * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul> | |
1041 | * float $x x position in user units | |
1042 | * float $y y position in user units | |
1043 | * boolean $reseth if true reset the last cell height (default true). | |
1044 | * int $stretch stretch carachter mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if | |
1045 | * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if | |
1046 | * necessary</li><li>4 = forced character spacing</li></ul> | |
1047 | * boolean $ishtml set to true if $txt is HTML content (default = false). | |
1048 | * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width. | |
1049 | * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page, | |
1050 | * or 0 for disable this feature. This feature works only when $ishtml=false. | |
1051 | * | |
1052 | */ | |
1053 | static function alterMailingLabelParams(&$args) { | |
1054 | return self::singleton()->invoke(1, $args, | |
1055 | self::$_nullObject, self::$_nullObject, | |
87dab4a4 | 1056 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1057 | 'civicrm_alterMailingLabelParams' |
1058 | ); | |
1059 | } | |
1060 | ||
1061 | /** | |
1062 | * This hooks allows alteration of generated page content | |
1063 | * | |
1064 | * @param $content previously generated content | |
1065 | * @param $context context of content - page or form | |
1066 | * @param $tplName the file name of the tpl | |
1067 | * @param $object a reference to the page or form object | |
1068 | * | |
1069 | * @access public | |
1070 | */ | |
1071 | static function alterContent(&$content, $context, $tplName, &$object) { | |
1072 | return self::singleton()->invoke(4, $content, $context, $tplName, $object, | |
87dab4a4 | 1073 | self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1074 | 'civicrm_alterContent' |
1075 | ); | |
1076 | } | |
1077 | ||
8aac22c8 | 1078 | /** |
1079 | * This hooks allows alteration of the tpl file used to generate content. It differs from the | |
1080 | * altercontent hook as the content has already been rendered through the tpl at that point | |
1081 | * | |
1082 | * @param $formName previously generated content | |
1083 | * @param $form reference to the form object | |
1084 | * @param $context context of content - page or form | |
1085 | * @param $tplName reference the file name of the tpl | |
1086 | * | |
1087 | * @access public | |
1088 | */ | |
1089 | static function alterTemplateFile($formName, &$form, $context, &$tplName) { | |
1090 | return self::singleton()->invoke(4, $formName, $form, $context, $tplName, | |
87dab4a4 | 1091 | self::$_nullObject, self::$_nullObject, |
8aac22c8 | 1092 | 'civicrm_alterTemplateFile' |
1093 | ); | |
1094 | } | |
6a488035 TO |
1095 | /** |
1096 | * This hook collects the trigger definition from all components | |
1097 | * | |
1098 | * @param $triggerInfo reference to an array of trigger information | |
1099 | * each element has 4 fields: | |
1100 | * table - array of tableName | |
1101 | * when - BEFORE or AFTER | |
1102 | * event - array of eventName - INSERT OR UPDATE OR DELETE | |
1103 | * sql - array of statements optionally terminated with a ; | |
1104 | * a statement can use the tokes {tableName} and {eventName} | |
1105 | * to do token replacement with the table / event. This allows | |
1106 | * templatizing logging and other hooks | |
1107 | * @param string $tableName (optional) the name of the table that we are interested in only | |
1108 | */ | |
1109 | static function triggerInfo(&$info, $tableName = NULL) { | |
1110 | return self::singleton()->invoke(2, $info, $tableName, | |
87dab4a4 | 1111 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1112 | self::$_nullObject, |
1113 | 'civicrm_triggerInfo' | |
1114 | ); | |
1115 | } | |
1116 | ||
1117 | /** | |
1118 | * This hook is called when a module-extension is installed. | |
9399901d KJ |
1119 | * Each module will receive hook_civicrm_install during its own installation (but not during the |
1120 | * installation of unrelated modules). | |
6a488035 TO |
1121 | */ |
1122 | static function install() { | |
1123 | return self::singleton()->invoke(0, self::$_nullObject, | |
1124 | self::$_nullObject, self::$_nullObject, | |
87dab4a4 | 1125 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1126 | 'civicrm_install' |
1127 | ); | |
1128 | } | |
1129 | ||
1130 | /** | |
1131 | * This hook is called when a module-extension is uninstalled. | |
9399901d KJ |
1132 | * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the |
1133 | * uninstallation of unrelated modules). | |
6a488035 TO |
1134 | */ |
1135 | static function uninstall() { | |
1136 | return self::singleton()->invoke(0, self::$_nullObject, | |
1137 | self::$_nullObject, self::$_nullObject, | |
87dab4a4 | 1138 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1139 | 'civicrm_uninstall' |
1140 | ); | |
1141 | } | |
1142 | ||
1143 | /** | |
1144 | * This hook is called when a module-extension is re-enabled. | |
9399901d KJ |
1145 | * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the |
1146 | * re-enablement of unrelated modules). | |
6a488035 TO |
1147 | */ |
1148 | static function enable() { | |
1149 | return self::singleton()->invoke(0, self::$_nullObject, | |
1150 | self::$_nullObject, self::$_nullObject, | |
87dab4a4 | 1151 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1152 | 'civicrm_enable' |
1153 | ); | |
1154 | } | |
1155 | ||
1156 | /** | |
1157 | * This hook is called when a module-extension is disabled. | |
9399901d KJ |
1158 | * Each module will receive hook_civicrm_disable during its own disablement (but not during the |
1159 | * disablement of unrelated modules). | |
6a488035 TO |
1160 | */ |
1161 | static function disable() { | |
1162 | return self::singleton()->invoke(0, self::$_nullObject, | |
1163 | self::$_nullObject, self::$_nullObject, | |
87dab4a4 | 1164 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1165 | 'civicrm_disable' |
1166 | ); | |
1167 | } | |
1168 | ||
1169 | static function alterReportVar($varType, &$var, &$object) { | |
1170 | return self::singleton()->invoke(3, $varType, $var, $object, | |
1171 | self::$_nullObject, | |
87dab4a4 | 1172 | self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1173 | 'civicrm_alterReportVar' |
1174 | ); | |
1175 | } | |
1176 | ||
1177 | /** | |
1178 | * This hook is called to drive database upgrades for extension-modules. | |
1179 | * | |
1180 | * @param string $op the type of operation being performed; 'check' or 'enqueue' | |
1181 | * @param string $queue (for 'enqueue') the modifiable list of pending up upgrade tasks | |
1182 | * | |
1183 | * @return mixed based on op. 'check' returns a array(boolean) (TRUE if upgrades are pending) | |
1184 | * 'enqueue' returns void | |
1185 | * @access public | |
1186 | */ | |
1187 | static function upgrade($op, CRM_Queue_Queue $queue = NULL) { | |
1188 | return self::singleton()->invoke(2, $op, $queue, | |
87dab4a4 | 1189 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1190 | self::$_nullObject, |
1191 | 'civicrm_upgrade' | |
1192 | ); | |
1193 | } | |
1194 | ||
1195 | /** | |
1196 | * This hook is called when an email has been successfully sent by CiviCRM, but not on an error. | |
1197 | * | |
9399901d KJ |
1198 | * @param array $params - the mailing parameters array fields include: groupName, from, toName, toEmail, |
1199 | * subject, cc, bcc, text, html, returnPath, replyTo, headers, attachments (array) | |
6a488035 TO |
1200 | */ |
1201 | static function postEmailSend(&$params) { | |
1202 | return self::singleton()->invoke(1, $params, | |
1203 | self::$_nullObject, self::$_nullObject, | |
87dab4a4 | 1204 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1205 | 'civicrm_postEmailSend' |
1206 | ); | |
1207 | } | |
1208 | ||
1209 | /** | |
1210 | * This hook is called when Settings specifications are loaded | |
1211 | * | |
1212 | * @param array $settingsFolders - list of paths from which to derive metadata | |
1213 | */ | |
1214 | static function alterSettingsFolders(&$settingsFolders) { | |
1215 | return self::singleton()->invoke(1, $settingsFolders, | |
1216 | self::$_nullObject, self::$_nullObject, | |
87dab4a4 | 1217 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1218 | 'civicrm_alterSettingsFolders' |
1219 | ); | |
1220 | } | |
1221 | ||
1222 | /** | |
1223 | * This hook is called when Settings have been loaded from the xml | |
1224 | * It is an opportunity for hooks to alter the data | |
1225 | * | |
1226 | * @param array $settingsMetaData - Settings Metadata | |
1227 | * @domainID integer $domainID | |
1228 | */ | |
1229 | static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) { | |
1230 | return self::singleton()->invoke(3, $settingsMetaData, | |
1231 | $domainID, $profile, | |
87dab4a4 | 1232 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1233 | 'civicrm_alterSettingsMetaData' |
1234 | ); | |
1235 | } | |
1236 | ||
5270c026 XD |
1237 | /** |
1238 | * This hook is called before running an api call. | |
1239 | * | |
1240 | * @param $wrappers array of implements API_Wrapper(see CRM/Utils/API/ReloadOption.php as an example) | |
1241 | * | |
1242 | * @return null the return value is ignored | |
1243 | * @access public | |
1244 | */ | |
09f8c8dc TO |
1245 | static function apiWrappers(&$wrappers, $apiRequest) { |
1246 | return self::singleton() | |
1247 | ->invoke(2, $wrappers, $apiRequest, self::$_nullObject, self::$_nullObject, self::$_nullObject, | |
87dab4a4 | 1248 | self::$_nullObject, 'civicrm_apiWrappers' |
5270c026 XD |
1249 | ); |
1250 | } | |
1251 | ||
6a488035 TO |
1252 | /** |
1253 | * This hook is called before running pending cron jobs. | |
1254 | * | |
1255 | * @param CRM_Core_JobManager $jobManager | |
1256 | * | |
1257 | * @return null the return value is ignored | |
1258 | * @access public | |
1259 | */ | |
1260 | static function cron($jobManager) { | |
1261 | return self::singleton()->invoke(1, | |
87dab4a4 | 1262 | $jobManager, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1263 | 'civicrm_cron' |
1264 | ); | |
1265 | } | |
1266 | ||
1267 | /** | |
1268 | * This hook is called when loading CMS permissions; use this hook to modify | |
1269 | * the array of system permissions for CiviCRM. | |
1270 | * | |
1271 | * @param Array $permissions Array of permissions. See CRM_Core_Permission::getCorePermissions() | |
1272 | * for the format of this array. | |
1273 | * | |
1274 | * @return null the return value is ignored | |
1275 | * @access public | |
1276 | */ | |
1277 | static function permission(&$permissions) { | |
1278 | return self::singleton()->invoke(1, $permissions, | |
87dab4a4 | 1279 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
6a488035 TO |
1280 | 'civicrm_permission' |
1281 | ); | |
1282 | } | |
fed67e4d TO |
1283 | |
1284 | ||
1285 | /** | |
1286 | * This hook is called for declaring managed entities via API | |
1287 | * | |
1288 | * @param array $entities List of entity types; each entity-type is an array with keys: | |
1289 | * - name: string, a unique short name (e.g. "ReportInstance") | |
1290 | * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance") | |
1291 | * - table: string, a SQL table name (e.g. "civicrm_report_instance") | |
1292 | * | |
1293 | * @return null the return value is ignored | |
1294 | * @access public | |
1295 | */ | |
1296 | static function entityTypes(&$entityTypes) { | |
9399901d | 1297 | return self::singleton()->invoke(1, $entityTypes, self::$_nullObject, self::$_nullObject, |
87dab4a4 | 1298 | self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_entityTypes' |
fed67e4d TO |
1299 | ); |
1300 | } | |
a8387f19 TO |
1301 | |
1302 | /** | |
1303 | * This hook is called while preparing a profile form | |
1304 | * | |
1305 | * @param string $name | |
1306 | * @return void | |
1307 | */ | |
1308 | static function buildProfile($name) { | |
9399901d | 1309 | return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
87dab4a4 | 1310 | self::$_nullObject, self::$_nullObject, 'civicrm_buildProfile'); |
a8387f19 TO |
1311 | } |
1312 | ||
1313 | /** | |
1314 | * This hook is called while validating a profile form submission | |
1315 | * | |
1316 | * @param string $name | |
1317 | * @return void | |
1318 | */ | |
1319 | static function validateProfile($name) { | |
9399901d | 1320 | return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
87dab4a4 | 1321 | self::$_nullObject, self::$_nullObject, 'civicrm_validateProfile'); |
a8387f19 TO |
1322 | } |
1323 | ||
1324 | /** | |
1325 | * This hook is called processing a valid profile form submission | |
1326 | * | |
1327 | * @param string $name | |
1328 | * @return void | |
1329 | */ | |
1330 | static function processProfile($name) { | |
9399901d | 1331 | return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
87dab4a4 | 1332 | self::$_nullObject, self::$_nullObject, 'civicrm_processProfile'); |
a8387f19 TO |
1333 | } |
1334 | ||
1335 | /** | |
1336 | * This hook is called while preparing a read-only profile screen | |
1337 | * | |
1338 | * @param string $name | |
1339 | * @return void | |
1340 | */ | |
1341 | static function viewProfile($name) { | |
9399901d | 1342 | return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
87dab4a4 | 1343 | self::$_nullObject, self::$_nullObject, 'civicrm_viewProfile'); |
a8387f19 TO |
1344 | } |
1345 | ||
1346 | /** | |
1347 | * This hook is called while preparing a list of contacts (based on a profile) | |
1348 | * | |
1349 | * @param string $name | |
1350 | * @return void | |
1351 | */ | |
1352 | static function searchProfile($name) { | |
9399901d | 1353 | return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
87dab4a4 | 1354 | self::$_nullObject, self::$_nullObject, 'civicrm_searchProfile'); |
9399901d KJ |
1355 | } |
1356 | ||
1357 | /** | |
1358 | * This hook is called before encoding data in barcode | |
1359 | * | |
1360 | * @param array $data associated array of values available for encoding | |
1361 | * @param string $type type of barcode, classic barcode or QRcode | |
1362 | * @param string $context where this hooks is invoked. | |
1363 | * | |
1364 | * @return void | |
1365 | */ | |
1366 | static function alterBarcode( &$data, $type = 'barcode', $context = 'name_badge' ) { | |
1367 | return self::singleton()->invoke(3, $data, $type, $context, self::$_nullObject, | |
87dab4a4 | 1368 | self::$_nullObject, self::$_nullObject, 'civicrm_alterBarcode'); |
a8387f19 | 1369 | } |
99e9587a | 1370 | |
72ad6c1b TO |
1371 | /** |
1372 | * Modify or replace the Mailer object used for outgoing mail. | |
1373 | * | |
1374 | * @param object $mailer | |
1375 | * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory) | |
1376 | * @param string $driver | |
1377 | * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool") | |
1378 | * @param array $params | |
1379 | * The default mailer config options | |
1380 | * @see Mail::factory | |
1381 | */ | |
91bff2e5 | 1382 | static function alterMail(&$mailer, $driver, $params) { |
c8e4bea0 | 1383 | return self::singleton() |
87dab4a4 | 1384 | ->invoke(3, $mailer, $driver, $params, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_alterMailer'); |
72ad6c1b TO |
1385 | } |
1386 | ||
99e9587a | 1387 | /** |
2efcf0c2 | 1388 | * This hook is called while building the core search query, |
99e9587a DS |
1389 | * so hook implementers can provide their own query objects which alters/extends core search. |
1390 | * | |
1391 | * @param Array $queryObjects | |
1392 | * @return void | |
1393 | */ | |
c3e3dd65 | 1394 | static function queryObjects(&$queryObjects, $type = 'Contact') { |
87dab4a4 | 1395 | return self::singleton()->invoke(2, $queryObjects, $type, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_queryObjects'); |
99e9587a | 1396 | } |
6a488035 | 1397 | } |