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