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