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.
276 * the return value is ignored
278 public static function pre($op, $objectName, $id, &$params) {
279 $event = new \Civi\Core\Event\
PreEvent($op, $objectName, $id, $params);
280 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre", $event);
281 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre::$objectName", $event);
282 return self
::singleton()
283 ->invoke(4, $op, $objectName, $id, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_pre');
287 * This hook is called after a db write on some core objects.
290 * The type of operation being performed.
291 * @param string $objectName
292 * The name of the object.
293 * @param int $objectId
294 * The unique identifier for the object.
295 * @param object $objectRef
296 * The reference to the object if available.
299 * based on op. pre-hooks return a boolean or
300 * an error message which aborts the operation
302 public static function post($op, $objectName, $objectId, &$objectRef) {
303 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
304 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_post", $event);
305 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_post::$objectName", $event);
306 return self
::singleton()
307 ->invoke(4, $op, $objectName, $objectId, $objectRef, self
::$_nullObject, self
::$_nullObject, 'civicrm_post');
311 * This hook retrieves links from other modules and injects it into
312 * the view contact tabs
315 * The type of operation being performed.
316 * @param string $objectName
317 * The name of the object.
318 * @param int $objectId
319 * The unique identifier for the object.
320 * @param array $links
321 * (optional) the links array (introduced in v3.2).
323 * (optional) the bitmask to show/hide links.
324 * @param array $values
325 * (optional) the values to fill the links.
328 * the return value is ignored
330 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = array()) {
331 return self
::singleton()->invoke(6, $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
335 * This hook is invoked during the CiviCRM form preProcess phase.
337 * @param string $formName
338 * The name of the form.
339 * @param CRM_Core_Form $form
340 * Reference to the form object.
343 * the return value is ignored
345 public static function preProcess($formName, &$form) {
346 return self
::singleton()
347 ->invoke(2, $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_preProcess');
351 * This hook is invoked when building a CiviCRM form. This hook should also
352 * be used to set the default values of a form element
354 * @param string $formName
355 * The name of the form.
356 * @param CRM_Core_Form $form
357 * Reference to the form object.
360 * the return value is ignored
362 public static function buildForm($formName, &$form) {
363 return self
::singleton()->invoke(2, $formName, $form,
364 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
370 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
371 * any form elements, this hook should save the values in the database
373 * @param string $formName
374 * The name of the form.
375 * @param CRM_Core_Form $form
376 * Reference to the form object.
379 * the return value is ignored
381 public static function postProcess($formName, &$form) {
382 return self
::singleton()->invoke(2, $formName, $form,
383 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
384 'civicrm_postProcess'
389 * This hook is invoked during all CiviCRM form validation. An array of errors
390 * detected is returned. Else we assume validation succeeded.
392 * @param string $formName
393 * The name of the form.
394 * @param array &$fields the POST parameters as filtered by QF
395 * @param array &$files the FILES parameters as sent in by POST
396 * @param array &$form the form object
399 * formRule hooks return a boolean or
400 * an array of error messages which display a QF Error
402 public static function validate($formName, &$fields, &$files, &$form) {
403 return self
::singleton()
404 ->invoke(4, $formName, $fields, $files, $form, self
::$_nullObject, self
::$_nullObject, 'civicrm_validate');
408 * This hook is invoked during all CiviCRM form validation. An array of errors
409 * detected is returned. Else we assume validation succeeded.
411 * @param string $formName
412 * The name of the form.
413 * @param array &$fields the POST parameters as filtered by QF
414 * @param array &$files the FILES parameters as sent in by POST
415 * @param array &$form the form object
416 * @param array &$errors the array of errors.
419 * formRule hooks return a boolean or
420 * an array of error messages which display a QF Error
422 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
423 return self
::singleton()
424 ->invoke(5, $formName, $fields, $files, $form, $errors, self
::$_nullObject, 'civicrm_validateForm');
428 * This hook is called before a db write on a custom table
431 * The type of operation being performed.
432 * @param string $groupID
433 * The custom group ID.
434 * @param object $entityID
435 * The entityID of the row in the custom table.
436 * @param array $params
437 * The parameters that were sent into the calling function.
440 * the return value is ignored
442 public static function custom($op, $groupID, $entityID, &$params) {
443 return self
::singleton()
444 ->invoke(4, $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_custom');
448 * This hook is called when composing the ACL where clause to restrict
449 * visibility of contacts to the logged in user
452 * The type of permission needed.
453 * @param array $tables
454 * (reference ) add the tables that are needed for the select clause.
455 * @param array $whereTables
456 * (reference ) add the tables that are needed for the where clause.
457 * @param int $contactID
458 * The contactID for whom the check is made.
459 * @param string $where
460 * The currrent where clause.
463 * the return value is ignored
465 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
466 return self
::singleton()
467 ->invoke(5, $type, $tables, $whereTables, $contactID, $where, self
::$_nullObject, 'civicrm_aclWhereClause');
471 * This hook is called when composing the ACL where clause to restrict
472 * visibility of contacts to the logged in user
475 * The type of permission needed.
476 * @param int $contactID
477 * The contactID for whom the check is made.
478 * @param string $tableName
479 * The tableName which is being permissioned.
480 * @param array $allGroups
481 * The set of all the objects for the above table.
482 * @param array $currentGroups
483 * The set of objects that are currently permissioned for this contact.
486 * the return value is ignored
488 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
489 return self
::singleton()
490 ->invoke(5, $type, $contactID, $tableName, $allGroups, $currentGroups, self
::$_nullObject, 'civicrm_aclGroup');
494 * This hook is called when building the menu table
496 * @param array $files
497 * The current set of files to process.
500 * the return value is ignored
502 public static function xmlMenu(&$files) {
503 return self
::singleton()->invoke(1, $files,
504 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
510 * This hook is called for declaring managed entities via API
512 * @param array $entities
513 * List of pending entities.
516 * the return value is ignored
518 public static function managed(&$entities) {
519 return self
::singleton()->invoke(1, $entities,
520 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
526 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
528 * @param int $contactID
529 * The contactID for whom the dashboard is being rendered.
530 * @param int $contentPlacement
531 * (output parameter) where should the hook content be displayed.
532 * relative to the activity list
535 * the html snippet to include in the dashboard
537 public static function dashboard($contactID, &$contentPlacement = self
::DASHBOARD_BELOW
) {
538 $retval = self
::singleton()->invoke(2, $contactID, $contentPlacement,
539 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
544 * Note we need this seemingly unnecessary code because in the event that the implementation
545 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
546 * though we have a default value in this function's declaration above.
548 if (!isset($contentPlacement)) {
549 $contentPlacement = self
::DASHBOARD_BELOW
;
556 * This hook is called before storing recently viewed items.
558 * @param array $recentArray
559 * An array of recently viewed or processed items, for in place modification.
563 public static function recent(&$recentArray) {
564 return self
::singleton()->invoke(1, $recentArray,
565 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
571 * Determine how many other records refer to a given record
573 * @param CRM_Core_DAO $dao
574 * The item for which we want a reference count.
575 * @param array $refCounts
576 * Each item in the array is an array with keys:.
577 * - name: string, eg "sql:civicrm_email:contact_id"
578 * - type: string, eg "sql"
579 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
582 public static function referenceCounts($dao, &$refCounts) {
583 return self
::singleton()->invoke(2, $dao, $refCounts,
584 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
585 'civicrm_referenceCounts'
590 * This hook is called when building the amount structure for a Contribution or Event Page
592 * @param int $pageType
593 * Is this a contribution or event page.
594 * @param CRM_Core_Form $form
595 * Reference to the form object.
596 * @param array $amount
597 * The amount structure to be displayed.
601 public static function buildAmount($pageType, &$form, &$amount) {
602 return self
::singleton()->invoke(3, $pageType, $form, $amount, self
::$_nullObject,
603 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildAmount');
607 * This hook is called when building the state list for a particular country.
609 * @param array $countryID
610 * The country id whose states are being selected.
615 public static function buildStateProvinceForCountry($countryID, &$states) {
616 return self
::singleton()->invoke(2, $countryID, $states,
617 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
618 'civicrm_buildStateProvinceForCountry'
623 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
626 * The array of tabs that will be displayed.
627 * @param int $contactID
628 * The contactID for whom the dashboard is being rendered.
632 public static function tabs(&$tabs, $contactID) {
633 return self
::singleton()->invoke(2, $tabs, $contactID,
634 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabs'
639 * This hook is called when rendering the tabs used for events and potentially
640 * contribution pages, etc.
642 * @param string $tabsetName
643 * Name of the screen or visual element.
645 * Tabs that will be displayed.
646 * @param array $context
647 * Extra data about the screen or context in which the tab is used.
651 public static function tabset($tabsetName, &$tabs, $context) {
652 return self
::singleton()->invoke(3, $tabsetName, $tabs,
653 $context, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabset'
658 * This hook is called when sending an email / printing labels
660 * @param array $tokens
661 * The list of tokens that can be used for the contact.
665 public static function tokens(&$tokens) {
666 return self
::singleton()->invoke(1, $tokens,
667 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tokens'
672 * This hook is called when sending an email / printing labels to get the values for all the
673 * tokens returned by the 'tokens' hook
675 * @param array $details
676 * The array to store the token values indexed by contactIDs (unless it a single).
677 * @param array $contactIDs
678 * An array of contactIDs.
680 * The jobID if this is associated with a CiviMail mailing.
681 * @param array $tokens
682 * The list of tokens associated with the content.
683 * @param string $className
684 * The top level className from where the hook is invoked.
688 public static function tokenValues(
695 return self
::singleton()
696 ->invoke(5, $details, $contactIDs, $jobID, $tokens, $className, self
::$_nullObject, 'civicrm_tokenValues');
700 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
703 * @param object $page
704 * The page that will be rendered.
708 public static function pageRun(&$page) {
709 return self
::singleton()->invoke(1, $page,
710 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
716 * This hook is called after a copy of an object has been made. The current objects are
717 * Event, Contribution Page and UFGroup
719 * @param string $objectName
720 * Name of the object.
721 * @param object $object
722 * Reference to the copy.
726 public static function copy($objectName, &$object) {
727 return self
::singleton()->invoke(2, $objectName, $object,
728 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
734 * This hook is called when a contact unsubscribes from a mailing. It allows modules
735 * to override what the contacts are removed from.
739 * @param int $mailingId
740 * The id of the mailing to unsub from
741 * @param int $contactId
742 * The id of the contact who is unsubscribing
743 * @param array|int $groups
744 * Groups the contact will be removed from.
745 * @param array|int $baseGroups
746 * Base groups (used in smart mailings) the contact will be removed from.
751 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
752 return self
::singleton()
753 ->invoke(5, $op, $mailingId, $contactId, $groups, $baseGroups, self
::$_nullObject, 'civicrm_unsubscribeGroups');
757 * This hook is called when CiviCRM needs to edit/display a custom field with options (select, radio, checkbox,
760 * @param int $customFieldID
761 * The custom field ID.
762 * @param array $options
763 * The current set of options for that custom field.
764 * You can add/remove existing options.
765 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
766 * to be careful to not overwrite the array.
767 * Only add/edit/remove the specific field options you intend to affect.
768 * @param bool $detailedFormat
770 * the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
771 * @param array $selectAttributes
772 * Contain select attribute(s) if any.
776 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = array()) {
777 return self
::singleton()->invoke(3, $customFieldID, $options, $detailedFormat,
778 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
779 'civicrm_customFieldOptions'
785 * This hook is called to display the list of actions allowed after doing a search.
786 * This allows the module developer to inject additional actions or to remove existing actions.
788 * @param string $objectType
789 * The object type for this search.
790 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
791 * @param array $tasks
792 * The current set of tasks for that custom field.
793 * You can add/remove existing tasks.
794 * Each task needs to have a title (eg 'title' => ts( 'Add Contacts to Group')) and a class
795 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
796 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
797 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
798 * found in CRM/$objectType/Task.php.
802 public static function searchTasks($objectType, &$tasks) {
803 return self
::singleton()->invoke(2, $objectType, $tasks,
804 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
805 'civicrm_searchTasks'
811 * @param array $params
815 public static function eventDiscount(&$form, &$params) {
816 return self
::singleton()->invoke(2, $form, $params,
817 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
818 'civicrm_eventDiscount'
823 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
826 * The form object for which groups / mailings being displayed
827 * @param array $groups
828 * The list of groups being included / excluded
829 * @param array $mailings
830 * The list of mailings being included / excluded
834 public static function mailingGroups(&$form, &$groups, &$mailings) {
835 return self
::singleton()->invoke(3, $form, $groups, $mailings,
836 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
837 'civicrm_mailingGroups'
842 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
844 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
845 * You can use it to alter the membership types when first loaded, or after submission
846 * (for example if you want to gather data in the form and use it to alter the fees).
849 * The form object that is presenting the page
850 * @param array $membershipTypes
851 * The array of membership types and their amount
855 public static function membershipTypeValues(&$form, &$membershipTypes) {
856 return self
::singleton()->invoke(2, $form, $membershipTypes,
857 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
858 'civicrm_membershipTypeValues'
863 * This hook is called when rendering the contact summary
865 * @param int $contactID
866 * The contactID for whom the summary is being rendered
867 * @param mixed $content
868 * @param int $contentPlacement
869 * Specifies where the hook content should be displayed relative to the
873 * The html snippet to include in the contact summary
875 public static function summary($contactID, &$content, &$contentPlacement = self
::SUMMARY_BELOW
) {
876 return self
::singleton()->invoke(3, $contactID, $content, $contentPlacement,
877 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
883 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
884 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
885 * If you want to limit the contacts returned to a specific group, or some other criteria
886 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
887 * The hook is called when the query is executed to get the list of contacts to display.
889 * @param mixed $query
890 * - the query that will be executed (input and output parameter);.
891 * It's important to realize that the ACL clause is built prior to this hook being fired,
892 * so your query will ignore any ACL rules that may be defined.
893 * Your query must return two columns:
894 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
896 * @param string $name
897 * The name string to execute the query against (this is the value being typed in by the user).
898 * @param string $context
899 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
901 * The id of the object for which the call is being made.
902 * For custom fields, it will be the custom field id
906 public static function contactListQuery(&$query, $name, $context, $id) {
907 return self
::singleton()->invoke(4, $query, $name, $context, $id,
908 self
::$_nullObject, self
::$_nullObject,
909 'civicrm_contactListQuery'
914 * Hook definition for altering payment parameters before talking to a payment processor back end.
916 * Definition will look like this:
918 * function hook_civicrm_alterPaymentProcessorParams($paymentObj,
919 * &$rawParams, &$cookedParams);
921 * @param string $paymentObj
922 * instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
923 * @param array &$rawParams
924 * array of params as passed to to the processor
925 * @param array &$cookedParams
926 * params after the processor code has translated them into its own key/value pairs
930 public static function alterPaymentProcessorParams(
935 return self
::singleton()->invoke(3, $paymentObj, $rawParams, $cookedParams,
936 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
937 'civicrm_alterPaymentProcessorParams'
942 * This hook is called when an email is about to be sent by CiviCRM.
944 * @param array $params
945 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
946 * returnPath, replyTo, headers, attachments (array)
947 * @param string $context
948 * The context in which the hook is being invoked, eg 'civimail'.
952 public static function alterMailParams(&$params, $context = NULL) {
953 return self
::singleton()->invoke(2, $params, $context,
954 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
955 'civicrm_alterMailParams'
960 * This hook is called when membership status is being calculated
962 * @param array $membershipStatus
963 * Membership status details as determined - alter if required.
964 * @param array $arguments
965 * Arguments passed in to calculate date.
970 * - 'exclude_is_admin'
971 * - 'membership_type_id'
972 * @param array $membership
973 * Membership details from the calling function.
977 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
978 return self
::singleton()->invoke(3, $membershipStatus, $arguments,
979 $membership, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
980 'civicrm_alterCalculatedMembershipStatus'
985 * This hook is called when rendering the Manage Case screen
991 * of data to be displayed, where the key is a unique id to be used for styling (div id's)
992 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
994 public static function caseSummary($caseID) {
995 return self
::singleton()->invoke(1, $caseID,
996 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
997 'civicrm_caseSummary'
1002 * This hook is called when locating CiviCase types.
1004 * @param array $caseTypes
1008 public static function caseTypes(&$caseTypes) {
1009 return self
::singleton()
1010 ->invoke(1, $caseTypes, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_caseTypes');
1014 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1015 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
1017 * @param CRM_Core_Config|array $config
1022 public static function config(&$config) {
1023 return self
::singleton()->invoke(1, $config,
1024 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1031 * @param int $recordID
1036 public static function enableDisable($recordBAO, $recordID, $isActive) {
1037 return self
::singleton()->invoke(3, $recordBAO, $recordID, $isActive,
1038 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1039 'civicrm_enableDisable'
1044 * This hooks allows to change option values
1046 * @param array $options
1047 * Associated array of option values / id
1048 * @param string $name
1053 public static function optionValues(&$options, $name) {
1054 return self
::singleton()->invoke(2, $options, $name,
1055 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1056 'civicrm_optionValues'
1061 * This hook allows modification of the navigation menu.
1063 * @param array $params
1064 * Associated array of navigation menu entry to Modify/Add
1068 public static function navigationMenu(&$params) {
1069 return self
::singleton()->invoke(1, $params,
1070 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1071 'civicrm_navigationMenu'
1076 * This hook allows modification of the data used to perform merging of duplicates.
1078 * @param string $type
1079 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1080 * @param array $data
1081 * The data, as described in $type.
1082 * @param int $mainId
1083 * Contact_id of the contact that survives the merge.
1084 * @param int $otherId
1085 * Contact_id of the contact that will be absorbed and deleted.
1086 * @param array $tables
1087 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
1091 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
1092 return self
::singleton()->invoke(5, $type, $data, $mainId, $otherId, $tables, self
::$_nullObject, 'civicrm_merge');
1096 * This hook provides a way to override the default privacy behavior for notes.
1098 * @param array &$noteValues
1099 * Associative array of values for this note
1103 public static function notePrivacy(&$noteValues) {
1104 return self
::singleton()->invoke(1, $noteValues,
1105 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1106 'civicrm_notePrivacy'
1111 * This hook is called before record is exported as CSV
1113 * @param string $exportTempTable
1114 * Name of the temporary export table used during export.
1115 * @param array $headerRows
1116 * Header rows for output.
1117 * @param array $sqlColumns
1119 * @param int $exportMode
1120 * Export mode ( contact, contribution, etc...).
1124 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, &$exportMode) {
1125 return self
::singleton()->invoke(4, $exportTempTable, $headerRows, $sqlColumns, $exportMode,
1126 self
::$_nullObject, self
::$_nullObject,
1132 * This hook allows modification of the queries constructed from dupe rules.
1134 * @param string $obj
1135 * Object of rulegroup class.
1136 * @param string $type
1137 * Type of queries e.g table / threshold.
1138 * @param array $query
1143 public static function dupeQuery($obj, $type, &$query) {
1144 return self
::singleton()->invoke(3, $obj, $type, $query,
1145 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1151 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1153 * @param string $type
1154 * Type of mail processed: 'activity' OR 'mailing'.
1155 * @param array &$params the params that were sent to the CiviCRM API function
1156 * @param object $mail
1157 * The mail object which is an ezcMail class.
1158 * @param array &$result the result returned by the api call
1159 * @param string $action
1160 * (optional ) the requested action to be performed if the types was 'mailing'.
1164 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
1165 return self
::singleton()
1166 ->invoke(5, $type, $params, $mail, $result, $action, self
::$_nullObject, 'civicrm_emailProcessor');
1170 * This hook is called after a row has been processed and the
1171 * record (and associated records imported
1173 * @param string $object
1174 * Object being imported (for now Contact only, later Contribution, Activity,.
1175 * Participant and Member)
1176 * @param string $usage
1177 * Hook usage/location (for now process only, later mapping and others).
1178 * @param string $objectRef
1179 * Import record object.
1180 * @param array $params
1181 * Array with various key values: currently.
1182 * contactID - contact id
1183 * importID - row id in temp table
1184 * importTempTable - name of tempTable
1185 * fieldHeaders - field headers
1186 * fields - import fields
1190 public static function import($object, $usage, &$objectRef, &$params) {
1191 return self
::singleton()->invoke(4, $object, $usage, $objectRef, $params,
1192 self
::$_nullObject, self
::$_nullObject,
1198 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
1199 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
1201 * @param string $entity
1202 * The API entity (like contact).
1203 * @param string $action
1204 * The API action (like get).
1205 * @param array &$params the API parameters
1206 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
1210 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
1211 return self
::singleton()->invoke(4, $entity, $action, $params, $permissions,
1212 self
::$_nullObject, self
::$_nullObject,
1213 'civicrm_alterAPIPermissions'
1218 * @param CRM_Core_DAO $dao
1222 public static function postSave(&$dao) {
1223 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1224 return self
::singleton()->invoke(1, $dao,
1225 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1231 * This hook allows user to customize context menu Actions on contact summary page.
1233 * @param array $actions
1234 * Array of all Actions in contextmenu.
1235 * @param int $contactID
1236 * ContactID for the summary page.
1240 public static function summaryActions(&$actions, $contactID = NULL) {
1241 return self
::singleton()->invoke(2, $actions, $contactID,
1242 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1243 'civicrm_summaryActions'
1248 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1249 * This enables us hook implementors to modify both the headers and the rows
1251 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1252 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1254 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1255 * you want displayed. This is a hackish, but avoids template modification.
1257 * @param string $objectName
1258 * The component name that we are doing the search.
1259 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
1260 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1261 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
1264 * @internal param array $seletor the selector object. Allows you access to the context of the search
1267 * modify the header and values object to pass the data u need
1269 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
1270 return self
::singleton()->invoke(4, $objectName, $headers, $rows, $selector,
1271 self
::$_nullObject, self
::$_nullObject,
1272 'civicrm_searchColumns'
1277 * This hook is called when uf groups are being built for a module.
1279 * @param string $moduleName
1281 * @param array $ufGroups
1282 * Array of ufgroups for a module.
1286 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
1287 return self
::singleton()->invoke(2, $moduleName, $ufGroups,
1288 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1289 'civicrm_buildUFGroupsForModule'
1294 * This hook is called when we are determining the contactID for a specific
1297 * @param string $email
1298 * The email address.
1299 * @param int $contactID
1300 * The contactID that matches this email address, IF it exists.
1301 * @param array $result
1302 * (reference) has two fields.
1303 * contactID - the new (or same) contactID
1304 * action - 3 possible values:
1305 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1306 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1307 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
1311 public static function emailProcessorContact($email, $contactID, &$result) {
1312 return self
::singleton()->invoke(3, $email, $contactID, $result,
1313 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1314 'civicrm_emailProcessorContact'
1319 * Hook definition for altering the generation of Mailing Labels
1321 * @param array $args
1322 * An array of the args in the order defined for the tcpdf multiCell api call.
1323 * with the variable names below converted into string keys (ie $w become 'w'
1324 * as the first key for $args)
1325 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1326 * float $h Cell minimum height. The cell extends automatically if needed.
1327 * string $txt String to print
1328 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1329 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1330 * a string containing some or all of the following characters (in any order):
1331 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1332 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1333 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1334 * (default value when $ishtml=false)</li></ul>
1335 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1336 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1337 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1338 * float $x x position in user units
1339 * float $y y position in user units
1340 * boolean $reseth if true reset the last cell height (default true).
1341 * int $stretch stretch carachter mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
1342 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1343 * necessary</li><li>4 = forced character spacing</li></ul>
1344 * boolean $ishtml set to true if $txt is HTML content (default = false).
1345 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1346 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1347 * or 0 for disable this feature. This feature works only when $ishtml=false.
1351 public static function alterMailingLabelParams(&$args) {
1352 return self
::singleton()->invoke(1, $args,
1353 self
::$_nullObject, self
::$_nullObject,
1354 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1355 'civicrm_alterMailingLabelParams'
1360 * This hooks allows alteration of generated page content
1363 * Previously generated content.
1365 * Context of content - page or form.
1367 * The file name of the tpl.
1369 * A reference to the page or form object.
1373 public static function alterContent(&$content, $context, $tplName, &$object) {
1374 return self
::singleton()->invoke(4, $content, $context, $tplName, $object,
1375 self
::$_nullObject, self
::$_nullObject,
1376 'civicrm_alterContent'
1381 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1382 * altercontent hook as the content has already been rendered through the tpl at that point
1385 * Previously generated content.
1387 * Reference to the form object.
1389 * Context of content - page or form.
1391 * Reference the file name of the tpl.
1395 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
1396 return self
::singleton()->invoke(4, $formName, $form, $context, $tplName,
1397 self
::$_nullObject, self
::$_nullObject,
1398 'civicrm_alterTemplateFile'
1403 * This hook collects the trigger definition from all components
1406 * @param string $tableName
1407 * (optional) the name of the table that we are interested in only.
1409 * @internal param \reference $triggerInfo to an array of trigger information
1410 * each element has 4 fields:
1411 * table - array of tableName
1412 * when - BEFORE or AFTER
1413 * event - array of eventName - INSERT OR UPDATE OR DELETE
1414 * sql - array of statements optionally terminated with a ;
1415 * a statement can use the tokes {tableName} and {eventName}
1416 * to do token replacement with the table / event. This allows
1417 * templatizing logging and other hooks
1420 public static function triggerInfo(&$info, $tableName = NULL) {
1421 return self
::singleton()->invoke(2, $info, $tableName,
1422 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1424 'civicrm_triggerInfo'
1429 * This hook is called when a module-extension is installed.
1430 * Each module will receive hook_civicrm_install during its own installation (but not during the
1431 * installation of unrelated modules).
1433 public static function install() {
1434 return self
::singleton()->invoke(0, self
::$_nullObject,
1435 self
::$_nullObject, self
::$_nullObject,
1436 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1442 * This hook is called when a module-extension is uninstalled.
1443 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1444 * uninstallation of unrelated modules).
1446 public static function uninstall() {
1447 return self
::singleton()->invoke(0, self
::$_nullObject,
1448 self
::$_nullObject, self
::$_nullObject,
1449 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1455 * This hook is called when a module-extension is re-enabled.
1456 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1457 * re-enablement of unrelated modules).
1459 public static function enable() {
1460 return self
::singleton()->invoke(0, self
::$_nullObject,
1461 self
::$_nullObject, self
::$_nullObject,
1462 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1468 * This hook is called when a module-extension is disabled.
1469 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1470 * disablement of unrelated modules).
1472 public static function disable() {
1473 return self
::singleton()->invoke(0, self
::$_nullObject,
1474 self
::$_nullObject, self
::$_nullObject,
1475 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1487 public static function alterReportVar($varType, &$var, &$object) {
1488 return self
::singleton()->invoke(3, $varType, $var, $object,
1490 self
::$_nullObject, self
::$_nullObject,
1491 'civicrm_alterReportVar'
1496 * This hook is called to drive database upgrades for extension-modules.
1499 * The type of operation being performed; 'check' or 'enqueue'.
1500 * @param CRM_Queue_Queue $queue
1501 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
1504 * NULL, if $op is 'enqueue'.
1505 * TRUE, if $op is 'check' and upgrades are pending.
1506 * FALSE, if $op is 'check' and upgrades are not pending.
1508 public static function upgrade($op, CRM_Queue_Queue
$queue = NULL) {
1509 return self
::singleton()->invoke(2, $op, $queue,
1510 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1517 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1519 * @param array $params
1520 * The mailing parameters. Array fields include: groupName, from, toName,
1521 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1522 * attachments (array)
1526 public static function postEmailSend(&$params) {
1527 return self
::singleton()->invoke(1, $params,
1528 self
::$_nullObject, self
::$_nullObject,
1529 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1530 'civicrm_postEmailSend'
1535 * This hook is called when Settings specifications are loaded
1537 * @param array $settingsFolders
1538 * List of paths from which to derive metadata
1542 public static function alterSettingsFolders(&$settingsFolders) {
1543 return self
::singleton()->invoke(1, $settingsFolders,
1544 self
::$_nullObject, self
::$_nullObject,
1545 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1546 'civicrm_alterSettingsFolders'
1551 * This hook is called when Settings have been loaded from the xml
1552 * It is an opportunity for hooks to alter the data
1554 * @param array $settingsMetaData
1555 * Settings Metadata.
1556 * @param int $domainID
1557 * @param mixed $profile
1561 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
1562 return self
::singleton()->invoke(3, $settingsMetaData,
1563 $domainID, $profile,
1564 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1565 'civicrm_alterSettingsMetaData'
1570 * This hook is called before running an api call.
1572 * @param API_Wrapper[] $wrappers
1573 * (see CRM_Utils_API_ReloadOption as an example)
1574 * @param mixed $apiRequest
1577 * The return value is ignored
1579 public static function apiWrappers(&$wrappers, $apiRequest) {
1580 return self
::singleton()
1581 ->invoke(2, $wrappers, $apiRequest, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1582 self
::$_nullObject, 'civicrm_apiWrappers'
1587 * This hook is called before running pending cron jobs.
1589 * @param CRM_Core_JobManager $jobManager
1592 * The return value is ignored.
1594 public static function cron($jobManager) {
1595 return self
::singleton()->invoke(1,
1596 $jobManager, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1602 * This hook is called when loading CMS permissions; use this hook to modify
1603 * the array of system permissions for CiviCRM.
1605 * @param array $permissions
1606 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1607 * the format of this array.
1610 * The return value is ignored
1612 public static function permission(&$permissions) {
1613 return self
::singleton()->invoke(1, $permissions,
1614 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1615 'civicrm_permission'
1620 * @param CRM_Core_Exception Exception $exception
1621 * @param mixed $request
1622 * Reserved for future use.
1624 public static function unhandledException($exception, $request = NULL) {
1626 ->invoke(2, $exception, $request, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_unhandled_exception');
1628 //$event = new stdClass();
1629 //$event->exception = $exception;
1630 //CRM_Core_LegacyErrorHandler::handleException($event);
1633 $event = new \Civi\Core\Event\
UnhandledExceptionEvent($exception, self
::$_nullObject);
1634 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_unhandled_exception", $event);
1638 * This hook is called for declaring managed entities via API
1640 * @param array[] $entityTypes
1641 * List of entity types; each entity-type is an array with keys:
1642 * - name: string, a unique short name (e.g. "ReportInstance")
1643 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
1644 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
1647 * The return value is ignored
1649 public static function entityTypes(&$entityTypes) {
1650 return self
::singleton()->invoke(1, $entityTypes, self
::$_nullObject, self
::$_nullObject,
1651 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_entityTypes'
1656 * This hook is called while preparing a profile form
1658 * @param string $name
1661 public static function buildProfile($name) {
1662 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1663 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildProfile');
1667 * This hook is called while validating a profile form submission
1669 * @param string $name
1672 public static function validateProfile($name) {
1673 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1674 self
::$_nullObject, self
::$_nullObject, 'civicrm_validateProfile');
1678 * This hook is called processing a valid profile form submission
1680 * @param string $name
1683 public static function processProfile($name) {
1684 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1685 self
::$_nullObject, self
::$_nullObject, 'civicrm_processProfile');
1689 * This hook is called while preparing a read-only profile screen
1691 * @param string $name
1694 public static function viewProfile($name) {
1695 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1696 self
::$_nullObject, self
::$_nullObject, 'civicrm_viewProfile');
1700 * This hook is called while preparing a list of contacts (based on a profile)
1702 * @param string $name
1705 public static function searchProfile($name) {
1706 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1707 self
::$_nullObject, self
::$_nullObject, 'civicrm_searchProfile');
1711 * This hook is invoked when building a CiviCRM name badge.
1713 * @param string $labelName
1714 * String referencing name of badge format.
1715 * @param object $label
1716 * Reference to the label object.
1717 * @param array $format
1718 * Array of format data.
1719 * @param array $participant
1720 * Array of participant values.
1723 * the return value is ignored
1725 public static function alterBadge($labelName, &$label, &$format, &$participant) {
1726 return self
::singleton()
1727 ->invoke(4, $labelName, $label, $format, $participant, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBadge');
1732 * This hook is called before encoding data in barcode
1734 * @param array $data
1735 * Associated array of values available for encoding.
1736 * @param string $type
1737 * Type of barcode, classic barcode or QRcode.
1738 * @param string $context
1739 * Where this hooks is invoked.
1743 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
1744 return self
::singleton()->invoke(3, $data, $type, $context, self
::$_nullObject,
1745 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBarcode');
1749 * Modify or replace the Mailer object used for outgoing mail.
1751 * @param object $mailer
1752 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
1753 * @param string $driver
1754 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
1755 * @param array $params
1756 * The default mailer config options
1759 * @see Mail::factory
1761 public static function alterMail(&$mailer, $driver, $params) {
1762 return self
::singleton()
1763 ->invoke(3, $mailer, $driver, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterMailer');
1767 * This hook is called while building the core search query,
1768 * so hook implementers can provide their own query objects which alters/extends core search.
1770 * @param array $queryObjects
1771 * @param string $type
1775 public static function queryObjects(&$queryObjects, $type = 'Contact') {
1776 return self
::singleton()
1777 ->invoke(2, $queryObjects, $type, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_queryObjects');
1781 * This hook is called while viewing contact dashboard
1783 * @param array $availableDashlets
1784 * List of dashlets; each is formatted per api/v3/Dashboard
1785 * @param array $defaultDashlets
1786 * List of dashlets; each is formatted per api/v3/DashboardContact
1790 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
1791 return self
::singleton()
1792 ->invoke(2, $availableDashlets, $defaultDashlets, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_dashboard_defaults');
1796 * This hook is called before a case merge (or a case reassign)
1798 * @param int $mainContactId
1799 * @param int $mainCaseId
1800 * @param int $otherContactId
1801 * @param int $otherCaseId
1802 * @param bool $changeClient
1806 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
1807 return self
::singleton()
1808 ->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_pre_case_merge');
1812 * This hook is called after a case merge (or a case reassign)
1814 * @param int $mainContactId
1815 * @param int $mainCaseId
1816 * @param int $otherContactId
1817 * @param int $otherCaseId
1818 * @param bool $changeClient
1822 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
1823 return self
::singleton()
1824 ->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_post_case_merge');
1829 * Add a hook for altering the display name
1831 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
1833 * @param string $displayName
1834 * @param int $contactId
1835 * @param object $dao
1836 * The contact object.
1840 public static function alterDisplayName($displayName, $contactId, $dao) {
1841 return self
::singleton()->invoke(3,
1842 $displayName, $contactId, $dao, self
::$_nullObject, self
::$_nullObject,
1843 self
::$_nullObject, 'civicrm_contact_get_displayname'
1848 * EXPERIMENTAL: This hook allows one to register additional Angular modules
1850 * @param array $angularModules
1853 * the return value is ignored
1856 * function mymod_civicrm_angularModules(&$angularModules) {
1857 * $angularModules['myAngularModule'] = array('ext' => 'org.example.mymod', 'js' => array('js/myAngularModule.js'));
1858 * $angularModules['myBigAngularModule'] = array('ext' => 'org.example.mymod', 'js' => array('js/part1.js', 'js/part2.js'), 'css' => array('css/myAngularModule.css'));
1862 public static function angularModules(&$angularModules) {
1863 return self
::singleton()->invoke(1, $angularModules,
1864 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1865 'civicrm_angularModules'
1870 * This hook fires whenever a record in a case changes.
1872 * @param \Civi\CCase\Analyzer $analyzer
1874 public static function caseChange(\Civi\CCase\Analyzer
$analyzer) {
1875 $event = new \Civi\CCase\Event\
CaseChangeEvent($analyzer);
1876 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_caseChange", $event);
1878 return self
::singleton()->invoke(1, $angularModules,
1879 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1880 'civicrm_caseChange'
1885 * Generate a default CRUD URL for an entity
1887 * @param array $spec
1889 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
1890 * - entity_table: string
1892 * @param CRM_Core_DAO $bao
1893 * @param array $link
1894 * To define the link, add these keys to $link:.
1898 * - url: string (used in lieu of "path"/"query")
1899 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
1902 public static function crudLink($spec, $bao, &$link) {
1903 return self
::singleton()->invoke(3, $spec, $bao, $link,
1904 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1910 * @param array <CRM_Core_FileSearchInterface> $fileSearches
1913 public static function fileSearches(&$fileSearches) {
1914 return self
::singleton()->invoke(1, $fileSearches,
1915 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1916 'civicrm_fileSearches'