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
60 static private $_singleton = NULL;
65 private $commonIncluded = FALSE;
70 private $commonCiviModules = array();
73 * Constructor and getter for the singleton instance.
78 * An instance of $config->userHookClass
80 public static function singleton($fresh = FALSE) {
81 if (self
::$_singleton == NULL ||
$fresh) {
82 $config = CRM_Core_Config
::singleton();
83 $class = $config->userHookClass
;
84 require_once str_replace('_', DIRECTORY_SEPARATOR
, $config->userHookClass
) . '.php';
85 self
::$_singleton = new $class();
87 return self
::$_singleton;
93 * @param int $numParams
94 * Number of parameters to pass to the hook.
96 * Parameter to be passed 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.
107 * @param string $fnSuffix
108 * Function suffix, this is effectively the hook name.
112 public abstract function invoke(
114 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
119 * @param array $numParams
131 public function commonInvoke(
133 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
137 $this->commonBuildModuleList($fnPrefix);
139 return $this->runHooks($this->commonCiviModules
, $fnSuffix,
140 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
145 * Build the list of modules to be processed for hooks.
147 * @param string $fnPrefix
149 public function commonBuildModuleList($fnPrefix) {
150 if (!$this->commonIncluded
) {
151 // include external file
152 $this->commonIncluded
= TRUE;
154 $config = CRM_Core_Config
::singleton();
155 if (!empty($config->customPHPPathDir
) &&
156 file_exists("{$config->customPHPPathDir}/civicrmHooks.php")
158 @include_once
"civicrmHooks.php";
161 if (!empty($fnPrefix)) {
162 $this->commonCiviModules
[$fnPrefix] = $fnPrefix;
165 $this->requireCiviModules($this->commonCiviModules
);
170 * @param $civiModules
172 * @param array $numParams
182 public function runHooks(
183 $civiModules, $fnSuffix, $numParams,
184 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
186 // $civiModules is *not* passed by reference because runHooks
187 // must be reentrant. PHP is finicky about running
188 // multiple loops over the same variable. The circumstances
189 // to reproduce the issue are pretty intricate.
192 if ($civiModules !== NULL) {
193 foreach ($civiModules as $module) {
194 $fnName = "{$module}_{$fnSuffix}";
195 if (function_exists($fnName)) {
197 switch ($numParams) {
199 $fResult = $fnName();
203 $fResult = $fnName($arg1);
207 $fResult = $fnName($arg1, $arg2);
211 $fResult = $fnName($arg1, $arg2, $arg3);
215 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
219 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
223 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
227 CRM_Core_Error
::fatal(ts('Invalid hook invocation'));
231 if (!empty($fResult) &&
234 $result = array_merge($result, $fResult);
240 return empty($result) ?
TRUE : $result;
246 public function requireCiviModules(&$moduleList) {
247 $civiModules = CRM_Core_PseudoConstant
::getModuleExtensions();
248 foreach ($civiModules as $civiModule) {
249 if (!file_exists($civiModule['filePath'])) {
250 CRM_Core_Session
::setStatus(
251 ts('Error loading module file (%1). Please restore the file or disable the module.',
252 array(1 => $civiModule['filePath'])),
253 ts('Warning'), 'error');
256 include_once $civiModule['filePath'];
257 $moduleList[$civiModule['prefix']] = $civiModule['prefix'];
262 * This hook is called before a db write on some core objects.
263 * This hook does not allow the abort of the operation
266 * The type of operation being performed.
267 * @param string $objectName
268 * The name of the object.
270 * The object id if available.
271 * @param array $params
272 * The parameters used for object creation / editing.
275 * the return value is ignored
277 public static function pre($op, $objectName, $id, &$params) {
278 $event = new \Civi\Core\Event\
PreEvent($op, $objectName, $id, $params);
279 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre", $event);
280 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre::$objectName", $event);
281 return self
::singleton()
282 ->invoke(4, $op, $objectName, $id, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_pre');
286 * This hook is called after a db write on some core objects.
289 * The type of operation being performed.
290 * @param string $objectName
291 * The name of the object.
292 * @param int $objectId
293 * The unique identifier for the object.
294 * @param object $objectRef
295 * The reference to the object if available.
298 * based on op. pre-hooks return a boolean or
299 * an error message which aborts the operation
301 public static function post($op, $objectName, $objectId, &$objectRef) {
302 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
303 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_post", $event);
304 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_post::$objectName", $event);
305 return self
::singleton()
306 ->invoke(4, $op, $objectName, $objectId, $objectRef, self
::$_nullObject, self
::$_nullObject, 'civicrm_post');
310 * This hook retrieves links from other modules and injects it into.
311 * the view contact tabs
314 * The type of operation being performed.
315 * @param string $objectName
316 * The name of the object.
317 * @param int $objectId
318 * The unique identifier for the object.
319 * @param array $links
320 * (optional) the links array (introduced in v3.2).
322 * (optional) the bitmask to show/hide links.
323 * @param array $values
324 * (optional) the values to fill the links.
327 * the return value is ignored
329 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = array()) {
330 return self
::singleton()->invoke(6, $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
334 * This hook is invoked during the CiviCRM form preProcess phase.
336 * @param string $formName
337 * The name of the form.
338 * @param CRM_Core_Form $form
339 * Reference to the form object.
342 * the return value is ignored
344 public static function preProcess($formName, &$form) {
345 return self
::singleton()
346 ->invoke(2, $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_preProcess');
350 * This hook is invoked when building a CiviCRM form. This hook should also
351 * be used to set the default values of a form element
353 * @param string $formName
354 * The name of the form.
355 * @param CRM_Core_Form $form
356 * Reference to the form object.
359 * the return value is ignored
361 public static function buildForm($formName, &$form) {
362 return self
::singleton()->invoke(2, $formName, $form,
363 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
369 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
370 * any form elements, this hook should save the values in the database
372 * @param string $formName
373 * The name of the form.
374 * @param CRM_Core_Form $form
375 * Reference to the form object.
378 * the return value is ignored
380 public static function postProcess($formName, &$form) {
381 return self
::singleton()->invoke(2, $formName, $form,
382 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
383 'civicrm_postProcess'
388 * This hook is invoked during all CiviCRM form validation. An array of errors
389 * detected is returned. Else we assume validation succeeded.
391 * @param string $formName
392 * The name of the form.
393 * @param array &$fields the POST parameters as filtered by QF
394 * @param array &$files the FILES parameters as sent in by POST
395 * @param array &$form the form object
398 * formRule hooks return a boolean or
399 * an array of error messages which display a QF Error
401 public static function validate($formName, &$fields, &$files, &$form) {
402 return self
::singleton()
403 ->invoke(4, $formName, $fields, $files, $form, self
::$_nullObject, self
::$_nullObject, 'civicrm_validate');
407 * This hook is invoked during all CiviCRM form validation. An array of errors
408 * detected is returned. Else we assume validation succeeded.
410 * @param string $formName
411 * The name of the form.
412 * @param array &$fields the POST parameters as filtered by QF
413 * @param array &$files the FILES parameters as sent in by POST
414 * @param array &$form the form object
415 * @param array &$errors the array of errors.
418 * formRule hooks return a boolean or
419 * an array of error messages which display a QF Error
421 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
422 return self
::singleton()
423 ->invoke(5, $formName, $fields, $files, $form, $errors, self
::$_nullObject, 'civicrm_validateForm');
427 * This hook is called before a db write on a custom table.
430 * The type of operation being performed.
431 * @param string $groupID
432 * The custom group ID.
433 * @param object $entityID
434 * The entityID of the row in the custom table.
435 * @param array $params
436 * The parameters that were sent into the calling function.
439 * the return value is ignored
441 public static function custom($op, $groupID, $entityID, &$params) {
442 return self
::singleton()
443 ->invoke(4, $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_custom');
447 * This hook is called when composing the ACL where clause to restrict
448 * visibility of contacts to the logged in user
451 * The type of permission needed.
452 * @param array $tables
453 * (reference ) add the tables that are needed for the select clause.
454 * @param array $whereTables
455 * (reference ) add the tables that are needed for the where clause.
456 * @param int $contactID
457 * The contactID for whom the check is made.
458 * @param string $where
459 * The currrent where clause.
462 * the return value is ignored
464 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
465 return self
::singleton()
466 ->invoke(5, $type, $tables, $whereTables, $contactID, $where, self
::$_nullObject, 'civicrm_aclWhereClause');
470 * This hook is called when composing the ACL where clause to restrict
471 * visibility of contacts to the logged in user
474 * The type of permission needed.
475 * @param int $contactID
476 * The contactID for whom the check is made.
477 * @param string $tableName
478 * The tableName which is being permissioned.
479 * @param array $allGroups
480 * The set of all the objects for the above table.
481 * @param array $currentGroups
482 * The set of objects that are currently permissioned for this contact.
485 * the return value is ignored
487 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
488 return self
::singleton()
489 ->invoke(5, $type, $contactID, $tableName, $allGroups, $currentGroups, self
::$_nullObject, 'civicrm_aclGroup');
493 * This hook is called when building the menu table.
495 * @param array $files
496 * The current set of files to process.
499 * the return value is ignored
501 public static function xmlMenu(&$files) {
502 return self
::singleton()->invoke(1, $files,
503 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
509 * This hook is called for declaring managed entities via API.
511 * @param array $entities
512 * List of pending entities. Each entity is an array with keys:
513 * + 'module': string; for module-extensions, this is the fully-qualifed name (e.g. "com.example.mymodule"); for CMS modules, the name is prefixed by the CMS (e.g. "drupal.mymodule")
514 * + 'name': string, a symbolic name which can be used to track this entity (Note: Each module creates its own namespace)
515 * + 'entity': string, an entity-type supported by the CiviCRM API (Note: this currently must be an entity which supports the 'is_active' property)
516 * + 'params': array, the entity data as supported by the CiviCRM API
517 * + 'update' (v4.5+): string, a policy which describes when to update records
518 * - 'always' (default): always update the managed-entity record; changes in $entities will override any local changes (eg by the site-admin)
519 * - 'never': never update the managed-entity record; changes made locally (eg by the site-admin) will override changes in $entities
520 * + 'cleanup' (v4.5+): string, a policy which describes whether to cleanup the record when it becomes orphaned (ie when $entities no longer references the record)
521 * - 'always' (default): always delete orphaned records
522 * - 'never': never delete orphaned records
523 * - 'unused': only delete orphaned records if there are no other references to it in the DB. (This is determined by calling the API's "getrefcount" action.)
526 * the return value is ignored
528 public static function managed(&$entities) {
529 return self
::singleton()->invoke(1, $entities,
530 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
536 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
538 * @param int $contactID
539 * The contactID for whom the dashboard is being rendered.
540 * @param int $contentPlacement
541 * (output parameter) where should the hook content be displayed.
542 * relative to the activity list
545 * the html snippet to include in the dashboard
547 public static function dashboard($contactID, &$contentPlacement = self
::DASHBOARD_BELOW
) {
548 $retval = self
::singleton()->invoke(2, $contactID, $contentPlacement,
549 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
554 * Note we need this seemingly unnecessary code because in the event that the implementation
555 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
556 * though we have a default value in this function's declaration above.
558 if (!isset($contentPlacement)) {
559 $contentPlacement = self
::DASHBOARD_BELOW
;
566 * This hook is called before storing recently viewed items.
568 * @param array $recentArray
569 * An array of recently viewed or processed items, for in place modification.
573 public static function recent(&$recentArray) {
574 return self
::singleton()->invoke(1, $recentArray,
575 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
581 * Determine how many other records refer to a given record.
583 * @param CRM_Core_DAO $dao
584 * The item for which we want a reference count.
585 * @param array $refCounts
586 * Each item in the array is an Array with keys:
587 * - name: string, eg "sql:civicrm_email:contact_id"
588 * - type: string, eg "sql"
589 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
592 public static function referenceCounts($dao, &$refCounts) {
593 return self
::singleton()->invoke(2, $dao, $refCounts,
594 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
595 'civicrm_referenceCounts'
600 * This hook is called when building the amount structure for a Contribution or Event Page.
602 * @param int $pageType
603 * Is this a contribution or event page.
604 * @param CRM_Core_Form $form
605 * Reference to the form object.
606 * @param array $amount
607 * The amount structure to be displayed.
611 public static function buildAmount($pageType, &$form, &$amount) {
612 return self
::singleton()->invoke(3, $pageType, $form, $amount, self
::$_nullObject,
613 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildAmount');
617 * This hook is called when building the state list for a particular country.
619 * @param array $countryID
620 * The country id whose states are being selected.
625 public static function buildStateProvinceForCountry($countryID, &$states) {
626 return self
::singleton()->invoke(2, $countryID, $states,
627 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
628 'civicrm_buildStateProvinceForCountry'
633 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
636 * The array of tabs that will be displayed.
637 * @param int $contactID
638 * The contactID for whom the dashboard is being rendered.
642 public static function tabs(&$tabs, $contactID) {
643 return self
::singleton()->invoke(2, $tabs, $contactID,
644 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabs'
649 * This hook is called when rendering the tabs used for events and potentially
650 * contribution pages, etc.
652 * @param string $tabsetName
653 * Name of the screen or visual element.
655 * Tabs that will be displayed.
656 * @param array $context
657 * Extra data about the screen or context in which the tab is used.
661 public static function tabset($tabsetName, &$tabs, $context) {
662 return self
::singleton()->invoke(3, $tabsetName, $tabs,
663 $context, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabset'
668 * This hook is called when sending an email / printing labels
670 * @param array $tokens
671 * The list of tokens that can be used for the contact.
675 public static function tokens(&$tokens) {
676 return self
::singleton()->invoke(1, $tokens,
677 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tokens'
682 * This hook is called when sending an email / printing labels to get the values for all the
683 * tokens returned by the 'tokens' hook
685 * @param array $details
686 * The array to store the token values indexed by contactIDs (unless it a single).
687 * @param array $contactIDs
688 * An array of contactIDs.
690 * The jobID if this is associated with a CiviMail mailing.
691 * @param array $tokens
692 * The list of tokens associated with the content.
693 * @param string $className
694 * The top level className from where the hook is invoked.
698 public static function tokenValues(
705 return self
::singleton()
706 ->invoke(5, $details, $contactIDs, $jobID, $tokens, $className, self
::$_nullObject, 'civicrm_tokenValues');
710 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
713 * @param object $page
714 * The page that will be rendered.
718 public static function pageRun(&$page) {
719 return self
::singleton()->invoke(1, $page,
720 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
726 * This hook is called after a copy of an object has been made. The current objects are
727 * Event, Contribution Page and UFGroup
729 * @param string $objectName
730 * Name of the object.
731 * @param object $object
732 * Reference to the copy.
736 public static function copy($objectName, &$object) {
737 return self
::singleton()->invoke(2, $objectName, $object,
738 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
744 * This hook is called when a contact unsubscribes from a mailing. It allows modules
745 * to override what the contacts are removed from.
749 * @param int $mailingId
750 * The id of the mailing to unsub from
751 * @param int $contactId
752 * The id of the contact who is unsubscribing
753 * @param array|int $groups
754 * Groups the contact will be removed from.
755 * @param array|int $baseGroups
756 * Base groups (used in smart mailings) the contact will be removed from.
761 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
762 return self
::singleton()
763 ->invoke(5, $op, $mailingId, $contactId, $groups, $baseGroups, self
::$_nullObject, 'civicrm_unsubscribeGroups');
767 * This hook is called when CiviCRM needs to edit/display a custom field with options (select, radio, checkbox,
770 * @param int $customFieldID
771 * The custom field ID.
772 * @param array $options
773 * The current set of options for that custom field.
774 * You can add/remove existing options.
775 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
776 * to be careful to not overwrite the array.
777 * Only add/edit/remove the specific field options you intend to affect.
778 * @param bool $detailedFormat
780 * the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
781 * @param array $selectAttributes
782 * Contain select attribute(s) if any.
786 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = array()) {
787 return self
::singleton()->invoke(3, $customFieldID, $options, $detailedFormat,
788 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
789 'civicrm_customFieldOptions'
795 * This hook is called to display the list of actions allowed after doing a search.
796 * This allows the module developer to inject additional actions or to remove existing actions.
798 * @param string $objectType
799 * The object type for this search.
800 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
801 * @param array $tasks
802 * The current set of tasks for that custom field.
803 * You can add/remove existing tasks.
804 * Each task needs to have a title (eg 'title' => ts( 'Add Contacts to Group')) and a class
805 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
806 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
807 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
808 * found in CRM/$objectType/Task.php.
812 public static function searchTasks($objectType, &$tasks) {
813 return self
::singleton()->invoke(2, $objectType, $tasks,
814 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
815 'civicrm_searchTasks'
821 * @param array $params
825 public static function eventDiscount(&$form, &$params) {
826 return self
::singleton()->invoke(2, $form, $params,
827 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
828 'civicrm_eventDiscount'
833 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
836 * The form object for which groups / mailings being displayed
837 * @param array $groups
838 * The list of groups being included / excluded
839 * @param array $mailings
840 * The list of mailings being included / excluded
844 public static function mailingGroups(&$form, &$groups, &$mailings) {
845 return self
::singleton()->invoke(3, $form, $groups, $mailings,
846 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
847 'civicrm_mailingGroups'
852 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
854 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
855 * You can use it to alter the membership types when first loaded, or after submission
856 * (for example if you want to gather data in the form and use it to alter the fees).
859 * The form object that is presenting the page
860 * @param array $membershipTypes
861 * The array of membership types and their amount
865 public static function membershipTypeValues(&$form, &$membershipTypes) {
866 return self
::singleton()->invoke(2, $form, $membershipTypes,
867 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
868 'civicrm_membershipTypeValues'
873 * This hook is called when rendering the contact summary.
875 * @param int $contactID
876 * The contactID for whom the summary is being rendered
877 * @param mixed $content
878 * @param int $contentPlacement
879 * Specifies where the hook content should be displayed relative to the
883 * The html snippet to include in the contact summary
885 public static function summary($contactID, &$content, &$contentPlacement = self
::SUMMARY_BELOW
) {
886 return self
::singleton()->invoke(3, $contactID, $content, $contentPlacement,
887 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
893 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
894 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
895 * If you want to limit the contacts returned to a specific group, or some other criteria
896 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
897 * The hook is called when the query is executed to get the list of contacts to display.
899 * @param mixed $query
900 * - the query that will be executed (input and output parameter);.
901 * It's important to realize that the ACL clause is built prior to this hook being fired,
902 * so your query will ignore any ACL rules that may be defined.
903 * Your query must return two columns:
904 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
906 * @param string $name
907 * The name string to execute the query against (this is the value being typed in by the user).
908 * @param string $context
909 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
911 * The id of the object for which the call is being made.
912 * For custom fields, it will be the custom field id
916 public static function contactListQuery(&$query, $name, $context, $id) {
917 return self
::singleton()->invoke(4, $query, $name, $context, $id,
918 self
::$_nullObject, self
::$_nullObject,
919 'civicrm_contactListQuery'
924 * Hook definition for altering payment parameters before talking to a payment processor back end.
926 * Definition will look like this:
928 * function hook_civicrm_alterPaymentProcessorParams($paymentObj,
929 * &$rawParams, &$cookedParams);
931 * @param string $paymentObj
932 * instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
933 * @param array &$rawParams
934 * array of params as passed to to the processor
935 * @param array &$cookedParams
936 * params after the processor code has translated them into its own key/value pairs
940 public static function alterPaymentProcessorParams(
945 return self
::singleton()->invoke(3, $paymentObj, $rawParams, $cookedParams,
946 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
947 'civicrm_alterPaymentProcessorParams'
952 * This hook is called when an email is about to be sent by CiviCRM.
954 * @param array $params
955 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
956 * returnPath, replyTo, headers, attachments (array)
957 * @param string $context
958 * The context in which the hook is being invoked, eg 'civimail'.
962 public static function alterMailParams(&$params, $context = NULL) {
963 return self
::singleton()->invoke(2, $params, $context,
964 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
965 'civicrm_alterMailParams'
970 * This hook is called when membership status is being calculated.
972 * @param array $membershipStatus
973 * Membership status details as determined - alter if required.
974 * @param array $arguments
975 * Arguments passed in to calculate date.
980 * - 'exclude_is_admin'
981 * - 'membership_type_id'
982 * @param array $membership
983 * Membership details from the calling function.
987 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
988 return self
::singleton()->invoke(3, $membershipStatus, $arguments,
989 $membership, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
990 'civicrm_alterCalculatedMembershipStatus'
995 * This hook is called when rendering the Manage Case screen.
1001 * Array of data to be displayed, where the key is a unique id to be used for styling (div id's)
1002 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
1004 public static function caseSummary($caseID) {
1005 return self
::singleton()->invoke(1, $caseID,
1006 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1007 'civicrm_caseSummary'
1012 * This hook is called when locating CiviCase types.
1014 * @param array $caseTypes
1018 public static function caseTypes(&$caseTypes) {
1019 return self
::singleton()
1020 ->invoke(1, $caseTypes, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_caseTypes');
1024 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1025 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
1027 * @param CRM_Core_Config|array $config
1032 public static function config(&$config) {
1033 return self
::singleton()->invoke(1, $config,
1034 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1040 * This hooks allows to change option values.
1042 * @param array $options
1043 * Associated array of option values / id
1044 * @param string $name
1049 public static function optionValues(&$options, $name) {
1050 return self
::singleton()->invoke(2, $options, $name,
1051 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1052 'civicrm_optionValues'
1057 * This hook allows modification of the navigation menu.
1059 * @param array $params
1060 * Associated array of navigation menu entry to Modify/Add
1064 public static function navigationMenu(&$params) {
1065 return self
::singleton()->invoke(1, $params,
1066 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1067 'civicrm_navigationMenu'
1072 * This hook allows modification of the data used to perform merging of duplicates.
1074 * @param string $type
1075 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1076 * @param array $data
1077 * The data, as described in $type.
1078 * @param int $mainId
1079 * Contact_id of the contact that survives the merge.
1080 * @param int $otherId
1081 * Contact_id of the contact that will be absorbed and deleted.
1082 * @param array $tables
1083 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
1087 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
1088 return self
::singleton()->invoke(5, $type, $data, $mainId, $otherId, $tables, self
::$_nullObject, 'civicrm_merge');
1092 * This hook provides a way to override the default privacy behavior for notes.
1094 * @param array &$noteValues
1095 * Associative array of values for this note
1099 public static function notePrivacy(&$noteValues) {
1100 return self
::singleton()->invoke(1, $noteValues,
1101 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1102 'civicrm_notePrivacy'
1107 * This hook is called before record is exported as CSV.
1109 * @param string $exportTempTable
1110 * Name of the temporary export table used during export.
1111 * @param array $headerRows
1112 * Header rows for output.
1113 * @param array $sqlColumns
1115 * @param int $exportMode
1116 * Export mode ( contact, contribution, etc...).
1120 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, &$exportMode) {
1121 return self
::singleton()->invoke(4, $exportTempTable, $headerRows, $sqlColumns, $exportMode,
1122 self
::$_nullObject, self
::$_nullObject,
1128 * This hook allows modification of the queries constructed from dupe rules.
1130 * @param string $obj
1131 * Object of rulegroup class.
1132 * @param string $type
1133 * Type of queries e.g table / threshold.
1134 * @param array $query
1139 public static function dupeQuery($obj, $type, &$query) {
1140 return self
::singleton()->invoke(3, $obj, $type, $query,
1141 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1147 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1149 * @param string $type
1150 * Type of mail processed: 'activity' OR 'mailing'.
1151 * @param array &$params the params that were sent to the CiviCRM API function
1152 * @param object $mail
1153 * The mail object which is an ezcMail class.
1154 * @param array &$result the result returned by the api call
1155 * @param string $action
1156 * (optional ) the requested action to be performed if the types was 'mailing'.
1160 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
1161 return self
::singleton()
1162 ->invoke(5, $type, $params, $mail, $result, $action, self
::$_nullObject, 'civicrm_emailProcessor');
1166 * This hook is called after a row has been processed and the
1167 * record (and associated records imported
1169 * @param string $object
1170 * Object being imported (for now Contact only, later Contribution, Activity,.
1171 * Participant and Member)
1172 * @param string $usage
1173 * Hook usage/location (for now process only, later mapping and others).
1174 * @param string $objectRef
1175 * Import record object.
1176 * @param array $params
1177 * Array with various key values: currently.
1178 * contactID - contact id
1179 * importID - row id in temp table
1180 * importTempTable - name of tempTable
1181 * fieldHeaders - field headers
1182 * fields - import fields
1186 public static function import($object, $usage, &$objectRef, &$params) {
1187 return self
::singleton()->invoke(4, $object, $usage, $objectRef, $params,
1188 self
::$_nullObject, self
::$_nullObject,
1194 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
1195 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
1197 * @param string $entity
1198 * The API entity (like contact).
1199 * @param string $action
1200 * The API action (like get).
1201 * @param array &$params the API parameters
1202 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
1206 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
1207 return self
::singleton()->invoke(4, $entity, $action, $params, $permissions,
1208 self
::$_nullObject, self
::$_nullObject,
1209 'civicrm_alterAPIPermissions'
1214 * @param CRM_Core_DAO $dao
1218 public static function postSave(&$dao) {
1219 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1220 return self
::singleton()->invoke(1, $dao,
1221 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1227 * This hook allows user to customize context menu Actions on contact summary page.
1229 * @param array $actions
1230 * Array of all Actions in contextmenu.
1231 * @param int $contactID
1232 * ContactID for the summary page.
1236 public static function summaryActions(&$actions, $contactID = NULL) {
1237 return self
::singleton()->invoke(2, $actions, $contactID,
1238 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1239 'civicrm_summaryActions'
1244 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1245 * This enables us hook implementors to modify both the headers and the rows
1247 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1248 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1250 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1251 * you want displayed. This is a hackish, but avoids template modification.
1253 * @param string $objectName
1254 * The component name that we are doing the search.
1255 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
1256 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1257 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
1258 * @param array $selector
1259 * the selector object. Allows you access to the context of the search
1262 * modify the header and values object to pass the data u need
1264 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
1265 return self
::singleton()->invoke(4, $objectName, $headers, $rows, $selector,
1266 self
::$_nullObject, self
::$_nullObject,
1267 'civicrm_searchColumns'
1272 * This hook is called when uf groups are being built for a module.
1274 * @param string $moduleName
1276 * @param array $ufGroups
1277 * Array of ufgroups for a module.
1281 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
1282 return self
::singleton()->invoke(2, $moduleName, $ufGroups,
1283 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1284 'civicrm_buildUFGroupsForModule'
1289 * This hook is called when we are determining the contactID for a specific
1292 * @param string $email
1293 * The email address.
1294 * @param int $contactID
1295 * The contactID that matches this email address, IF it exists.
1296 * @param array $result
1297 * (reference) has two fields.
1298 * contactID - the new (or same) contactID
1299 * action - 3 possible values:
1300 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1301 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1302 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
1306 public static function emailProcessorContact($email, $contactID, &$result) {
1307 return self
::singleton()->invoke(3, $email, $contactID, $result,
1308 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1309 'civicrm_emailProcessorContact'
1314 * Hook definition for altering the generation of Mailing Labels.
1316 * @param array $args
1317 * An array of the args in the order defined for the tcpdf multiCell api call.
1318 * with the variable names below converted into string keys (ie $w become 'w'
1319 * as the first key for $args)
1320 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1321 * float $h Cell minimum height. The cell extends automatically if needed.
1322 * string $txt String to print
1323 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1324 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1325 * a string containing some or all of the following characters (in any order):
1326 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1327 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1328 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1329 * (default value when $ishtml=false)</li></ul>
1330 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1331 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1332 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1333 * float $x x position in user units
1334 * float $y y position in user units
1335 * boolean $reseth if true reset the last cell height (default true).
1336 * int $stretch stretch carachter mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
1337 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1338 * necessary</li><li>4 = forced character spacing</li></ul>
1339 * boolean $ishtml set to true if $txt is HTML content (default = false).
1340 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1341 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1342 * or 0 for disable this feature. This feature works only when $ishtml=false.
1346 public static function alterMailingLabelParams(&$args) {
1347 return self
::singleton()->invoke(1, $args,
1348 self
::$_nullObject, self
::$_nullObject,
1349 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1350 'civicrm_alterMailingLabelParams'
1355 * This hooks allows alteration of generated page content.
1358 * Previously generated content.
1360 * Context of content - page or form.
1362 * The file name of the tpl.
1364 * A reference to the page or form object.
1368 public static function alterContent(&$content, $context, $tplName, &$object) {
1369 return self
::singleton()->invoke(4, $content, $context, $tplName, $object,
1370 self
::$_nullObject, self
::$_nullObject,
1371 'civicrm_alterContent'
1376 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1377 * altercontent hook as the content has already been rendered through the tpl at that point
1380 * Previously generated content.
1382 * Reference to the form object.
1384 * Context of content - page or form.
1386 * Reference the file name of the tpl.
1390 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
1391 return self
::singleton()->invoke(4, $formName, $form, $context, $tplName,
1392 self
::$_nullObject, self
::$_nullObject,
1393 'civicrm_alterTemplateFile'
1398 * This hook collects the trigger definition from all components.
1401 * @param string $tableName
1402 * (optional) the name of the table that we are interested in only.
1404 * @internal param \reference $triggerInfo to an array of trigger information
1405 * each element has 4 fields:
1406 * table - array of tableName
1407 * when - BEFORE or AFTER
1408 * event - array of eventName - INSERT OR UPDATE OR DELETE
1409 * sql - array of statements optionally terminated with a ;
1410 * a statement can use the tokes {tableName} and {eventName}
1411 * to do token replacement with the table / event. This allows
1412 * templatizing logging and other hooks
1415 public static function triggerInfo(&$info, $tableName = NULL) {
1416 return self
::singleton()->invoke(2, $info, $tableName,
1417 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1419 'civicrm_triggerInfo'
1424 * This hook is called when a module-extension is installed.
1425 * Each module will receive hook_civicrm_install during its own installation (but not during the
1426 * installation of unrelated modules).
1428 public static function install() {
1429 return self
::singleton()->invoke(0, self
::$_nullObject,
1430 self
::$_nullObject, self
::$_nullObject,
1431 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1437 * This hook is called when a module-extension is uninstalled.
1438 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1439 * uninstallation of unrelated modules).
1441 public static function uninstall() {
1442 return self
::singleton()->invoke(0, self
::$_nullObject,
1443 self
::$_nullObject, self
::$_nullObject,
1444 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1450 * This hook is called when a module-extension is re-enabled.
1451 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1452 * re-enablement of unrelated modules).
1454 public static function enable() {
1455 return self
::singleton()->invoke(0, self
::$_nullObject,
1456 self
::$_nullObject, self
::$_nullObject,
1457 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1463 * This hook is called when a module-extension is disabled.
1464 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1465 * disablement of unrelated modules).
1467 public static function disable() {
1468 return self
::singleton()->invoke(0, self
::$_nullObject,
1469 self
::$_nullObject, self
::$_nullObject,
1470 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1482 public static function alterReportVar($varType, &$var, &$object) {
1483 return self
::singleton()->invoke(3, $varType, $var, $object,
1485 self
::$_nullObject, self
::$_nullObject,
1486 'civicrm_alterReportVar'
1491 * This hook is called to drive database upgrades for extension-modules.
1494 * The type of operation being performed; 'check' or 'enqueue'.
1495 * @param CRM_Queue_Queue $queue
1496 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
1499 * NULL, if $op is 'enqueue'.
1500 * TRUE, if $op is 'check' and upgrades are pending.
1501 * FALSE, if $op is 'check' and upgrades are not pending.
1503 public static function upgrade($op, CRM_Queue_Queue
$queue = NULL) {
1504 return self
::singleton()->invoke(2, $op, $queue,
1505 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1512 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1514 * @param array $params
1515 * The mailing parameters. Array fields include: groupName, from, toName,
1516 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1517 * attachments (array)
1521 public static function postEmailSend(&$params) {
1522 return self
::singleton()->invoke(1, $params,
1523 self
::$_nullObject, self
::$_nullObject,
1524 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1525 'civicrm_postEmailSend'
1530 * This hook is called when Settings specifications are loaded.
1532 * @param array $settingsFolders
1533 * List of paths from which to derive metadata
1537 public static function alterSettingsFolders(&$settingsFolders) {
1538 return self
::singleton()->invoke(1, $settingsFolders,
1539 self
::$_nullObject, self
::$_nullObject,
1540 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1541 'civicrm_alterSettingsFolders'
1546 * This hook is called when Settings have been loaded from the xml
1547 * It is an opportunity for hooks to alter the data
1549 * @param array $settingsMetaData
1550 * Settings Metadata.
1551 * @param int $domainID
1552 * @param mixed $profile
1556 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
1557 return self
::singleton()->invoke(3, $settingsMetaData,
1558 $domainID, $profile,
1559 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1560 'civicrm_alterSettingsMetaData'
1565 * This hook is called before running an api call.
1567 * @param API_Wrapper[] $wrappers
1568 * (see CRM_Utils_API_ReloadOption as an example)
1569 * @param mixed $apiRequest
1572 * The return value is ignored
1574 public static function apiWrappers(&$wrappers, $apiRequest) {
1575 return self
::singleton()
1576 ->invoke(2, $wrappers, $apiRequest, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1577 self
::$_nullObject, 'civicrm_apiWrappers'
1582 * This hook is called before running pending cron jobs.
1584 * @param CRM_Core_JobManager $jobManager
1587 * The return value is ignored.
1589 public static function cron($jobManager) {
1590 return self
::singleton()->invoke(1,
1591 $jobManager, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1597 * This hook is called when loading CMS permissions; use this hook to modify
1598 * the array of system permissions for CiviCRM.
1600 * @param array $permissions
1601 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1602 * the format of this array.
1605 * The return value is ignored
1607 public static function permission(&$permissions) {
1608 return self
::singleton()->invoke(1, $permissions,
1609 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1610 'civicrm_permission'
1615 * @param CRM_Core_Exception Exception $exception
1616 * @param mixed $request
1617 * Reserved for future use.
1619 public static function unhandledException($exception, $request = NULL) {
1621 ->invoke(2, $exception, $request, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_unhandled_exception');
1623 //$event = new stdClass();
1624 //$event->exception = $exception;
1625 //CRM_Core_LegacyErrorHandler::handleException($event);
1628 $event = new \Civi\Core\Event\
UnhandledExceptionEvent($exception, self
::$_nullObject);
1629 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_unhandled_exception", $event);
1633 * This hook is called for declaring managed entities via API.
1635 * @param array[] $entityTypes
1636 * List of entity types; each entity-type is an array with keys:
1637 * - name: string, a unique short name (e.g. "ReportInstance")
1638 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
1639 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
1642 * The return value is ignored
1644 public static function entityTypes(&$entityTypes) {
1645 return self
::singleton()->invoke(1, $entityTypes, self
::$_nullObject, self
::$_nullObject,
1646 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_entityTypes'
1651 * This hook is called while preparing a profile form.
1653 * @param string $name
1656 public static function buildProfile($name) {
1657 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1658 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildProfile');
1662 * This hook is called while validating a profile form submission.
1664 * @param string $name
1667 public static function validateProfile($name) {
1668 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1669 self
::$_nullObject, self
::$_nullObject, 'civicrm_validateProfile');
1673 * This hook is called processing a valid profile form submission.
1675 * @param string $name
1678 public static function processProfile($name) {
1679 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1680 self
::$_nullObject, self
::$_nullObject, 'civicrm_processProfile');
1684 * This hook is called while preparing a read-only profile screen
1686 * @param string $name
1689 public static function viewProfile($name) {
1690 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1691 self
::$_nullObject, self
::$_nullObject, 'civicrm_viewProfile');
1695 * This hook is called while preparing a list of contacts (based on a profile)
1697 * @param string $name
1700 public static function searchProfile($name) {
1701 return self
::singleton()->invoke(1, $name, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1702 self
::$_nullObject, self
::$_nullObject, 'civicrm_searchProfile');
1706 * This hook is invoked when building a CiviCRM name badge.
1708 * @param string $labelName
1709 * String referencing name of badge format.
1710 * @param object $label
1711 * Reference to the label object.
1712 * @param array $format
1713 * Array of format data.
1714 * @param array $participant
1715 * Array of participant values.
1718 * the return value is ignored
1720 public static function alterBadge($labelName, &$label, &$format, &$participant) {
1721 return self
::singleton()
1722 ->invoke(4, $labelName, $label, $format, $participant, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBadge');
1727 * This hook is called before encoding data in barcode.
1729 * @param array $data
1730 * Associated array of values available for encoding.
1731 * @param string $type
1732 * Type of barcode, classic barcode or QRcode.
1733 * @param string $context
1734 * Where this hooks is invoked.
1738 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
1739 return self
::singleton()->invoke(3, $data, $type, $context, self
::$_nullObject,
1740 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBarcode');
1744 * Modify or replace the Mailer object used for outgoing mail.
1746 * @param object $mailer
1747 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
1748 * @param string $driver
1749 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
1750 * @param array $params
1751 * The default mailer config options
1754 * @see Mail::factory
1756 public static function alterMail(&$mailer, $driver, $params) {
1757 return self
::singleton()
1758 ->invoke(3, $mailer, $driver, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterMailer');
1762 * This hook is called while building the core search query,
1763 * so hook implementers can provide their own query objects which alters/extends core search.
1765 * @param array $queryObjects
1766 * @param string $type
1770 public static function queryObjects(&$queryObjects, $type = 'Contact') {
1771 return self
::singleton()
1772 ->invoke(2, $queryObjects, $type, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_queryObjects');
1776 * This hook is called while viewing contact dashboard.
1778 * @param array $availableDashlets
1779 * List of dashlets; each is formatted per api/v3/Dashboard
1780 * @param array $defaultDashlets
1781 * List of dashlets; each is formatted per api/v3/DashboardContact
1785 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
1786 return self
::singleton()
1787 ->invoke(2, $availableDashlets, $defaultDashlets, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_dashboard_defaults');
1791 * This hook is called before a case merge (or a case reassign)
1793 * @param int $mainContactId
1794 * @param int $mainCaseId
1795 * @param int $otherContactId
1796 * @param int $otherCaseId
1797 * @param bool $changeClient
1801 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
1802 return self
::singleton()
1803 ->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_pre_case_merge');
1807 * This hook is called after a case merge (or a case reassign)
1809 * @param int $mainContactId
1810 * @param int $mainCaseId
1811 * @param int $otherContactId
1812 * @param int $otherCaseId
1813 * @param bool $changeClient
1817 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
1818 return self
::singleton()
1819 ->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_post_case_merge');
1824 * Add a hook for altering the display name
1826 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
1828 * @param string $displayName
1829 * @param int $contactId
1830 * @param object $dao
1831 * The contact object.
1835 public static function alterDisplayName($displayName, $contactId, $dao) {
1836 return self
::singleton()->invoke(3,
1837 $displayName, $contactId, $dao, self
::$_nullObject, self
::$_nullObject,
1838 self
::$_nullObject, 'civicrm_contact_get_displayname'
1843 * EXPERIMENTAL: This hook allows one to register additional Angular modules
1845 * @param array $angularModules
1848 * the return value is ignored
1851 * function mymod_civicrm_angularModules(&$angularModules) {
1852 * $angularModules['myAngularModule'] = array(
1853 * 'ext' => 'org.example.mymod',
1854 * 'js' => array('js/myAngularModule.js'),
1856 * $angularModules['myBigAngularModule'] = array(
1857 * 'ext' => 'org.example.mymod',
1858 * 'js' => array('js/part1.js', 'js/part2.js'),
1859 * 'css' => array('css/myAngularModule.css'),
1860 * 'partials' => array('partials/myBigAngularModule'),
1865 public static function angularModules(&$angularModules) {
1866 return self
::singleton()->invoke(1, $angularModules,
1867 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1868 'civicrm_angularModules'
1873 * This hook fires whenever a record in a case changes.
1875 * @param \Civi\CCase\Analyzer $analyzer
1877 public static function caseChange(\Civi\CCase\Analyzer
$analyzer) {
1878 $event = new \Civi\CCase\Event\
CaseChangeEvent($analyzer);
1879 \Civi\Core\Container
::singleton()->get('dispatcher')->dispatch("hook_civicrm_caseChange", $event);
1881 return self
::singleton()->invoke(1, $angularModules,
1882 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1883 'civicrm_caseChange'
1888 * Generate a default CRUD URL for an entity.
1890 * @param array $spec
1892 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
1893 * - entity_table: string
1895 * @param CRM_Core_DAO $bao
1896 * @param array $link
1897 * To define the link, add these keys to $link:.
1901 * - url: string (used in lieu of "path"/"query")
1902 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
1905 public static function crudLink($spec, $bao, &$link) {
1906 return self
::singleton()->invoke(3, $spec, $bao, $link,
1907 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1913 * @param array <CRM_Core_FileSearchInterface> $fileSearches
1916 public static function fileSearches(&$fileSearches) {
1917 return self
::singleton()->invoke(1, $fileSearches,
1918 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1919 'civicrm_fileSearches'