9437b9b14f3463f1f0a3685b564a17b5968ff921
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
30 * @package CiviCRM_Hook
31 * @copyright CiviCRM LLC (c) 2004-2014
35 abstract class CRM_Utils_Hook
{
37 // Allowed values for dashboard hook content placement
38 // Default - place content below activity list
39 const DASHBOARD_BELOW
= 1;
40 // Place content above activity list
41 const DASHBOARD_ABOVE
= 2;
42 // Don't display activity list at all
43 const DASHBOARD_REPLACE
= 3;
45 // by default - place content below existing content
46 const SUMMARY_BELOW
= 1;
47 // pace hook content above
48 const SUMMARY_ABOVE
= 2;
49 // create your own summarys
50 const SUMMARY_REPLACE
= 3;
52 static $_nullObject = NULL;
55 * We only need one instance of this object. So we use the singleton
56 * pattern and cache the instance in this variable
61 static private $_singleton = NULL;
66 private $commonIncluded = FALSE;
71 private $commonCiviModules = array();
74 * Constructor and getter for the singleton instance
79 * An instance of $config->userHookClass
81 public static function singleton($fresh = FALSE) {
82 if (self
::$_singleton == NULL ||
$fresh) {
83 $config = CRM_Core_Config
::singleton();
84 $class = $config->userHookClass
;
85 require_once str_replace('_', DIRECTORY_SEPARATOR
, $config->userHookClass
) . '.php';
86 self
::$_singleton = new $class();
88 return self
::$_singleton;
94 * @param int $numParams
95 * Number of parameters to pass to the hook.
97 * Parameter to be passed to the hook.
99 * Parameter to be passed to the hook.
101 * Parameter to be passed to the hook.
103 * Parameter to be passed to the hook.
105 * Parameter to be passed to the hook.
107 * Parameter to be passed to the hook.
108 * @param string $fnSuffix
109 * Function suffix, this is effectively the hook name.
113 public abstract function invoke(
115 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
120 * @param array $numParams
132 public function commonInvoke(
134 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
138 $this->commonBuildModuleList($fnPrefix);
140 return $this->runHooks($this->commonCiviModules
, $fnSuffix,
141 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
146 * Build the list of modules to be processed for hooks.
148 * @param string $fnPrefix
150 public function commonBuildModuleList($fnPrefix) {
151 if (!$this->commonIncluded
) {
152 // include external file
153 $this->commonIncluded
= TRUE;
155 $config = CRM_Core_Config
::singleton();
156 if (!empty($config->customPHPPathDir
) &&
157 file_exists("{$config->customPHPPathDir}/civicrmHooks.php")
159 @include_once
"civicrmHooks.php";
162 if (!empty($fnPrefix)) {
163 $this->commonCiviModules
[$fnPrefix] = $fnPrefix;
166 $this->requireCiviModules($this->commonCiviModules
);
171 * @param $civiModules
173 * @param array $numParams
183 public function runHooks(
184 $civiModules, $fnSuffix, $numParams,
185 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
187 // $civiModules is *not* passed by reference because runHooks
188 // must be reentrant. PHP is finicky about running
189 // multiple loops over the same variable. The circumstances
190 // to reproduce the issue are pretty intricate.
193 if ($civiModules !== NULL) {
194 foreach ($civiModules as $module) {
195 $fnName = "{$module}_{$fnSuffix}";
196 if (function_exists($fnName)) {
198 switch ($numParams) {
200 $fResult = $fnName();
204 $fResult = $fnName($arg1);
208 $fResult = $fnName($arg1, $arg2);
212 $fResult = $fnName($arg1, $arg2, $arg3);
216 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
220 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
224 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
228 CRM_Core_Error
::fatal(ts('Invalid hook invocation'));
232 if (!empty($fResult) &&
235 $result = array_merge($result, $fResult);
241 return empty($result) ?
TRUE : $result;
247 public function requireCiviModules(&$moduleList) {
248 $civiModules = CRM_Core_PseudoConstant
::getModuleExtensions();
249 foreach ($civiModules as $civiModule) {
250 if (!file_exists($civiModule['filePath'])) {
251 CRM_Core_Session
::setStatus(
252 ts('Error loading module file (%1). Please restore the file or disable the module.',
253 array(1 => $civiModule['filePath'])),
254 ts('Warning'), 'error');
257 include_once $civiModule['filePath'];
258 $moduleList[$civiModule['prefix']] = $civiModule['prefix'];
263 * This hook is called before a db write on some core objects.
264 * This hook does not allow the abort of the operation
267 * The type of operation being performed.
268 * @param string $objectName
269 * The name of the object.
271 * The object id if available.
272 * @param array $params
273 * The parameters used for object creation / editing.
275 * @return null the return value is ignored
277 public static function pre($op, $objectName, $id, &$params) {
278 $event = new \Civi\Core\Event\
PreEvent($op, $objectName, $id, $params);
279 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre", $event);
280 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre::$objectName", $event);
281 return self
::singleton()
282 ->invoke(4, $op, $objectName, $id, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_pre');
286 * This hook is called after a db write on some core objects.
289 * The type of operation being performed.
290 * @param string $objectName
291 * The name of the object.
292 * @param int $objectId
293 * The unique identifier for the object.
294 * @param object $objectRef
295 * The reference to the object if available.
297 * @return mixed based on op. pre-hooks return a boolean or
298 * an error message which aborts the operation
300 public static function post($op, $objectName, $objectId, &$objectRef) {
301 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
302 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_post", $event);
303 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_post::$objectName", $event);
304 return self
::singleton()
305 ->invoke(4, $op, $objectName, $objectId, $objectRef, self
::$_nullObject, self
::$_nullObject, 'civicrm_post');
309 * This hook retrieves links from other modules and injects it into
310 * the view contact tabs
313 * The type of operation being performed.
314 * @param string $objectName
315 * The name of the object.
316 * @param int $objectId
317 * The unique identifier for the object.
318 * @param array $links
319 * (optional) the links array (introduced in v3.2).
321 * (optional) the bitmask to show/hide links.
322 * @param array $values
323 * (optional) the values to fill the links.
325 * @return null the return value is ignored
327 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = array()) {
328 return self
::singleton()->invoke(6, $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
332 * This hook is invoked during the CiviCRM form preProcess phase.
334 * @param string $formName
335 * The name of the form.
336 * @param CRM_Core_Form $form
337 * Reference to the form object.
339 * @return null the return value is ignored
341 public static function preProcess($formName, &$form) {
342 return self
::singleton()
343 ->invoke(2, $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_preProcess');
347 * This hook is invoked when building a CiviCRM form. This hook should also
348 * be used to set the default values of a form element
350 * @param string $formName
351 * The name of the form.
352 * @param CRM_Core_Form $form
353 * Reference to the form object.
355 * @return null the return value is ignored
357 public static function buildForm($formName, &$form) {
358 return self
::singleton()->invoke(2, $formName, $form,
359 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
365 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
366 * any form elements, this hook should save the values in the database
368 * @param string $formName
369 * The name of the form.
370 * @param CRM_Core_Form $form
371 * Reference to the form object.
373 * @return null the return value is ignored
375 public static function postProcess($formName, &$form) {
376 return self
::singleton()->invoke(2, $formName, $form,
377 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
378 'civicrm_postProcess'
383 * This hook is invoked during all CiviCRM form validation. An array of errors
384 * detected is returned. Else we assume validation succeeded.
386 * @param string $formName
387 * The name of the form.
388 * @param array &$fields the POST parameters as filtered by QF
389 * @param array &$files the FILES parameters as sent in by POST
390 * @param array &$form the form object
392 * @return mixed formRule hooks return a boolean or
393 * an array of error messages which display a QF Error
395 public static function validate($formName, &$fields, &$files, &$form) {
396 return self
::singleton()
397 ->invoke(4, $formName, $fields, $files, $form, self
::$_nullObject, self
::$_nullObject, 'civicrm_validate');
401 * This hook is invoked during all CiviCRM form validation. An array of errors
402 * detected is returned. Else we assume validation succeeded.
404 * @param string $formName
405 * The name of the form.
406 * @param array &$fields the POST parameters as filtered by QF
407 * @param array &$files the FILES parameters as sent in by POST
408 * @param array &$form the form object
409 * @param array &$errors the array of errors.
411 * @return mixed formRule hooks return a boolean or
412 * an array of error messages which display a QF Error
414 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
415 return self
::singleton()
416 ->invoke(5, $formName, $fields, $files, $form, $errors, self
::$_nullObject, 'civicrm_validateForm');
420 * This hook is called before a db write on a custom table
423 * The type of operation being performed.
424 * @param string $groupID
425 * The custom group ID.
426 * @param object $entityID
427 * The entityID of the row in the custom table.
428 * @param array $params
429 * The parameters that were sent into the calling function.
431 * @return null the return value is ignored
433 public static function custom($op, $groupID, $entityID, &$params) {
434 return self
::singleton()
435 ->invoke(4, $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_custom');
439 * This hook is called when composing the ACL where clause to restrict
440 * visibility of contacts to the logged in user
443 * The type of permission needed.
444 * @param array $tables
445 * (reference ) add the tables that are needed for the select clause.
446 * @param array $whereTables
447 * (reference ) add the tables that are needed for the where clause.
448 * @param int $contactID
449 * The contactID for whom the check is made.
450 * @param string $where
451 * The currrent where clause.
453 * @return null the return value is ignored
455 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
456 return self
::singleton()
457 ->invoke(5, $type, $tables, $whereTables, $contactID, $where, self
::$_nullObject, 'civicrm_aclWhereClause');
461 * This hook is called when composing the ACL where clause to restrict
462 * visibility of contacts to the logged in user
465 * The type of permission needed.
466 * @param int $contactID
467 * The contactID for whom the check is made.
468 * @param string $tableName
469 * The tableName which is being permissioned.
470 * @param array $allGroups
471 * The set of all the objects for the above table.
472 * @param array $currentGroups
473 * The set of objects that are currently permissioned for this contact.
475 * @return null the return value is ignored
477 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
478 return self
::singleton()
479 ->invoke(5, $type, $contactID, $tableName, $allGroups, $currentGroups, self
::$_nullObject, 'civicrm_aclGroup');
483 * This hook is called when building the menu table
485 * @param array $files
486 * The current set of files to process.
488 * @return null the return value is ignored
490 public static function xmlMenu(&$files) {
491 return self
::singleton()->invoke(1, $files,
492 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
498 * This hook is called for declaring managed entities via API
500 * @param array $entities
501 * List of pending entities.
503 * @return null the return value is ignored
505 public static function managed(&$entities) {
506 return self
::singleton()->invoke(1, $entities,
507 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
513 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
515 * @param int $contactID
516 * The contactID for whom the dashboard is being rendered.
517 * @param int $contentPlacement
518 * (output parameter) where should the hook content be displayed.
519 * relative to the activity list
521 * @return string the html snippet to include in the dashboard
523 public static function dashboard($contactID, &$contentPlacement = self
::DASHBOARD_BELOW
) {
524 $retval = self
::singleton()->invoke(2, $contactID, $contentPlacement,
525 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
530 * Note we need this seemingly unnecessary code because in the event that the implementation
531 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
532 * though we have a default value in this function's declaration above.
534 if (!isset($contentPlacement)) {
535 $contentPlacement = self
::DASHBOARD_BELOW
;
542 * This hook is called before storing recently viewed items.
544 * @param array $recentArray
545 * An array of recently viewed or processed items, for in place modification.
549 public static function recent(&$recentArray) {
550 return self
::singleton()->invoke(1, $recentArray,
551 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
557 * Determine how many other records refer to a given record
559 * @param CRM_Core_DAO $dao
560 * The item for which we want a reference count.
561 * @param array $refCounts
562 * Each item in the array is an array with keys:.
563 * - name: string, eg "sql:civicrm_email:contact_id"
564 * - type: string, eg "sql"
565 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
568 public static function referenceCounts($dao, &$refCounts) {
569 return self
::singleton()->invoke(2, $dao, $refCounts,
570 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
571 'civicrm_referenceCounts'
576 * This hook is called when building the amount structure for a Contribution or Event Page
578 * @param int $pageType
579 * Is this a contribution or event page.
580 * @param CRM_Core_Form $form
581 * Reference to the form object.
582 * @param array $amount
583 * The amount structure to be displayed.
587 public static function buildAmount($pageType, &$form, &$amount) {
588 return self
::singleton()->invoke(3, $pageType, $form, $amount, self
::$_nullObject,
589 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildAmount');
593 * This hook is called when building the state list for a particular country.
595 * @param array $countryID
596 * The country id whose states are being selected.
601 public static function buildStateProvinceForCountry($countryID, &$states) {
602 return self
::singleton()->invoke(2, $countryID, $states,
603 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
604 'civicrm_buildStateProvinceForCountry'
609 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
612 * The array of tabs that will be displayed.
613 * @param int $contactID
614 * The contactID for whom the dashboard is being rendered.
618 public static function tabs(&$tabs, $contactID) {
619 return self
::singleton()->invoke(2, $tabs, $contactID,
620 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabs'
625 * This hook is called when rendering the tabs used for events and potentially
626 * contribution pages, etc.
628 * @param string $tabsetName
629 * Name of the screen or visual element.
631 * Tabs that will be displayed.
632 * @param array $context
633 * Extra data about the screen or context in which the tab is used.
637 public static function tabset($tabsetName, &$tabs, $context) {
638 return self
::singleton()->invoke(3, $tabsetName, $tabs,
639 $context, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabset'
644 * This hook is called when sending an email / printing labels
646 * @param array $tokens
647 * The list of tokens that can be used for the contact.
651 public static function tokens(&$tokens) {
652 return self
::singleton()->invoke(1, $tokens,
653 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tokens'
658 * This hook is called when sending an email / printing labels to get the values for all the
659 * tokens returned by the 'tokens' hook
661 * @param array $details
662 * The array to store the token values indexed by contactIDs (unless it a single).
663 * @param array $contactIDs
664 * An array of contactIDs.
666 * The jobID if this is associated with a CiviMail mailing.
667 * @param array $tokens
668 * The list of tokens associated with the content.
669 * @param string $className
670 * The top level className from where the hook is invoked.
674 public static function tokenValues(
681 return self
::singleton()
682 ->invoke(5, $details, $contactIDs, $jobID, $tokens, $className, self
::$_nullObject, 'civicrm_tokenValues');
686 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
689 * @param object $page
690 * The page that will be rendered.
694 public static function pageRun(&$page) {
695 return self
::singleton()->invoke(1, $page,
696 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
702 * This hook is called after a copy of an object has been made. The current objects are
703 * Event, Contribution Page and UFGroup
705 * @param string $objectName
706 * Name of the object.
707 * @param object $object
708 * Reference to the copy.
712 public static function copy($objectName, &$object) {
713 return self
::singleton()->invoke(2, $objectName, $object,
714 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
720 * This hook is called when a contact unsubscribes from a mailing. It allows modules
721 * to override what the contacts are removed from.
725 * @param int $mailingId
726 * The id of the mailing to unsub from
727 * @param int $contactId
728 * The id of the contact who is unsubscribing
729 * @param array|int $groups
730 * Groups the contact will be removed from.
731 * @param array|int $baseGroups
732 * Base groups (used in smart mailings) the contact will be removed from.
737 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
738 return self
::singleton()
739 ->invoke(5, $op, $mailingId, $contactId, $groups, $baseGroups, self
::$_nullObject, 'civicrm_unsubscribeGroups');
743 * This hook is called when CiviCRM needs to edit/display a custom field with options (select, radio, checkbox,
746 * @param int $customFieldID
747 * The custom field ID.
748 * @param array $options
749 * The current set of options for that custom field.
750 * You can add/remove existing options.
751 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
752 * to be careful to not overwrite the array.
753 * Only add/edit/remove the specific field options you intend to affect.
754 * @param bool $detailedFormat
756 * the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
757 * @param array $selectAttributes
758 * Contain select attribute(s) if any.
762 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = array()) {
763 return self
::singleton()->invoke(3, $customFieldID, $options, $detailedFormat,
764 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
765 'civicrm_customFieldOptions'
771 * This hook is called to display the list of actions allowed after doing a search.
772 * This allows the module developer to inject additional actions or to remove existing actions.
774 * @param string $objectType
775 * The object type for this search.
776 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
777 * @param array $tasks
778 * The current set of tasks for that custom field.
779 * You can add/remove existing tasks.
780 * Each task needs to have a title (eg 'title' => ts( 'Add Contacts to Group')) and a class
781 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
782 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
783 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
784 * found in CRM/$objectType/Task.php.
788 public static function searchTasks($objectType, &$tasks) {
789 return self
::singleton()->invoke(2, $objectType, $tasks,
790 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
791 'civicrm_searchTasks'
797 * @param array $params
801 public static function eventDiscount(&$form, &$params) {
802 return self
::singleton()->invoke(2, $form, $params,
803 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
804 'civicrm_eventDiscount'
809 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
812 * The form object for which groups / mailings being displayed
813 * @param array $groups
814 * The list of groups being included / excluded
815 * @param array $mailings
816 * The list of mailings being included / excluded
820 public static function mailingGroups(&$form, &$groups, &$mailings) {
821 return self
::singleton()->invoke(3, $form, $groups, $mailings,
822 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
823 'civicrm_mailingGroups'
828 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
830 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
831 * You can use it to alter the membership types when first loaded, or after submission
832 * (for example if you want to gather data in the form and use it to alter the fees).
835 * The form object that is presenting the page
836 * @param array $membershipTypes
837 * The array of membership types and their amount
841 public static function membershipTypeValues(&$form, &$membershipTypes) {
842 return self
::singleton()->invoke(2, $form, $membershipTypes,
843 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
844 'civicrm_membershipTypeValues'
849 * This hook is called when rendering the contact summary
851 * @param int $contactID
852 * The contactID for whom the summary is being rendered
853 * @param mixed $content
854 * @param int $contentPlacement
855 * Specifies where the hook content should be displayed relative to the
859 * The html snippet to include in the contact summary
861 public static function summary($contactID, &$content, &$contentPlacement = self
::SUMMARY_BELOW
) {
862 return self
::singleton()->invoke(3, $contactID, $content, $contentPlacement,
863 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
869 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
870 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
871 * If you want to limit the contacts returned to a specific group, or some other criteria
872 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
873 * The hook is called when the query is executed to get the list of contacts to display.
875 * @param mixed $query
876 * - the query that will be executed (input and output parameter);.
877 * It's important to realize that the ACL clause is built prior to this hook being fired,
878 * so your query will ignore any ACL rules that may be defined.
879 * Your query must return two columns:
880 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
882 * @param string $name
883 * The name string to execute the query against (this is the value being typed in by the user).
884 * @param string $context
885 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
887 * The id of the object for which the call is being made.
888 * For custom fields, it will be the custom field id
892 public static function contactListQuery(&$query, $name, $context, $id) {
893 return self
::singleton()->invoke(4, $query, $name, $context, $id,
894 self
::$_nullObject, self
::$_nullObject,
895 'civicrm_contactListQuery'
900 * Hook definition for altering payment parameters before talking to a payment processor back end.
902 * Definition will look like this:
904 * function hook_civicrm_alterPaymentProcessorParams($paymentObj,
905 * &$rawParams, &$cookedParams);
907 * @param string $paymentObj
908 * instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
909 * @param array &$rawParams
910 * array of params as passed to to the processor
911 * @param array &$cookedParams
912 * params after the processor code has translated them into its own key/value pairs
916 public static function alterPaymentProcessorParams(
921 return self
::singleton()->invoke(3, $paymentObj, $rawParams, $cookedParams,
922 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
923 'civicrm_alterPaymentProcessorParams'
928 * This hook is called when an email is about to be sent by CiviCRM.
930 * @param array $params
931 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
932 * returnPath, replyTo, headers, attachments (array)
933 * @param string $context
934 * The context in which the hook is being invoked, eg 'civimail'.
938 public static function alterMailParams(&$params, $context = NULL) {
939 return self
::singleton()->invoke(2, $params, $context,
940 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
941 'civicrm_alterMailParams'
946 * This hook is called when membership status is being calculated
948 * @param array $membershipStatus
949 * Membership status details as determined - alter if required.
950 * @param array $arguments
951 * Arguments passed in to calculate date.
956 * - 'exclude_is_admin'
957 * - 'membership_type_id'
958 * @param array $membership
959 * Membership details from the calling function.
963 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
964 return self
::singleton()->invoke(3, $membershipStatus, $arguments,
965 $membership, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
966 'civicrm_alterCalculatedMembershipStatus'
971 * This hook is called when rendering the Manage Case screen
976 * @return array of data to be displayed, where the key is a unique id to be used for styling (div id's)
977 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
979 public static function caseSummary($caseID) {
980 return self
::singleton()->invoke(1, $caseID,
981 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
982 'civicrm_caseSummary'
987 * This hook is called when locating CiviCase types.
989 * @param array $caseTypes
993 public static function caseTypes(&$caseTypes) {
994 return self
::singleton()
995 ->invoke(1, $caseTypes, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_caseTypes');
999 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1000 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
1002 * @param CRM_Core_Config|array $config
1007 public static function config(&$config) {
1008 return self
::singleton()->invoke(1, $config,
1009 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1016 * @param int $recordID
1021 public static function enableDisable($recordBAO, $recordID, $isActive) {
1022 return self
::singleton()->invoke(3, $recordBAO, $recordID, $isActive,
1023 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1024 'civicrm_enableDisable'
1029 * This hooks allows to change option values
1031 * @param array $options
1032 * Associated array of option values / id
1033 * @param string $name
1038 public static function optionValues(&$options, $name) {
1039 return self
::singleton()->invoke(2, $options, $name,
1040 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1041 'civicrm_optionValues'
1046 * This hook allows modification of the navigation menu.
1048 * @param array $params
1049 * Associated array of navigation menu entry to Modify/Add
1053 public static function navigationMenu(&$params) {
1054 return self
::singleton()->invoke(1, $params,
1055 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1056 'civicrm_navigationMenu'
1061 * This hook allows modification of the data used to perform merging of duplicates.
1063 * @param string $type
1064 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1065 * @param array $data
1066 * The data, as described in $type.
1067 * @param int $mainId
1068 * Contact_id of the contact that survives the merge.
1069 * @param int $otherId
1070 * Contact_id of the contact that will be absorbed and deleted.
1071 * @param array $tables
1072 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
1076 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
1077 return self
::singleton()->invoke(5, $type, $data, $mainId, $otherId, $tables, self
::$_nullObject, 'civicrm_merge');
1081 * This hook provides a way to override the default privacy behavior for notes.
1083 * @param array &$noteValues
1084 * Associative array of values for this note
1088 public static function notePrivacy(&$noteValues) {
1089 return self
::singleton()->invoke(1, $noteValues,
1090 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1091 'civicrm_notePrivacy'
1096 * This hook is called before record is exported as CSV
1098 * @param string $exportTempTable
1099 * Name of the temporary export table used during export.
1100 * @param array $headerRows
1101 * Header rows for output.
1102 * @param array $sqlColumns
1104 * @param int $exportMode
1105 * Export mode ( contact, contribution, etc...).
1109 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, &$exportMode) {
1110 return self
::singleton()->invoke(4, $exportTempTable, $headerRows, $sqlColumns, $exportMode,
1111 self
::$_nullObject, self
::$_nullObject,
1117 * This hook allows modification of the queries constructed from dupe rules.
1119 * @param string $obj
1120 * Object of rulegroup class.
1121 * @param string $type
1122 * Type of queries e.g table / threshold.
1123 * @param array $query
1128 public static function dupeQuery($obj, $type, &$query) {
1129 return self
::singleton()->invoke(3, $obj, $type, $query,
1130 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1136 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1138 * @param string $type
1139 * Type of mail processed: 'activity' OR 'mailing'.
1140 * @param array &$params the params that were sent to the CiviCRM API function
1141 * @param object $mail
1142 * The mail object which is an ezcMail class.
1143 * @param array &$result the result returned by the api call
1144 * @param string $action
1145 * (optional ) the requested action to be performed if the types was 'mailing'.
1149 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
1150 return self
::singleton()
1151 ->invoke(5, $type, $params, $mail, $result, $action, self
::$_nullObject, 'civicrm_emailProcessor');
1155 * This hook is called after a row has been processed and the
1156 * record (and associated records imported
1158 * @param string $object
1159 * Object being imported (for now Contact only, later Contribution, Activity,.
1160 * Participant and Member)
1161 * @param string $usage
1162 * Hook usage/location (for now process only, later mapping and others).
1163 * @param string $objectRef
1164 * Import record object.
1165 * @param array $params
1166 * Array with various key values: currently.
1167 * contactID - contact id
1168 * importID - row id in temp table
1169 * importTempTable - name of tempTable
1170 * fieldHeaders - field headers
1171 * fields - import fields
1175 public static function import($object, $usage, &$objectRef, &$params) {
1176 return self
::singleton()->invoke(4, $object, $usage, $objectRef, $params,
1177 self
::$_nullObject, self
::$_nullObject,
1183 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
1184 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
1186 * @param string $entity
1187 * The API entity (like contact).
1188 * @param string $action
1189 * The API action (like get).
1190 * @param array &$params the API parameters
1191 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
1195 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
1196 return self
::singleton()->invoke(4, $entity, $action, $params, $permissions,
1197 self
::$_nullObject, self
::$_nullObject,
1198 'civicrm_alterAPIPermissions'
1203 * @param CRM_Core_DAO $dao
1207 public static function postSave(&$dao) {
1208 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1209 return self
::singleton()->invoke(1, $dao,
1210 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1216 * This hook allows user to customize context menu Actions on contact summary page.
1218 * @param array $actions
1219 * Array of all Actions in contextmenu.
1220 * @param int $contactID
1221 * ContactID for the summary page.
1225 public static function summaryActions(&$actions, $contactID = NULL) {
1226 return self
::singleton()->invoke(2, $actions, $contactID,
1227 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1228 'civicrm_summaryActions'
1233 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1234 * This enables us hook implementors to modify both the headers and the rows
1236 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1237 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1239 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1240 * you want displayed. This is a hackish, but avoids template modification.
1242 * @param string $objectName
1243 * The component name that we are doing the search.
1244 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
1245 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1246 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
1249 * @internal param array $seletor the selector object. Allows you access to the context of the search
1251 * @return void modify the header and values object to pass the data u need
1253 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
1254 return self
::singleton()->invoke(4, $objectName, $headers, $rows, $selector,
1255 self
::$_nullObject, self
::$_nullObject,
1256 'civicrm_searchColumns'
1261 * This hook is called when uf groups are being built for a module.
1263 * @param string $moduleName
1265 * @param array $ufGroups
1266 * Array of ufgroups for a module.
1270 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
1271 return self
::singleton()->invoke(2, $moduleName, $ufGroups,
1272 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1273 'civicrm_buildUFGroupsForModule'
1278 * This hook is called when we are determining the contactID for a specific
1281 * @param string $email
1282 * The email address.
1283 * @param int $contactID
1284 * The contactID that matches this email address, IF it exists.
1285 * @param array $result
1286 * (reference) has two fields.
1287 * contactID - the new (or same) contactID
1288 * action - 3 possible values:
1289 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1290 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1291 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
1295 public static function emailProcessorContact($email, $contactID, &$result) {
1296 return self
::singleton()->invoke(3, $email, $contactID, $result,
1297 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1298 'civicrm_emailProcessorContact'
1303 * Hook definition for altering the generation of Mailing Labels
1305 * @param array $args
1306 * An array of the args in the order defined for the tcpdf multiCell api call.
1307 * with the variable names below converted into string keys (ie $w become 'w'
1308 * as the first key for $args)
1309 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1310 * float $h Cell minimum height. The cell extends automatically if needed.
1311 * string $txt String to print
1312 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1313 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1314 * a string containing some or all of the following characters (in any order):
1315 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1316 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1317 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1318 * (default value when $ishtml=false)</li></ul>
1319 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1320 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1321 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1322 * float $x x position in user units
1323 * float $y y position in user units
1324 * boolean $reseth if true reset the last cell height (default true).
1325 * int $stretch stretch carachter mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
1326 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1327 * necessary</li><li>4 = forced character spacing</li></ul>
1328 * boolean $ishtml set to true if $txt is HTML content (default = false).
1329 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1330 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1331 * or 0 for disable this feature. This feature works only when $ishtml=false.
1335 public static function alterMailingLabelParams(&$args) {
1336 return self
::singleton()->invoke(1, $args,
1337 self
::$_nullObject, self
::$_nullObject,
1338 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1339 'civicrm_alterMailingLabelParams'
1344 * This hooks allows alteration of generated page content
1347 * Previously generated content.
1349 * Context of content - page or form.
1351 * The file name of the tpl.
1353 * A reference to the page or form object.
1357 public static function alterContent(&$content, $context, $tplName, &$object) {
1358 return self
::singleton()->invoke(4, $content, $context, $tplName, $object,
1359 self
::$_nullObject, self
::$_nullObject,
1360 'civicrm_alterContent'
1365 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1366 * altercontent hook as the content has already been rendered through the tpl at that point
1369 * Previously generated content.
1371 * Reference to the form object.
1373 * Context of content - page or form.
1375 * Reference the file name of the tpl.
1379 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
1380 return self
::singleton()->invoke(4, $formName, $form, $context, $tplName,
1381 self
::$_nullObject, self
::$_nullObject,
1382 'civicrm_alterTemplateFile'
1387 * This hook collects the trigger definition from all components
1390 * @param string $tableName
1391 * (optional) the name of the table that we are interested in only.
1393 * @internal param \reference $triggerInfo to an array of trigger information
1394 * each element has 4 fields:
1395 * table - array of tableName
1396 * when - BEFORE or AFTER
1397 * event - array of eventName - INSERT OR UPDATE OR DELETE
1398 * sql - array of statements optionally terminated with a ;
1399 * a statement can use the tokes {tableName} and {eventName}
1400 * to do token replacement with the table / event. This allows
1401 * templatizing logging and other hooks
1404 public static function triggerInfo(&$info, $tableName = NULL) {
1405 return self
::singleton()->invoke(2, $info, $tableName,
1406 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1408 'civicrm_triggerInfo'
1413 * This hook is called when a module-extension is installed.
1414 * Each module will receive hook_civicrm_install during its own installation (but not during the
1415 * installation of unrelated modules).
1417 public static function install() {
1418 return self
::singleton()->invoke(0, self
::$_nullObject,
1419 self
::$_nullObject, self
::$_nullObject,
1420 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1426 * This hook is called when a module-extension is uninstalled.
1427 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1428 * uninstallation of unrelated modules).
1430 public static function uninstall() {
1431 return self
::singleton()->invoke(0, self
::$_nullObject,
1432 self
::$_nullObject, self
::$_nullObject,
1433 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1439 * This hook is called when a module-extension is re-enabled.
1440 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1441 * re-enablement of unrelated modules).
1443 public static function enable() {
1444 return self
::singleton()->invoke(0, self
::$_nullObject,
1445 self
::$_nullObject, self
::$_nullObject,
1446 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1452 * This hook is called when a module-extension is disabled.
1453 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1454 * disablement of unrelated modules).
1456 public static function disable() {
1457 return self
::singleton()->invoke(0, self
::$_nullObject,
1458 self
::$_nullObject, self
::$_nullObject,
1459 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1471 public static function alterReportVar($varType, &$var, &$object) {
1472 return self
::singleton()->invoke(3, $varType, $var, $object,
1474 self
::$_nullObject, self
::$_nullObject,
1475 'civicrm_alterReportVar'
1480 * This hook is called to drive database upgrades for extension-modules.
1483 * The type of operation being performed; 'check' or 'enqueue'.
1484 * @param CRM_Queue_Queue $queue
1485 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
1488 * NULL, if $op is 'enqueue'.
1489 * TRUE, if $op is 'check' and upgrades are pending.
1490 * FALSE, if $op is 'check' and upgrades are not pending.
1492 public static function upgrade($op, CRM_Queue_Queue
$queue = NULL) {
1493 return self
::singleton()->invoke(2, $op, $queue,
1494 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1501 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1503 * @param array $params
1504 * The mailing parameters. Array fields include: groupName, from, toName,
1505 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1506 * attachments (array)
1510 public static function postEmailSend(&$params) {
1511 return self
::singleton()->invoke(1, $params,
1512 self
::$_nullObject, self
::$_nullObject,
1513 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1514 'civicrm_postEmailSend'
1519 * This hook is called when Settings specifications are loaded
1521 * @param array $settingsFolders
1522 * List of paths from which to derive metadata
1526 public static function alterSettingsFolders(&$settingsFolders) {
1527 return self
::singleton()->invoke(1, $settingsFolders,
1528 self
::$_nullObject, self
::$_nullObject,
1529 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1530 'civicrm_alterSettingsFolders'
1535 * This hook is called when Settings have been loaded from the xml
1536 * It is an opportunity for hooks to alter the data
1538 * @param array $settingsMetaData
1539 * Settings Metadata.
1540 * @param int $domainID
1541 * @param mixed $profile
1545 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
1546 return self
::singleton()->invoke(3, $settingsMetaData,
1547 $domainID, $profile,
1548 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1549 'civicrm_alterSettingsMetaData'
1554 * This hook is called before running an api call.
1556 * @param API_Wrapper[] $wrappers
1557 * (see CRM_Utils_API_ReloadOption as an example)
1558 * @param mixed $apiRequest
1561 * The return value is ignored
1563 public static function apiWrappers(&$wrappers, $apiRequest) {
1564 return self
::singleton()
1565 ->invoke(2, $wrappers, $apiRequest, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1566 self
::$_nullObject, 'civicrm_apiWrappers'
1571 * This hook is called before running pending cron jobs.
1573 * @param CRM_Core_JobManager $jobManager
1576 * The return value is ignored.
1578 public static function cron($jobManager) {
1579 return self
::singleton()->invoke(1,
1580 $jobManager, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1586 * This hook is called when loading CMS permissions; use this hook to modify
1587 * the array of system permissions for CiviCRM.
1589 * @param array $permissions
1590 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1591 * the format of this array.
1594 * The return value is ignored
1596 public static function permission(&$permissions) {
1597 return self
::singleton()->invoke(1, $permissions,
1598 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1599 'civicrm_permission'
1604 * @param CRM_Core_Exception Exception $exception
1605 * @param mixed $request
1606 * Reserved for future use.
1608 public static function unhandledException($exception, $request = NULL) {
1610 ->invoke(2, $exception, $request, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_unhandled_exception');
1612 //$event = new stdClass();
1613 //$event->exception = $exception;
1614 //CRM_Core_LegacyErrorHandler::handleException($event);
1617 $event = new \Civi\Core\Event\
UnhandledExceptionEvent($exception, self
::$_nullObject);
1618 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_unhandled_exception", $event);
1622 * This hook is called for declaring managed entities via API
1624 * @param array[] $entityTypes
1625 * List of entity types; each entity-type is an array with keys:
1626 * - name: string, a unique short name (e.g. "ReportInstance")
1627 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
1628 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
1631 * The return value is ignored
1633 public static function entityTypes(&$entityTypes) {
1634 return self
::singleton()->invoke(1, $entityTypes, self
::$_nullObject, self
::$_nullObject,
1635 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_entityTypes'
1640 * This hook is called while preparing a profile form
1642 * @param string $name
1645 public static function buildProfile($name) {
1646 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1647 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildProfile');
1651 * This hook is called while validating a profile form submission
1653 * @param string $name
1656 public static function validateProfile($name) {
1657 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1658 self
::$_nullObject, self
::$_nullObject, 'civicrm_validateProfile');
1662 * This hook is called processing a valid profile form submission
1664 * @param string $name
1667 public static function processProfile($name) {
1668 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1669 self
::$_nullObject, self
::$_nullObject, 'civicrm_processProfile');
1673 * This hook is called while preparing a read-only profile screen
1675 * @param string $name
1678 public static function viewProfile($name) {
1679 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1680 self
::$_nullObject, self
::$_nullObject, 'civicrm_viewProfile');
1684 * This hook is called while preparing a list of contacts (based on a profile)
1686 * @param string $name
1689 public static function searchProfile($name) {
1690 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1691 self
::$_nullObject, self
::$_nullObject, 'civicrm_searchProfile');
1695 * This hook is invoked when building a CiviCRM name badge.
1697 * @param string $labelName
1698 * String referencing name of badge format.
1699 * @param object $label
1700 * Reference to the label object.
1701 * @param array $format
1702 * Array of format data.
1703 * @param array $participant
1704 * Array of participant values.
1706 * @return null the return value is ignored
1708 public static function alterBadge($labelName, &$label, &$format, &$participant) {
1709 return self
::singleton()
1710 ->invoke(4, $labelName, $label, $format, $participant, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBadge');
1715 * This hook is called before encoding data in barcode
1717 * @param array $data
1718 * Associated array of values available for encoding.
1719 * @param string $type
1720 * Type of barcode, classic barcode or QRcode.
1721 * @param string $context
1722 * Where this hooks is invoked.
1726 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
1727 return self
::singleton()->invoke(3, $data, $type, $context, self
::$_nullObject,
1728 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBarcode');
1732 * Modify or replace the Mailer object used for outgoing mail.
1734 * @param object $mailer
1735 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
1736 * @param string $driver
1737 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
1738 * @param array $params
1739 * The default mailer config options
1742 * @see Mail::factory
1744 public static function alterMail(&$mailer, $driver, $params) {
1745 return self
::singleton()
1746 ->invoke(3, $mailer, $driver, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterMailer');
1750 * This hook is called while building the core search query,
1751 * so hook implementers can provide their own query objects which alters/extends core search.
1753 * @param array $queryObjects
1754 * @param string $type
1758 public static function queryObjects(&$queryObjects, $type = 'Contact') {
1759 return self
::singleton()
1760 ->invoke(2, $queryObjects, $type, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_queryObjects');
1764 * This hook is called while viewing contact dashboard
1766 * @param array $availableDashlets
1767 * List of dashlets; each is formatted per api/v3/Dashboard
1768 * @param array $defaultDashlets
1769 * List of dashlets; each is formatted per api/v3/DashboardContact
1773 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
1774 return self
::singleton()
1775 ->invoke(2, $availableDashlets, $defaultDashlets, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_dashboard_defaults');
1779 * This hook is called before a case merge (or a case reassign)
1781 * @param int $mainContactId
1782 * @param int $mainCaseId
1783 * @param int $otherContactId
1784 * @param int $otherCaseId
1785 * @param bool $changeClient
1789 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
1790 return self
::singleton()
1791 ->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_pre_case_merge');
1795 * This hook is called after a case merge (or a case reassign)
1797 * @param int $mainContactId
1798 * @param int $mainCaseId
1799 * @param int $otherContactId
1800 * @param int $otherCaseId
1801 * @param bool $changeClient
1805 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
1806 return self
::singleton()
1807 ->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_post_case_merge');
1812 * Add a hook for altering the display name
1814 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
1816 * @param string $displayName
1817 * @param int $contactId
1818 * @param object $dao
1819 * The contact object.
1823 public static function alterDisplayName($displayName, $contactId, $dao) {
1824 return self
::singleton()->invoke(3,
1825 $displayName, $contactId, $dao, self
::$_nullObject, self
::$_nullObject,
1826 self
::$_nullObject, 'civicrm_contact_get_displayname'
1831 * EXPERIMENTAL: This hook allows one to register additional Angular modules
1833 * @param array $angularModules
1835 * @return null the return value is ignored
1838 * function mymod_civicrm_angularModules(&$angularModules) {
1839 * $angularModules['myAngularModule'] = array('ext' => 'org.example.mymod', 'js' => array('js/myAngularModule.js'));
1840 * $angularModules['myBigAngularModule'] = array('ext' => 'org.example.mymod', 'js' => array('js/part1.js', 'js/part2.js'), 'css' => array('css/myAngularModule.css'));
1844 public static function angularModules(&$angularModules) {
1845 return self
::singleton()->invoke(1, $angularModules,
1846 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1847 'civicrm_angularModules'
1852 * This hook fires whenever a record in a case changes.
1854 * @param \Civi\CCase\Analyzer $analyzer
1856 public static function caseChange(\Civi\CCase\Analyzer
$analyzer) {
1857 $event = new \Civi\CCase\Event\
CaseChangeEvent($analyzer);
1858 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_caseChange", $event);
1860 return self
::singleton()->invoke(1, $angularModules,
1861 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1862 'civicrm_caseChange'
1867 * Generate a default CRUD URL for an entity
1869 * @param array $spec
1871 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
1872 * - entity_table: string
1874 * @param CRM_Core_DAO $bao
1875 * @param array $link
1876 * To define the link, add these keys to $link:.
1880 * - url: string (used in lieu of "path"/"query")
1881 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
1884 public static function crudLink($spec, $bao, &$link) {
1885 return self
::singleton()->invoke(3, $spec, $bao, $link,
1886 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1892 * @param array <CRM_Core_FileSearchInterface> $fileSearches
1895 public static function fileSearches(&$fileSearches) {
1896 return self
::singleton()->invoke(1, $fileSearches,
1897 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1898 'civicrm_fileSearches'