6a1d710cf0a2fa7d089d5e93f9fe159f074867ac
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
36 abstract class CRM_Utils_Hook
{
38 // Allowed values for dashboard hook content placement
39 // Default - place content below activity list
40 const DASHBOARD_BELOW
= 1;
41 // Place content above activity list
42 const DASHBOARD_ABOVE
= 2;
43 // Don't display activity list at all
44 const DASHBOARD_REPLACE
= 3;
46 // by default - place content below existing content
47 const SUMMARY_BELOW
= 1;
48 // pace hook content above
49 const SUMMARY_ABOVE
= 2;
50 // create your own summarys
51 const SUMMARY_REPLACE
= 3;
53 static $_nullObject = NULL;
56 * We only need one instance of this object. So we use the singleton
57 * pattern and cache the instance in this variable
62 static private $_singleton = NULL;
67 private $commonIncluded = FALSE;
72 private $commonCiviModules = array();
75 * Constructor and getter for the singleton instance
80 * An instance of $config->userHookClass
82 public static function singleton($fresh = FALSE) {
83 if (self
::$_singleton == NULL ||
$fresh) {
84 $config = CRM_Core_Config
::singleton();
85 $class = $config->userHookClass
;
86 require_once str_replace('_', DIRECTORY_SEPARATOR
, $config->userHookClass
) . '.php';
87 self
::$_singleton = new $class();
89 return self
::$_singleton;
95 * @param int $numParams
96 * Number of parameters to pass to the hook.
98 * Parameter to be passed to the hook.
100 * Parameter to be passed to the hook.
102 * Parameter to be passed to the hook.
104 * Parameter to be passed to the hook.
106 * Parameter to be passed to the hook.
108 * Parameter to be passed to the hook.
109 * @param string $fnSuffix
110 * Function suffix, this is effectively the hook name.
114 abstract function invoke(
116 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
121 * @param array $numParams
133 function commonInvoke(
135 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
139 $this->commonBuildModuleList($fnPrefix);
141 return $this->runHooks($this->commonCiviModules
, $fnSuffix,
142 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
147 * Build the list of modules to be processed for hooks.
149 * @param string $fnPrefix
151 public function commonBuildModuleList($fnPrefix) {
152 if (!$this->commonIncluded
) {
153 // include external file
154 $this->commonIncluded
= TRUE;
156 $config = CRM_Core_Config
::singleton();
157 if (!empty($config->customPHPPathDir
) &&
158 file_exists("{$config->customPHPPathDir}/civicrmHooks.php")
160 @include_once
"civicrmHooks.php";
163 if (!empty($fnPrefix)) {
164 $this->commonCiviModules
[$fnPrefix] = $fnPrefix;
167 $this->requireCiviModules($this->commonCiviModules
);
172 * @param $civiModules
174 * @param array $numParams
185 $civiModules, $fnSuffix, $numParams,
186 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
188 // $civiModules is *not* passed by reference because runHooks
189 // must be reentrant. PHP is finicky about running
190 // multiple loops over the same variable. The circumstances
191 // to reproduce the issue are pretty intricate.
194 if ($civiModules !== NULL) {
195 foreach ($civiModules as $module) {
196 $fnName = "{$module}_{$fnSuffix}";
197 if (function_exists($fnName)) {
199 switch ($numParams) {
201 $fResult = $fnName();
205 $fResult = $fnName($arg1);
209 $fResult = $fnName($arg1, $arg2);
213 $fResult = $fnName($arg1, $arg2, $arg3);
217 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
221 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
225 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
229 CRM_Core_Error
::fatal(ts('Invalid hook invocation'));
233 if (!empty($fResult) &&
234 is_array($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()->invoke(4, $op, $objectName, $id, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_pre');
285 * This hook is called after a db write on some core objects.
288 * The type of operation being performed.
289 * @param string $objectName
290 * The name of the object.
291 * @param int $objectId
292 * The unique identifier for the object.
293 * @param object $objectRef
294 * The reference to the object if available.
296 * @return mixed based on op. pre-hooks return a boolean or
297 * an error message which aborts the operation
299 public static function post($op, $objectName, $objectId, &$objectRef) {
300 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
301 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_post", $event);
302 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_post::$objectName", $event);
303 return self
::singleton()->invoke(4, $op, $objectName, $objectId, $objectRef, self
::$_nullObject, self
::$_nullObject, 'civicrm_post');
307 * This hook retrieves links from other modules and injects it into
308 * the view contact tabs
311 * The type of operation being performed.
312 * @param string $objectName
313 * The name of the object.
314 * @param int $objectId
315 * The unique identifier for the object.
316 * @param array $links
317 * (optional) the links array (introduced in v3.2).
319 * (optional) the bitmask to show/hide links.
320 * @param array $values
321 * (optional) the values to fill the links.
323 * @return null the return value is ignored
325 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = array()) {
326 return self
::singleton()->invoke(6, $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
330 * This hook is invoked during the CiviCRM form preProcess phase.
332 * @param string $formName
333 * The name of the form.
334 * @param CRM_Core_Form $form
335 * Reference to the form object.
337 * @return null the return value is ignored
339 public static function preProcess($formName, &$form) {
340 return self
::singleton()->invoke(2, $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_preProcess');
344 * This hook is invoked when building a CiviCRM form. This hook should also
345 * be used to set the default values of a form element
347 * @param string $formName
348 * The name of the form.
349 * @param CRM_Core_Form $form
350 * Reference to the form object.
352 * @return null the return value is ignored
354 public static function buildForm($formName, &$form) {
355 return self
::singleton()->invoke(2, $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_buildForm');
359 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
360 * any form elements, this hook should save the values in the database
362 * @param string $formName
363 * The name of the form.
364 * @param CRM_Core_Form $form
365 * Reference to the form object.
367 * @return null the return value is ignored
369 public static function postProcess($formName, &$form) {
370 return self
::singleton()->invoke(2, $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_postProcess');
374 * This hook is invoked during all CiviCRM form validation. An array of errors
375 * detected is returned. Else we assume validation succeeded.
377 * @param string $formName
378 * The name of the form.
379 * @param array &$fields the POST parameters as filtered by QF
380 * @param array &$files the FILES parameters as sent in by POST
381 * @param array &$form the form object
383 * @return mixed formRule hooks return a boolean or
384 * an array of error messages which display a QF Error
386 public static function validate($formName, &$fields, &$files, &$form) {
387 return self
::singleton()->invoke(4, $formName, $fields, $files, $form, self
::$_nullObject, self
::$_nullObject, 'civicrm_validate');
391 * This hook is invoked during all CiviCRM form validation. An array of errors
392 * detected is returned. Else we assume validation succeeded.
394 * @param string $formName
395 * The name of the form.
396 * @param array &$fields the POST parameters as filtered by QF
397 * @param array &$files the FILES parameters as sent in by POST
398 * @param array &$form the form object
399 * @param array &$errors the array of errors.
401 * @return mixed formRule hooks return a boolean or
402 * an array of error messages which display a QF Error
404 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
405 return self
::singleton()->invoke(5, $formName, $fields, $files, $form, $errors, self
::$_nullObject, 'civicrm_validateForm');
409 * This hook is called before a db write on a custom table
412 * The type of operation being performed.
413 * @param string $groupID
414 * The custom group ID.
415 * @param object $entityID
416 * The entityID of the row in the custom table.
417 * @param array $params
418 * The parameters that were sent into the calling function.
420 * @return null the return value is ignored
422 public static function custom($op, $groupID, $entityID, &$params) {
423 return self
::singleton()->invoke(4, $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_custom');
427 * This hook is called when composing the ACL where clause to restrict
428 * visibility of contacts to the logged in user
431 * The type of permission needed.
432 * @param array $tables
433 * (reference ) add the tables that are needed for the select clause.
434 * @param array $whereTables
435 * (reference ) add the tables that are needed for the where clause.
436 * @param int $contactID
437 * The contactID for whom the check is made.
438 * @param string $where
439 * The currrent where clause.
441 * @return null the return value is ignored
443 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
444 return self
::singleton()->invoke(5, $type, $tables, $whereTables, $contactID, $where, self
::$_nullObject, 'civicrm_aclWhereClause');
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 int $contactID
454 * The contactID for whom the check is made.
455 * @param string $tableName
456 * The tableName which is being permissioned.
457 * @param array $allGroups
458 * The set of all the objects for the above table.
459 * @param array $currentGroups
460 * The set of objects that are currently permissioned for this contact.
462 * @return null the return value is ignored
464 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
465 return self
::singleton()->invoke(5, $type, $contactID, $tableName, $allGroups, $currentGroups, self
::$_nullObject, 'civicrm_aclGroup');
469 * This hook is called when building the menu table
471 * @param array $files
472 * The current set of files to process.
474 * @return null the return value is ignored
476 public static function xmlMenu(&$files) {
477 return self
::singleton()->invoke(1, $files,
478 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
484 * This hook is called for declaring managed entities via API
486 * @param array $entities
487 * List of pending entities.
489 * @return null the return value is ignored
491 public static function managed(&$entities) {
492 return self
::singleton()->invoke(1, $entities,
493 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
499 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
501 * @param int $contactID
502 * The contactID for whom the dashboard is being rendered.
503 * @param int $contentPlacement
504 * (output parameter) where should the hook content be displayed.
505 * relative to the activity list
507 * @return string the html snippet to include in the dashboard
509 public static function dashboard($contactID, &$contentPlacement = self
::DASHBOARD_BELOW
) {
510 $retval = self
::singleton()->invoke(2, $contactID, $contentPlacement,
511 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
516 * Note we need this seemingly unnecessary code because in the event that the implementation
517 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
518 * though we have a default value in this function's declaration above.
520 if (!isset($contentPlacement)) {
521 $contentPlacement = self
::DASHBOARD_BELOW
;
528 * This hook is called before storing recently viewed items.
530 * @param array $recentArray
531 * An array of recently viewed or processed items, for in place modification.
535 public static function recent(&$recentArray) {
536 return self
::singleton()->invoke(1, $recentArray,
537 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
543 * Determine how many other records refer to a given record
545 * @param CRM_Core_DAO $dao
546 * The item for which we want a reference count.
547 * @param array $refCounts
548 * Each item in the array is an array with keys:.
549 * - name: string, eg "sql:civicrm_email:contact_id"
550 * - type: string, eg "sql"
551 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
554 public static function referenceCounts($dao, &$refCounts) {
555 return self
::singleton()->invoke(2, $dao, $refCounts,
556 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
557 'civicrm_referenceCounts'
562 * This hook is called when building the amount structure for a Contribution or Event Page
564 * @param int $pageType
565 * Is this a contribution or event page.
566 * @param CRM_Core_Form $form
567 * Reference to the form object.
568 * @param array $amount
569 * The amount structure to be displayed.
573 public static function buildAmount($pageType, &$form, &$amount) {
574 return self
::singleton()->invoke(3, $pageType, $form, $amount, self
::$_nullObject,
575 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildAmount');
579 * This hook is called when building the state list for a particular country.
581 * @param array $countryID
582 * The country id whose states are being selected.
587 public static function buildStateProvinceForCountry($countryID, &$states) {
588 return self
::singleton()->invoke(2, $countryID, $states,
589 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
590 'civicrm_buildStateProvinceForCountry'
595 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
598 * The array of tabs that will be displayed.
599 * @param int $contactID
600 * The contactID for whom the dashboard is being rendered.
604 public static function tabs(&$tabs, $contactID) {
605 return self
::singleton()->invoke(2, $tabs, $contactID,
606 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabs'
611 * This hook is called when rendering the tabs used for events and potentially
612 * contribution pages, etc.
614 * @param string $tabsetName
615 * Name of the screen or visual element.
617 * Tabs that will be displayed.
618 * @param array $context
619 * Extra data about the screen or context in which the tab is used.
623 public static function tabset($tabsetName, &$tabs, $context) {
624 return self
::singleton()->invoke(3, $tabsetName, $tabs,
625 $context, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabset'
630 * This hook is called when sending an email / printing labels
632 * @param array $tokens
633 * The list of tokens that can be used for the contact.
637 public static function tokens(&$tokens) {
638 return self
::singleton()->invoke(1, $tokens,
639 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tokens'
644 * This hook is called when sending an email / printing labels to get the values for all the
645 * tokens returned by the 'tokens' hook
647 * @param array $details
648 * The array to store the token values indexed by contactIDs (unless it a single).
649 * @param array $contactIDs
650 * An array of contactIDs.
652 * The jobID if this is associated with a CiviMail mailing.
653 * @param array $tokens
654 * The list of tokens associated with the content.
655 * @param string $className
656 * The top level className from where the hook is invoked.
660 static function tokenValues(
667 return self
::singleton()->invoke(5, $details, $contactIDs, $jobID, $tokens, $className, self
::$_nullObject, 'civicrm_tokenValues');
671 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
674 * @param object $page
675 * The page that will be rendered.
679 public static function pageRun(&$page) {
680 return self
::singleton()->invoke(1, $page,
681 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
687 * This hook is called after a copy of an object has been made. The current objects are
688 * Event, Contribution Page and UFGroup
690 * @param string $objectName
691 * Name of the object.
692 * @param object $object
693 * Reference to the copy.
697 public static function copy($objectName, &$object) {
698 return self
::singleton()->invoke(2, $objectName, $object,
699 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
705 * This hook is called when a contact unsubscribes from a mailing. It allows modules
706 * to override what the contacts are removed from.
710 * @param int $mailingId
711 * The id of the mailing to unsub from
712 * @param int $contactId
713 * The id of the contact who is unsubscribing
714 * @param array|int $groups
715 * Groups the contact will be removed from.
716 * @param array|int $baseGroups
717 * Base groups (used in smart mailings) the contact will be removed from.
722 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
723 return self
::singleton()->invoke(5, $op, $mailingId, $contactId, $groups, $baseGroups, self
::$_nullObject, 'civicrm_unsubscribeGroups');
727 * This hook is called when CiviCRM needs to edit/display a custom field with options (select, radio, checkbox,
730 * @param int $customFieldID
731 * The custom field ID.
732 * @param array $options
733 * The current set of options for that custom field.
734 * You can add/remove existing options.
735 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
736 * to be careful to not overwrite the array.
737 * Only add/edit/remove the specific field options you intend to affect.
738 * @param bool $detailedFormat
740 * the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
741 * @param array $selectAttributes
742 * Contain select attribute(s) if any.
746 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = array()) {
747 return self
::singleton()->invoke(3, $customFieldID, $options, $detailedFormat,
748 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
749 'civicrm_customFieldOptions'
755 * This hook is called to display the list of actions allowed after doing a search.
756 * This allows the module developer to inject additional actions or to remove existing actions.
758 * @param string $objectType
759 * The object type for this search.
760 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
761 * @param array $tasks
762 * The current set of tasks for that custom field.
763 * You can add/remove existing tasks.
764 * Each task needs to have a title (eg 'title' => ts( 'Add Contacts to Group')) and a class
765 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
766 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
767 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
768 * found in CRM/$objectType/Task.php.
772 public static function searchTasks($objectType, &$tasks) {
773 return self
::singleton()->invoke(2, $objectType, $tasks,
774 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
775 'civicrm_searchTasks'
781 * @param array $params
785 public static function eventDiscount(&$form, &$params) {
786 return self
::singleton()->invoke(2, $form, $params,
787 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
788 'civicrm_eventDiscount'
793 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
796 * The form object for which groups / mailings being displayed
797 * @param array $groups
798 * The list of groups being included / excluded
799 * @param array $mailings
800 * The list of mailings being included / excluded
804 public static function mailingGroups(&$form, &$groups, &$mailings) {
805 return self
::singleton()->invoke(3, $form, $groups, $mailings,
806 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
807 'civicrm_mailingGroups'
812 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
814 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
815 * You can use it to alter the membership types when first loaded, or after submission
816 * (for example if you want to gather data in the form and use it to alter the fees).
819 * The form object that is presenting the page
820 * @param array $membershipTypes
821 * The array of membership types and their amount
825 public static function membershipTypeValues(&$form, &$membershipTypes) {
826 return self
::singleton()->invoke(2, $form, $membershipTypes,
827 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
828 'civicrm_membershipTypeValues'
833 * This hook is called when rendering the contact summary
835 * @param int $contactID
836 * The contactID for whom the summary is being rendered
837 * @param mixed $content
838 * @param int $contentPlacement
839 * Specifies where the hook content should be displayed relative to the
843 * The html snippet to include in the contact summary
845 public static function summary($contactID, &$content, &$contentPlacement = self
::SUMMARY_BELOW
) {
846 return self
::singleton()->invoke(3, $contactID, $content, $contentPlacement,
847 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
853 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
854 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
855 * If you want to limit the contacts returned to a specific group, or some other criteria
856 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
857 * The hook is called when the query is executed to get the list of contacts to display.
859 * @param mixed $query
860 * - the query that will be executed (input and output parameter);.
861 * It's important to realize that the ACL clause is built prior to this hook being fired,
862 * so your query will ignore any ACL rules that may be defined.
863 * Your query must return two columns:
864 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
866 * @param string $name
867 * The name string to execute the query against (this is the value being typed in by the user).
868 * @param string $context
869 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
871 * The id of the object for which the call is being made.
872 * For custom fields, it will be the custom field id
876 public static function contactListQuery(&$query, $name, $context, $id) {
877 return self
::singleton()->invoke(4, $query, $name, $context, $id,
878 self
::$_nullObject, self
::$_nullObject,
879 'civicrm_contactListQuery'
884 * Hook definition for altering payment parameters before talking to a payment processor back end.
886 * Definition will look like this:
888 * function hook_civicrm_alterPaymentProcessorParams($paymentObj,
889 * &$rawParams, &$cookedParams);
891 * @param string $paymentObj
892 * instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
893 * @param array &$rawParams
894 * array of params as passed to to the processor
895 * @param array &$cookedParams
896 * params after the processor code has translated them into its own key/value pairs
900 static function alterPaymentProcessorParams(
905 return self
::singleton()->invoke(3, $paymentObj, $rawParams, $cookedParams,
906 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
907 'civicrm_alterPaymentProcessorParams'
912 * This hook is called when an email is about to be sent by CiviCRM.
914 * @param array $params
915 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
916 * returnPath, replyTo, headers, attachments (array)
917 * @param string $context
918 * The context in which the hook is being invoked, eg 'civimail'.
922 public static function alterMailParams(&$params, $context = NULL) {
923 return self
::singleton()->invoke(2, $params, $context,
924 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
925 'civicrm_alterMailParams'
930 * This hook is called when membership status is being calculated
932 * @param array $membershipStatus
933 * Membership status details as determined - alter if required.
934 * @param array $arguments
935 * Arguments passed in to calculate date.
940 * - 'exclude_is_admin'
941 * - 'membership_type_id'
942 * @param array $membership
943 * Membership details from the calling function.
947 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
948 return self
::singleton()->invoke(3, $membershipStatus, $arguments,
949 $membership, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
950 'civicrm_alterCalculatedMembershipStatus'
955 * This hook is called when rendering the Manage Case screen
960 * @return array of data to be displayed, where the key is a unique id to be used for styling (div id's)
961 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
963 public static function caseSummary($caseID) {
964 return self
::singleton()->invoke(1, $caseID,
965 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
966 'civicrm_caseSummary'
971 * This hook is called when locating CiviCase types.
973 * @param array $caseTypes
977 public static function caseTypes(&$caseTypes) {
978 return self
::singleton()->invoke(1, $caseTypes, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_caseTypes');
982 * This hook is called soon after the CRM_Core_Config object has ben initialized.
983 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
985 * @param CRM_Core_Config|array $config
990 public static function config(&$config) {
991 return self
::singleton()->invoke(1, $config,
992 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
999 * @param int $recordID
1004 public static function enableDisable($recordBAO, $recordID, $isActive) {
1005 return self
::singleton()->invoke(3, $recordBAO, $recordID, $isActive,
1006 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1007 'civicrm_enableDisable'
1012 * This hooks allows to change option values
1014 * @param array $options
1015 * Associated array of option values / id
1016 * @param string $name
1021 public static function optionValues(&$options, $name) {
1022 return self
::singleton()->invoke(2, $options, $name,
1023 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1024 'civicrm_optionValues'
1029 * This hook allows modification of the navigation menu.
1031 * @param array $params
1032 * Associated array of navigation menu entry to Modify/Add
1036 public static function navigationMenu(&$params) {
1037 return self
::singleton()->invoke(1, $params,
1038 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1039 'civicrm_navigationMenu'
1044 * This hook allows modification of the data used to perform merging of duplicates.
1046 * @param string $type
1047 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1048 * @param array $data
1049 * The data, as described in $type.
1050 * @param int $mainId
1051 * Contact_id of the contact that survives the merge.
1052 * @param int $otherId
1053 * Contact_id of the contact that will be absorbed and deleted.
1054 * @param array $tables
1055 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
1059 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
1060 return self
::singleton()->invoke(5, $type, $data, $mainId, $otherId, $tables, self
::$_nullObject, 'civicrm_merge');
1064 * This hook provides a way to override the default privacy behavior for notes.
1066 * @param array &$noteValues
1067 * Associative array of values for this note
1071 public static function notePrivacy(&$noteValues) {
1072 return self
::singleton()->invoke(1, $noteValues,
1073 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1074 'civicrm_notePrivacy'
1079 * This hook is called before record is exported as CSV
1081 * @param string $exportTempTable
1082 * Name of the temporary export table used during export.
1083 * @param array $headerRows
1084 * Header rows for output.
1085 * @param array $sqlColumns
1087 * @param int $exportMode
1088 * Export mode ( contact, contribution, etc...).
1092 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, &$exportMode) {
1093 return self
::singleton()->invoke(4, $exportTempTable, $headerRows, $sqlColumns, $exportMode,
1094 self
::$_nullObject, self
::$_nullObject,
1100 * This hook allows modification of the queries constructed from dupe rules.
1102 * @param string $obj
1103 * Object of rulegroup class.
1104 * @param string $type
1105 * Type of queries e.g table / threshold.
1106 * @param array $query
1111 public static function dupeQuery($obj, $type, &$query) {
1112 return self
::singleton()->invoke(3, $obj, $type, $query,
1113 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1119 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1121 * @param string $type
1122 * Type of mail processed: 'activity' OR 'mailing'.
1123 * @param array &$params the params that were sent to the CiviCRM API function
1124 * @param object $mail
1125 * The mail object which is an ezcMail class.
1126 * @param array &$result the result returned by the api call
1127 * @param string $action
1128 * (optional ) the requested action to be performed if the types was 'mailing'.
1132 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
1133 return self
::singleton()->invoke(5, $type, $params, $mail, $result, $action, self
::$_nullObject, 'civicrm_emailProcessor');
1137 * This hook is called after a row has been processed and the
1138 * record (and associated records imported
1140 * @param string $object
1141 * Object being imported (for now Contact only, later Contribution, Activity,.
1142 * Participant and Member)
1143 * @param string $usage
1144 * Hook usage/location (for now process only, later mapping and others).
1145 * @param string $objectRef
1146 * Import record object.
1147 * @param array $params
1148 * Array with various key values: currently.
1149 * contactID - contact id
1150 * importID - row id in temp table
1151 * importTempTable - name of tempTable
1152 * fieldHeaders - field headers
1153 * fields - import fields
1157 public static function import($object, $usage, &$objectRef, &$params) {
1158 return self
::singleton()->invoke(4, $object, $usage, $objectRef, $params,
1159 self
::$_nullObject, self
::$_nullObject,
1165 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
1166 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
1168 * @param string $entity
1169 * The API entity (like contact).
1170 * @param string $action
1171 * The API action (like get).
1172 * @param array &$params the API parameters
1173 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
1177 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
1178 return self
::singleton()->invoke(4, $entity, $action, $params, $permissions,
1179 self
::$_nullObject, self
::$_nullObject,
1180 'civicrm_alterAPIPermissions'
1185 * @param CRM_Core_DAO $dao
1189 public static function postSave(&$dao) {
1190 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1191 return self
::singleton()->invoke(1, $dao,
1192 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1198 * This hook allows user to customize context menu Actions on contact summary page.
1200 * @param array $actions
1201 * Array of all Actions in contextmenu.
1202 * @param int $contactID
1203 * ContactID for the summary page.
1207 public static function summaryActions(&$actions, $contactID = NULL) {
1208 return self
::singleton()->invoke(2, $actions, $contactID,
1209 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1210 'civicrm_summaryActions'
1215 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1216 * This enables us hook implementors to modify both the headers and the rows
1218 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1219 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1221 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1222 * you want displayed. This is a hackish, but avoids template modification.
1224 * @param string $objectName
1225 * The component name that we are doing the search.
1226 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
1227 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1228 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
1231 * @internal param array $seletor the selector object. Allows you access to the context of the search
1233 * @return void modify the header and values object to pass the data u need
1235 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
1236 return self
::singleton()->invoke(4, $objectName, $headers, $rows, $selector,
1237 self
::$_nullObject, self
::$_nullObject,
1238 'civicrm_searchColumns'
1243 * This hook is called when uf groups are being built for a module.
1245 * @param string $moduleName
1247 * @param array $ufGroups
1248 * Array of ufgroups for a module.
1252 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
1253 return self
::singleton()->invoke(2, $moduleName, $ufGroups,
1254 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1255 'civicrm_buildUFGroupsForModule'
1260 * This hook is called when we are determining the contactID for a specific
1263 * @param string $email
1264 * The email address.
1265 * @param int $contactID
1266 * The contactID that matches this email address, IF it exists.
1267 * @param array $result
1268 * (reference) has two fields.
1269 * contactID - the new (or same) contactID
1270 * action - 3 possible values:
1271 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1272 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1273 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
1277 public static function emailProcessorContact($email, $contactID, &$result) {
1278 return self
::singleton()->invoke(3, $email, $contactID, $result,
1279 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1280 'civicrm_emailProcessorContact'
1285 * Hook definition for altering the generation of Mailing Labels
1287 * @param array $args
1288 * An array of the args in the order defined for the tcpdf multiCell api call.
1289 * with the variable names below converted into string keys (ie $w become 'w'
1290 * as the first key for $args)
1291 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1292 * float $h Cell minimum height. The cell extends automatically if needed.
1293 * string $txt String to print
1294 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1295 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1296 * a string containing some or all of the following characters (in any order):
1297 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1298 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1299 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1300 * (default value when $ishtml=false)</li></ul>
1301 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1302 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1303 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1304 * float $x x position in user units
1305 * float $y y position in user units
1306 * boolean $reseth if true reset the last cell height (default true).
1307 * int $stretch stretch carachter mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
1308 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1309 * necessary</li><li>4 = forced character spacing</li></ul>
1310 * boolean $ishtml set to true if $txt is HTML content (default = false).
1311 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1312 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1313 * or 0 for disable this feature. This feature works only when $ishtml=false.
1317 public static function alterMailingLabelParams(&$args) {
1318 return self
::singleton()->invoke(1, $args,
1319 self
::$_nullObject, self
::$_nullObject,
1320 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1321 'civicrm_alterMailingLabelParams'
1326 * This hooks allows alteration of generated page content
1329 * Previously generated content.
1331 * Context of content - page or form.
1333 * The file name of the tpl.
1335 * A reference to the page or form object.
1339 public static function alterContent(&$content, $context, $tplName, &$object) {
1340 return self
::singleton()->invoke(4, $content, $context, $tplName, $object,
1341 self
::$_nullObject, self
::$_nullObject,
1342 'civicrm_alterContent'
1347 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1348 * altercontent hook as the content has already been rendered through the tpl at that point
1351 * Previously generated content.
1353 * Reference to the form object.
1355 * Context of content - page or form.
1357 * Reference the file name of the tpl.
1361 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
1362 return self
::singleton()->invoke(4, $formName, $form, $context, $tplName,
1363 self
::$_nullObject, self
::$_nullObject,
1364 'civicrm_alterTemplateFile'
1369 * This hook collects the trigger definition from all components
1372 * @param string $tableName
1373 * (optional) the name of the table that we are interested in only.
1375 * @internal param \reference $triggerInfo to an array of trigger information
1376 * each element has 4 fields:
1377 * table - array of tableName
1378 * when - BEFORE or AFTER
1379 * event - array of eventName - INSERT OR UPDATE OR DELETE
1380 * sql - array of statements optionally terminated with a ;
1381 * a statement can use the tokes {tableName} and {eventName}
1382 * to do token replacement with the table / event. This allows
1383 * templatizing logging and other hooks
1386 public static function triggerInfo(&$info, $tableName = NULL) {
1387 return self
::singleton()->invoke(2, $info, $tableName,
1388 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1390 'civicrm_triggerInfo'
1395 * This hook is called when a module-extension is installed.
1396 * Each module will receive hook_civicrm_install during its own installation (but not during the
1397 * installation of unrelated modules).
1399 public static function install() {
1400 return self
::singleton()->invoke(0, self
::$_nullObject,
1401 self
::$_nullObject, self
::$_nullObject,
1402 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1408 * This hook is called when a module-extension is uninstalled.
1409 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1410 * uninstallation of unrelated modules).
1412 public static function uninstall() {
1413 return self
::singleton()->invoke(0, self
::$_nullObject,
1414 self
::$_nullObject, self
::$_nullObject,
1415 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1421 * This hook is called when a module-extension is re-enabled.
1422 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1423 * re-enablement of unrelated modules).
1425 public static function enable() {
1426 return self
::singleton()->invoke(0, self
::$_nullObject,
1427 self
::$_nullObject, self
::$_nullObject,
1428 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1434 * This hook is called when a module-extension is disabled.
1435 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1436 * disablement of unrelated modules).
1438 public static function disable() {
1439 return self
::singleton()->invoke(0, self
::$_nullObject,
1440 self
::$_nullObject, self
::$_nullObject,
1441 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1453 public static function alterReportVar($varType, &$var, &$object) {
1454 return self
::singleton()->invoke(3, $varType, $var, $object,
1456 self
::$_nullObject, self
::$_nullObject,
1457 'civicrm_alterReportVar'
1462 * This hook is called to drive database upgrades for extension-modules.
1465 * The type of operation being performed; 'check' or 'enqueue'.
1466 * @param CRM_Queue_Queue $queue
1467 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
1470 * NULL, if $op is 'enqueue'.
1471 * TRUE, if $op is 'check' and upgrades are pending.
1472 * FALSE, if $op is 'check' and upgrades are not pending.
1474 public static function upgrade($op, CRM_Queue_Queue
$queue = NULL) {
1475 return self
::singleton()->invoke(2, $op, $queue,
1476 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1483 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1485 * @param array $params
1486 * The mailing parameters. Array fields include: groupName, from, toName,
1487 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1488 * attachments (array)
1492 public static function postEmailSend(&$params) {
1493 return self
::singleton()->invoke(1, $params,
1494 self
::$_nullObject, self
::$_nullObject,
1495 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1496 'civicrm_postEmailSend'
1501 * This hook is called when Settings specifications are loaded
1503 * @param array $settingsFolders
1504 * List of paths from which to derive metadata
1508 public static function alterSettingsFolders(&$settingsFolders) {
1509 return self
::singleton()->invoke(1, $settingsFolders,
1510 self
::$_nullObject, self
::$_nullObject,
1511 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1512 'civicrm_alterSettingsFolders'
1517 * This hook is called when Settings have been loaded from the xml
1518 * It is an opportunity for hooks to alter the data
1520 * @param array $settingsMetaData
1521 * Settings Metadata.
1522 * @param int $domainID
1523 * @param mixed $profile
1527 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
1528 return self
::singleton()->invoke(3, $settingsMetaData,
1529 $domainID, $profile,
1530 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1531 'civicrm_alterSettingsMetaData'
1536 * This hook is called before running an api call.
1538 * @param API_Wrapper[] $wrappers
1539 * (see CRM_Utils_API_ReloadOption as an example)
1540 * @param mixed $apiRequest
1543 * The return value is ignored
1545 public static function apiWrappers(&$wrappers, $apiRequest) {
1546 return self
::singleton()
1547 ->invoke(2, $wrappers, $apiRequest, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1548 self
::$_nullObject, 'civicrm_apiWrappers'
1553 * This hook is called before running pending cron jobs.
1555 * @param CRM_Core_JobManager $jobManager
1558 * The return value is ignored.
1560 public static function cron($jobManager) {
1561 return self
::singleton()->invoke(1,
1562 $jobManager, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1568 * This hook is called when loading CMS permissions; use this hook to modify
1569 * the array of system permissions for CiviCRM.
1571 * @param array $permissions
1572 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1573 * the format of this array.
1576 * The return value is ignored
1578 public static function permission(&$permissions) {
1579 return self
::singleton()->invoke(1, $permissions,
1580 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1581 'civicrm_permission'
1586 * @param CRM_Core_Exception Exception $exception
1587 * @param mixed $request
1588 * Reserved for future use.
1590 static function unhandledException($exception, $request = NULL) {
1591 self
::singleton()->invoke(2, $exception, $request, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_unhandled_exception');
1593 //$event = new stdClass();
1594 //$event->exception = $exception;
1595 //CRM_Core_LegacyErrorHandler::handleException($event);
1598 $event = new \Civi\Core\Event\
UnhandledExceptionEvent($exception, self
::$_nullObject);
1599 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_unhandled_exception", $event);
1603 * This hook is called for declaring managed entities via API
1605 * @param array[] $entityTypes
1606 * List of entity types; each entity-type is an array with keys:
1607 * - name: string, a unique short name (e.g. "ReportInstance")
1608 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
1609 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
1612 * The return value is ignored
1614 public static function entityTypes(&$entityTypes) {
1615 return self
::singleton()->invoke(1, $entityTypes, self
::$_nullObject, self
::$_nullObject,
1616 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_entityTypes'
1621 * This hook is called while preparing a profile form
1623 * @param string $name
1626 public static function buildProfile($name) {
1627 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1628 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildProfile');
1632 * This hook is called while validating a profile form submission
1634 * @param string $name
1637 public static function validateProfile($name) {
1638 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1639 self
::$_nullObject, self
::$_nullObject, 'civicrm_validateProfile');
1643 * This hook is called processing a valid profile form submission
1645 * @param string $name
1648 public static function processProfile($name) {
1649 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1650 self
::$_nullObject, self
::$_nullObject, 'civicrm_processProfile');
1654 * This hook is called while preparing a read-only profile screen
1656 * @param string $name
1659 public static function viewProfile($name) {
1660 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1661 self
::$_nullObject, self
::$_nullObject, 'civicrm_viewProfile');
1665 * This hook is called while preparing a list of contacts (based on a profile)
1667 * @param string $name
1670 public static function searchProfile($name) {
1671 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1672 self
::$_nullObject, self
::$_nullObject, 'civicrm_searchProfile');
1676 * This hook is invoked when building a CiviCRM name badge.
1678 * @param string $labelName
1679 * String referencing name of badge format.
1680 * @param object $label
1681 * Reference to the label object.
1682 * @param array $format
1683 * Array of format data.
1684 * @param array $participant
1685 * Array of participant values.
1687 * @return null the return value is ignored
1689 public static function alterBadge($labelName, &$label, &$format, &$participant) {
1690 return self
::singleton()->invoke(4, $labelName, $label, $format, $participant, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBadge');
1695 * This hook is called before encoding data in barcode
1697 * @param array $data
1698 * Associated array of values available for encoding.
1699 * @param string $type
1700 * Type of barcode, classic barcode or QRcode.
1701 * @param string $context
1702 * Where this hooks is invoked.
1706 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
1707 return self
::singleton()->invoke(3, $data, $type, $context, self
::$_nullObject,
1708 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBarcode');
1712 * Modify or replace the Mailer object used for outgoing mail.
1714 * @param object $mailer
1715 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
1716 * @param string $driver
1717 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
1718 * @param array $params
1719 * The default mailer config options
1722 * @see Mail::factory
1724 public static function alterMail(&$mailer, $driver, $params) {
1725 return self
::singleton()
1726 ->invoke(3, $mailer, $driver, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterMailer');
1730 * This hook is called while building the core search query,
1731 * so hook implementers can provide their own query objects which alters/extends core search.
1733 * @param array $queryObjects
1734 * @param string $type
1738 public static function queryObjects(&$queryObjects, $type = 'Contact') {
1739 return self
::singleton()->invoke(2, $queryObjects, $type, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_queryObjects');
1743 * This hook is called while viewing contact dashboard
1745 * @param array $availableDashlets
1746 * List of dashlets; each is formatted per api/v3/Dashboard
1747 * @param array $defaultDashlets
1748 * List of dashlets; each is formatted per api/v3/DashboardContact
1752 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
1753 return self
::singleton()->invoke(2, $availableDashlets, $defaultDashlets, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_dashboard_defaults');
1757 * This hook is called before a case merge (or a case reassign)
1759 * @param int $mainContactId
1760 * @param int $mainCaseId
1761 * @param int $otherContactId
1762 * @param int $otherCaseId
1763 * @param bool $changeClient
1767 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
1768 return self
::singleton()->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_pre_case_merge');
1772 * This hook is called after a case merge (or a case reassign)
1774 * @param int $mainContactId
1775 * @param int $mainCaseId
1776 * @param int $otherContactId
1777 * @param int $otherCaseId
1778 * @param bool $changeClient
1782 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
1783 return self
::singleton()->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_post_case_merge');
1788 * Add a hook for altering the display name
1790 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
1792 * @param string $displayName
1793 * @param int $contactId
1794 * @param object $dao
1795 * The contact object.
1799 public static function alterDisplayName($displayName, $contactId, $dao) {
1800 return self
::singleton()->invoke(3,
1801 $displayName, $contactId, $dao, self
::$_nullObject, self
::$_nullObject,
1802 self
::$_nullObject, 'civicrm_contact_get_displayname'
1807 * EXPERIMENTAL: This hook allows one to register additional Angular modules
1809 * @param array $angularModules
1811 * @return null the return value is ignored
1814 * function mymod_civicrm_angularModules(&$angularModules) {
1815 * $angularModules['myAngularModule'] = array('ext' => 'org.example.mymod', 'js' => array('js/myAngularModule.js'));
1816 * $angularModules['myBigAngularModule'] = array('ext' => 'org.example.mymod', 'js' => array('js/part1.js', 'js/part2.js'), 'css' => array('css/myAngularModule.css'));
1820 public static function angularModules(&$angularModules) {
1821 return self
::singleton()->invoke(1, $angularModules,
1822 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1823 'civicrm_angularModules'
1828 * This hook fires whenever a record in a case changes.
1830 * @param \Civi\CCase\Analyzer $analyzer
1832 public static function caseChange(\Civi\CCase\Analyzer
$analyzer) {
1833 $event = new \Civi\CCase\Event\
CaseChangeEvent($analyzer);
1834 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_caseChange", $event);
1836 return self
::singleton()->invoke(1, $angularModules,
1837 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1838 'civicrm_caseChange'
1843 * Generate a default CRUD URL for an entity
1845 * @param array $spec
1847 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
1848 * - entity_table: string
1850 * @param CRM_Core_DAO $bao
1851 * @param array $link
1852 * To define the link, add these keys to $link:.
1856 * - url: string (used in lieu of "path"/"query")
1857 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
1860 public static function crudLink($spec, $bao, &$link) {
1861 return self
::singleton()->invoke(3, $spec, $bao, $link,
1862 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1868 * @param array<CRM_Core_FileSearchInterface> $fileSearches
1871 public static function fileSearches(&$fileSearches) {
1872 return self
::singleton()->invoke(1, $fileSearches,
1873 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1874 'civicrm_fileSearches'