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