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