From c858afbb4495533fa05e9c4f091afc80154fb394 Mon Sep 17 00:00:00 2001 From: Curtis Conard Date: Sat, 17 May 2025 11:54:08 -0400 Subject: [PATCH 1/3] add new hooks documentation --- source/plugins/hooks.rst | 1514 ++++++++++++++++++++++++++------------ 1 file changed, 1032 insertions(+), 482 deletions(-) diff --git a/source/plugins/hooks.rst b/source/plugins/hooks.rst index e99687ba..6c4f9099 100644 --- a/source/plugins/hooks.rst +++ b/source/plugins/hooks.rst @@ -1,713 +1,1263 @@ Hooks ----- -GLPI provides a certain amount of "hooks". Their goal is for plugins (mainly) to work on certain places of the framework; like when an item has been added, updated, deleted, ... +GLPI provides over 130 "hooks". Their goal is for plugins to be able to expand functionality of GLPI and react to specific events; like when an item has been added, updated, deleted, etc. +The hooks are primarily interacted with through the "$PLUGIN_HOOKS" global array from the plugin's ``init`` function. +Some hooks though are automatically called if a specific function exists in the plugin's ``hook.php`` file. -This page describes current existing hooks; but not the way they must be implemented from plugins. Please refer to the plugins development documentation. +This page describes the different currently existing hooks. For more information about plugin development, please refer to the plugins development documentation. -.. _standards_hooks: +Hooks +##### +ADD_CSS +******* + +Add CSS file in the head of all non-anonymous pages. + + + +ADD_JAVASCRIPT +************** + +Add classic JavaScript file in the head of all non-anonymous pages. + + + +ADD_JAVASCRIPT_MODULE +********************* + +Add ESM JavaScript module in the head of all non-anonymous pages. + + +ADD_HEADER_TAG +************** + +Add a header tag in the head of all non-anonymous pages. + + +JAVASCRIPT +********** + +Register one or more on-demand JavaScript files. +On-demand JS files are loaded based on the `$CFG_GLPI['javascript']` array. +Example: `$PLUGIN_HOOKS[Hooks::JAVASCRIPT]['your_js_name'] = ['path/to/your/file.js'];` + + +ADD_CSS_ANONYMOUS_PAGE +********************** + +Add CSS file in the head of all anonymous pages. + + +ADD_JAVASCRIPT_ANONYMOUS_PAGE +***************************** + +Add classic JavaScript file in the head of all anonymous pages. + + +ADD_JAVASCRIPT_MODULE_ANONYMOUS_PAGE +************************************ + +Add ESM JavaScript module in the head of all anonymous pages. + + +ADD_HEADER_TAG_ANONYMOUS_PAGE +***************************** + +Add a header tag in the head of all anonymous pages. + + +CHANGE_ENTITY +************* + +Register a function to be called when the entity is changed. + + +CHANGE_PROFILE +************** + +Register a function to be called when the profile is changed. + + +DISPLAY_LOGIN +************* + +Register a function to output some content on the login page. + + +DISPLAY_CENTRAL +*************** + +Register a function to output some content on the standard (central) or simplified interface (helpdesk) home page. +This hook is called inside a table element. + + +DISPLAY_NETPORT_LIST_BEFORE +*************************** + +Register a function to output some content before the network port list. + + +INIT_SESSION +************ + +Register a function to be called when the session is initialized. + + +POST_INIT +********* + +Register a function to be called after all plugins are initialized. + + +CONFIG_PAGE +*********** + +Register a URL relative to the plugin's root URL for the plugin's config page. + + +USE_MASSIVE_ACTION +****************** + +Set to true if the plugin wants to use the Hooks::AUTO_MASSIVE_ACTIONS hook. +Example: $PLUGIN_HOOKS[Hooks::USE_MASSIVE_ACTION]['myplugin'] = true; + + +ASSIGN_TO_TICKET +**************** + +Set to true if the plugin wants to use the Hooks::AUTO_ASSIGN_TO_TICKET hook. +Example: $PLUGIN_HOOKS[Hooks::ASSIGN_TO_TICKET]['myplugin'] = true; + + +IMPORT_ITEM +*********** + +Set to true if the plugin can import items. Adds the plugin as a source criteria for 'Rules for assigning an item to an entity' + + +RULE_MATCHED +************ + +Register a function to be called when the rules engine matches a rule. +The function is called with an array containing several properties including: +* 'sub_type' => The subtype of the rule (Example: RuleTicket) +* 'ruleid' => The ID of the rule +* 'input' => The input data sent to the rule engine +* 'output' => The current output data +The function is not expected to return anything and the data provided to it cannot be modified. + + +VCARD_DATA +********** + +Register a function to be called when a vCard is generated. +The function is called with an array containing several properties including: +* 'item' => The item for which the vCard is generated +* 'data' => The vCard data +The function is expected to modify the given array as needed and return it. + + +POST_PLUGIN_DISABLE +******************* + +Register a function to be called when the plugin is disabled. +The function is called with the plugin name as a parameter. + + +POST_PLUGIN_CLEAN +***************** + +Register a function to be called when the plugin is cleaned from the database. +The function is called with the plugin name as a parameter. + + +POST_PLUGIN_INSTALL +******************* + +Register a function to be called when the plugin is installed. +The function is called with the plugin name as a parameter. + + +POST_PLUGIN_UNINSTALL +********************* + +Register a function to be called when the plugin is uninstalled. +The function is called with the plugin name as a parameter. + + +POST_PLUGIN_ENABLE +****************** + +Register a function to be called when the plugin is enabled. +The function is called with the plugin name as a parameter. + + +DISPLAY_LOCKED_FIELDS +********************* + +Register a function to be called to show locked fields managed by the plugin. +The function is called with an array containing several properties including: +* 'item' => The item for which the locked fields are shown +* 'header' => Always false. //TODO WHY!? + + +PRE_KANBAN_CONTENT +****************** + +Register a function to define content to show before the main content of a Kanban card. +This function is called with an array containing several properties including: +* 'itemtype' => The type of the item represented by the Kanban card +* 'items_id' => The ID of the item represented by the Kanban card +The function is expected to return HTML content. + + +POST_KANBAN_CONTENT +******************* + +Register a function to define content to show after the main content of a Kanban card. +This function is called with an array containing several properties including: +* 'itemtype' => The type of the item represented by the Kanban card +* 'items_id' => The ID of the item represented by the Kanban card +The function is expected to return HTML content. + + +KANBAN_ITEM_METADATA +******************** + +Register a function to redefine metadata for a Kanban card. +This function is called with an array containing several properties including: +* 'itemtype' => The type of the item represented by the Kanban card +* 'items_id' => The ID of the item represented by the Kanban card +* 'metadata' => The current metadata for the Kanban card +The function is expected to modify the given array as needed and return it. + + +KANBAN_FILTERS +************** + +Define extra Kanban filters by itemtype. +Example: +``` +$PLUGIN_HOOKS[Hooks::KANBAN_FILTERS]['myplugin'] = [ + 'Ticket' => [ + 'new_metadata_property' => [ + 'description' => 'My new property' + 'supported_prefixes' => ['!'] + ] + ] +] +``` + + +PRE_KANBAN_PANEL_CONTENT +************************ + +Register a function to display content at the beginning of the item details panel in the Kanban. +The function is called with an array containing several properties including: +* 'itemtype' => The type of the item represented by the Kanban card +* 'items_id' => The ID of the item represented by the Kanban card +The function is expected to return HTML content. + + + +POST_KANBAN_PANEL_CONTENT +************************* + +Register a function to display content at the end of the item details panel in the Kanban. +The function is called with an array containing several properties including: +* 'itemtype' => The type of the item represented by the Kanban card +* 'items_id' => The ID of the item represented by the Kanban card +The function is expected to return HTML content. + + + +PRE_KANBAN_PANEL_MAIN_CONTENT +***************************** + +Register a function to display content at the beginning of the item details panel in the Kanban after the content from Hooks::PRE_KANBAN_PANEL_CONTENT but before the default main content. +The function is called with an array containing several properties including: +* 'itemtype' => The type of the item represented by the Kanban card +* 'items_id' => The ID of the item represented by the Kanban card +The function is expected to return HTML content. + + + +POST_KANBAN_PANEL_MAIN_CONTENT +****************************** + +Register a function to display content at the end of the item details panel in the Kanban after the default main content but before the content from Hooks::POST_KANBAN_PANEL_CONTENT. +The function is called with an array containing several properties including: +* 'itemtype' => The type of the item represented by the Kanban card +* 'items_id' => The ID of the item represented by the Kanban card +The function is expected to return HTML content. + + + +REDEFINE_MENUS +************** + +Register a function to redefine the GLPI menu. +The function is called with the current menu as a parameter. +The function is expected to modify the given array as needed and return it. + + + +RETRIEVE_MORE_DATA_FROM_LDAP +**************************** + +Register a function to get more user field data from LDAP. +The function is called with an array containing the current fields for the user along with: +* '_ldap_result' => The LDAP query result +* '_ldap_conn' => The LDAP connection resource +The function is expected to modify the given array as needed and return it. + + +RETRIEVE_MORE_FIELD_FROM_LDAP +***************************** + +Register a function to get more LDAP -> Field mappings. +The function is called with an array containing the current mappings. +The function is expected to modify the given array as needed and return it. + + + +RESTRICT_LDAP_AUTH +****************** + +Register a function to add additional checks to the LDAP authentication. +The function is called with an array containing several properties including: +* 'dn' => The DN of the user +* login field => Login field value where 'login field' is the name of the login field (usually samaccountname or uid) set in the LDAP config in GLPI. +* sync field => Sync field value where 'sync field' is the name of the sync field (usually objectguid or entryuuid) set in the LDAP config in GLPI + + +UNLOCK_FIELDS +************* + +Register a function to handle unlocking additional fields. +The function is called with the $_POST array containing several properties including: +* 'itemtype' => The type of the item for which the fields are unlocked +* 'id' => The ID of the item for which the fields are unlocked +* itemtype => Array of fields to unlock where 'itemtype' is the name of the item type (usually the same as the itemtype value). +The function is expected to return nothing. + + +UNDISCLOSED_CONFIG_VALUE +************************ + +Register a function to optionally hide a config value in certain locations such as the API. +The function is called with an array containing several properties including: +* 'context' => The context of the config option ('core' for core GLPI configs) +* 'name' => The name of the config option +* 'value' => The value of the config option +The function is expected to modify the given array as needed (typically unsetting the value if it should be hidden) and return it. + + +FILTER_ACTORS +************* + +Register a function to modify the actor results in the right panel of ITIL objects. +The function is called with an array containing several properties including: +* 'actors' => The current actor results +* 'params' => The parameters used to retrieve the actors +The function is expected to modify the given array as needed and return it. + + +DEFAULT_DISPLAY_PREFS +********************* + +Register a function to declare what the default display preferences are for an itemtype. +This is not used when no display preferences are set for the itemtype, but rather when hte preferences are being reset. +Therefore, defaults should be set during the plugin installation and the result of the function should be the same as the default values set in the plugin installation. +Core GLPI itemtypes with display preferences set in `install/empty_data.php` will never use this hook. +The function is called with an array containing several properties including: +* 'itemtype' => The type of the item for which the display preferences are set +* 'prefs' => The current defaults (usually empty unless also modified by another plugin) +The function is expected to modify the given array as needed and return it. + + +USE_RULES +********* + +Must be set to true for some other hooks to function including: +* Hooks::AUTO_GET_RULE_CRITERIA +* Hooks::AUTO_GET_RULE_ACTIONS +* Hooks::AUTO_RULE_COLLECTION_PREPARE_INPUT_DATA_FOR_PROCESS +* Hooks::AUTO_PRE_PROCESS_RULE_COLLECTION_PREVIEW_RESULTS +* Hooks::AUTO_RULEIMPORTASSET_GET_SQL_RESTRICTION +* Hooks::AUTO_RULEIMPORTASSET_ADD_GLOBAL_CRITERIA + + +ADD_RECIPIENT_TO_TARGET +*********************** + +Register a function to be called when a notification recipient is to be added. +The function is called with the NotificationTarget object as a parameter. +The function is expected to return nothing. +The added notification target information can be found in the `recipient_data` property of the object. Modifying this information will have no effect. +The current list of all added notification targets can be found in the `target` property of the object. +If you wish to remove/modify targets, you must do so in the `target` property. + + +AUTOINVENTORY_INFORMATION +************************* + +Register a function to be called to display some automatic inventory information. +The function is called with the item as a parameter. +The function is expected to return nothing, but the information may be output directly. +The function is only called for items that have the `is_dynamic` field, and it is set to 1. + + +INFOCOM +******* + +Register a function to be called to display extra Infocom form fields/information. +The function is called with the item as a parameter. +The function is expected to return nothing, but the information may be output directly. + + +ITEM_ACTION_TARGETS +******************* + +Register a function to handle adding a plugin-specific notification target. +The function is called with the NotificationTarget object as a parameter. +The function is expected to return nothing. +The notification target data can be found in the `data` property of the object. + + + +ITEM_ADD_TARGETS +**************** + +Register a function to handle adding new possible recipients for notification targets. +The function is called with the NotificationTarget object as a parameter. +The function is expected to return nothing. + + + +ITEM_EMPTY +********** + +Register a function to handle the 'item_empty' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +The hook is called at the very end of the process of initializing an empty item. + + + +PRE_ITEM_ADD +************ + +Register a function to handle the 'pre_item_add' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +This hook is called at the very beginning of the add process, before the input has been modified. +The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the add process. + + + +POST_PREPAREADD +*************** + +Register a function to handle the 'post_prepareadd' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +This hook is called after the input has been modified, but before the item is added to the database. +The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the add process. + + + +ITEM_ADD +******** + +Register a function to handle the 'item_add' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +This hook is called at the very end of the add process, after the item has been added to the database. + + +PRE_ITEM_UPDATE +*************** + +Register a function to handle the 'pre_item_update' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +This hook is called at the very beginning of the update process, before the input has been modified. +The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the update process. + + + +ITEM_UPDATE +*********** + +Register a function to handle the 'item_update' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +This hook is called at the very end of the update process, after the item has been updated in the database. +The input can be found in the `input` property of the item while the updated field names can be found in the `updates` property. +The old values of changed field can be found in the `oldvalues` property. + + +PRE_ITEM_DELETE +*************** + +Register a function to handle the 'pre_item_delete' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +This hook is called at the very beginning of the soft-deletion process. +The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the deletion process. + + +ITEM_DELETE +*********** + +Register a function to handle the 'item_delete' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +This hook is called at the very end of the soft-deletion process, after the item has been soft-deleted from the database (`is_deleted` set to 1). + + +PRE_ITEM_PURGE +************** + +Register a function to handle the 'pre_item_purge' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +This hook is called at the very beginning of the purge process. +The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the purge process. + + +ITEM_PURGE +********** + +Register a function to handle the 'item_purge' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +This hook is called at the very end of the purge process, after the item has been purged from the database. + + +PRE_ITEM_RESTORE +**************** + +Register a function to handle the 'pre_item_restore' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +This hook is called at the very beginning of the restore process. +The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the restore process. + + +ITEM_RESTORE +************ + +Register a function to handle the 'item_restore' lifecycle event for an item. +The function is called with the item as a parameter. +The function is expected to return nothing. +This hook is called at the very end of the restore process, after the item has been restored in the database (`is_deleted` set to 0). + + +ITEM_GET_DATA +************* + +Register a function to handle adding data for a notification target. +The function is called with the NotificationTarget object as a parameter. +The function is expected to return nothing. +The notification target data can be found in the `data` property of the object. + + + +ITEM_GET_EVENTS +*************** + +Register a function to handle adding events for a notification target. +The function is called with the NotificationTarget object as a parameter. +The function is expected to return nothing. +The notification target events can be found in the `events` property of the object. -Standards Hooks -^^^^^^^^^^^^^^^ -Usage -+++++ -Aside from their goals or when/where they're called; you will see three types of different hooks. Some will receive an item as parameter, others an array of parameters, and some won't receive anything. Basically, the way they're declared into your plugin, and the way you'll handle that will differ. +SHOW_ITEM_STATS +*************** -All hooks called are defined in the ``setup.php`` file of your plugin; into the ``$PLUGIN_HOOKS`` array. The first key is the hook name, the second your plugin name; values can be just text (to call a function declared in the ``hook.php`` file), or an array (to call a static method from an object): +Register a function to show additional statistics in the Statistics tab of Tickets, Changes and Problems. +The function is called with the item as a parameter. +The function is expected to return nothing, but the information may be output directly. -.. code-block:: php - The item for which the fields are shown +* 'options' => An array of form parameters -You will also have to declare the function you want to call in you ``hook.php`` file: -.. code-block:: php - The item for which the fields are shown + * 'options' => An array of form parameters -.. _hook_item_parameter: -With item as parameter -~~~~~~~~~~~~~~~~~~~~~~ -Those hooks will send you an item instance as parameter; you'll have to attach them to the itemtypes you want to apply on. Let's say you want to call the ``pre_item_update`` hook for `Computer` and `Phone` item types, in your ``setup.php`` you'll add something like: +ITEM_TRANSFER +************* -.. code-block:: php +Register a function to be called after an item is transferred to another entity. +The function is called with an array containing several properties including: +* 'type' => The type of the item being transferred. +* 'id' => The original ID of the item being transferred. +* 'newID' => The new ID of the item being transferred. If the item was cloned into the new entity, this ID will differ from the original ID. +* 'entities_id' => The ID of the destination entity. +The function is expected to return nothing. - 'myplugin_updateitem_called', - 'Phone' => 'myplugin_updateitem_called' - ]; -You will also have to declare the function you want to call in you ``hook.php`` file: +PRE_SHOW_ITEM +************* -.. code-block:: php +Register a function to be called before showing an item in the timeline of a Ticket, Change or Problem. +The function is called with the following parameters: +* 'item' => The item being shown in the timeline +* 'options' => An array containing the following properties: + * 'parent' => The Ticket, Change or Problem + * 'rand' => A random number that may be used for unique element IDs within the timeline item HTML +The function is expected to return nothing, but the information may be output directly. - ` expect they will send you an array of parameters instead of only an item instance. The array will contain two entries: ``item`` and ``options``, the first one is the item instance, the second options that have been passed: +Register a function to be called after showing an item in the timeline of a Ticket, Change or Problem. +The function is called with the following parameters: +* 'item' => The item being shown in the timeline +* 'options' => An array containing the following properties: + * 'parent' => The Ticket, Change or Problem + * 'rand' => A random number that may be used for unique element IDs within the timeline item HTML +The function is expected to return nothing, but the information may be output directly. -.. code-block:: php - Computer Object - // (...) - // - // [options] => Array - // ( - // [_target] => /front/computer.form.php - // [id] => 1 - // [withtemplate] => - // [tabnum] => 1 - // [itemtype] => Computer - // ) - //) - } -The hooks that are called with an array of parameters are: ``post_item_form``, ``pre_item_form``, ``pre_show_item``, ``post_show_item``, ``pre_show_tab``, ``post_show_tab``, ``pre_itil_info_section``, ``post_itil_info_section``, ``item_transfer``. +PRE_ITEM_FORM +************* -Some hooks will receive a specific array as parameter, they will be detailed below. +Register a function to show additional fields at the top of an item form. +The function is called with the following parameters: +* 'item' => The item for which the fields are shown +* 'options' => An array of form parameters +The function is expected to return nothing, but the information may be output directly. -Unclassified -++++++++++++ -Hooks that cannot be classified in above categories :) +POST_ITEM_FORM +************** -``secured_fields`` - .. versionadded:: 9.4.6 +Register a function to show additional fields at the bottom of an item form. +The function is called with the following parameters: +* 'item' => The item for which the fields are shown +* 'options' => An array of form parameters +The function is expected to return nothing, but the information may be output directly. - An array of fields names (with table like ``glpi_mytable.myfield``) that are stored using GLPI encrypting methods. - This allows plugins to add some fields to the ``glpi:security:changekey`` command. - .. warning:: +PRE_SHOW_TAB +************ - Plugins have to ensure crypt migration on their side is OK; and once using it, they **must** properly declare fields. +Register a function to show additional content before the main content in a tab. +This function is not called for the main tab of a form. +The function is called with the following parameters: +* 'item' => The item for which the tab is shown +* 'options' => An array containing the following properties: + * 'itemtype' => The type of the item being shown in the tab + * 'tabnum' => The number of the tab being shown for the itemtype +The function is expected to return HTML content or an empty string. - All fields that would use the key file without being listed would be unreadable after key has been changed (and stored data would stay potentially unsecure). -``secured_configs`` - .. versionadded:: 9.4.6 +POST_SHOW_TAB +************* - An array of configuration entries that are stored using GLPI encrypting methods. - This allows plugins to add some entries to the ``glpi:security:changekey`` command. +Register a function to show additional content after the main content in a tab. +This function is not called for the main tab of a form. +The function is called with the following parameters: +* 'item' => The item for which the tab is shown +* 'options' => An array containing the following properties: + * 'itemtype' => The type of the item being shown in the tab + * 'tabnum' => The number of the tab being shown for the itemtype +The function is expected to return HTML content or an empty string. - .. warning:: - Plugins have to ensure crypt migration on their side is OK; and once using it, they **must** properly declare fields. +PRE_ITEM_LIST +************* - All configuration entries that would use the key file without being listed would be unreadable after key has been changed (and stored data would stay potentially unsecure). +Register a function to show additional content before the search result list for an itemtype. +The function is called with the following parameters: +* 'itemtype' => The type of the item being shown in the list +* 'options' => Unused. Always an empty array. +The function is expected to return nothing, but the information may be output directly. -``add_javascript`` - Add javascript in **all** pages headers - .. versionadded:: 9.2 - Minified javascript files are checked automatically. You will just have to provide a minified file along with the original to get it used! +POST_ITEM_LIST +************** - The name of the minified ``plugin.js`` file must be ``plugin.min.js`` +Register a function to show additional content after the search result list for an itemtype. +The function is called with the following parameters: +* 'itemtype' => The type of the item being shown in the list +* 'options' => Unused. Always an empty array. +The function is expected to return nothing, but the information may be output directly. -``add_css`` - Add CSS stylesheet on **all** pages headers - .. versionadded:: 9.2 +TIMELINE_ACTIONS +**************** - Minified CSS files are checked automatically. You will just have to provide a minified file along with the original to get it used! +Register a function to show action buttons in the footer of a Ticket, Change or Problem timeline. +This is how timeline actions were displayed before version 10.0, but now using the Hooks::TIMELINE_ANSWER_ACTIONS is the preferred way. +The function is called with the following parameters: +* 'item' => The item for which the actions are shown +* 'rand' => A random number that may be used for unique element IDs within the HTML +The function is expected to return nothing, but the information may be output directly. - The name of the minified ``plugin.css`` file must be ``plugin.min.css`` -``add_javascript_anonymous_page`` - Add javascript in **all anonymous** pages headers +TIMELINE_ANSWER_ACTIONS +*********************** - .. versionadded:: 10.0.18 +Register a function to add new itemtypes to the answer/action split dropdown, and be made available to show in a Ticket, Change or Problem timeline. +The function is called with the following parameters: +* 'item' => The item for which the actions are shown +The function is expected to return an array of options to be added to the dropdown. +Each option should have a unique key and be an array with the following properties: +* 'type' => The type of the item to be used for the action. In some cases, this is a parent/abstract class such as ITILTask. This is used as a CSS class on the main timeline item element. +* 'class' => The actual type of the item to be used for the action such as TicketTask. +* 'icon' => The icon to be used for the action. +* 'label' => The label to be used for the action. +* 'short_label' => The short label to be used for the action. +* 'template' => The Twig template to use when showing related items in the timeline. +* 'item' => An instance of the related itemtype. +* 'hide_in_menu' => If true, the option is not available in the dropdown menu but the related items may still be shown in the timeline. - Minified javascript files are checked automatically. You will just have to provide a minified file along with the original to get it used! - The name of the minified ``plugin_anonymous.js`` file must be ``plugin_anonymous.min.js`` +SHOW_IN_TIMELINE +**************** -``add_javascript_module_anonymous_page`` - Add javascript module in **all anonymous** pages headers +.. warning::\nDeprecated: 11.0.0 Use `TIMELINE_ITEMS` instead. The usage of both hooks is the same.\n - .. versionadded:: 10.0.18 - Minified javascript files are checked automatically. You will just have to provide a minified file along with the original to get it used! +TIMELINE_ITEMS +************** - The name of the minified ``mymodule_anonymous.js`` file must be ``mymodule_anonymous.min.js`` +Register a function to add new items to the timeline of a Ticket, Change or Problem. +The function is called with the following parameters: +* 'item' => The item for which the actions are shown. +* 'timeline' => The array of items currently shown in the timeline. This is passed by reference. +The function is expected to modify the timeline array as needed. +The timeline item array contains arrays where the keys are typically "${itemtype}_${items_id}" and the values are arrays with the following properties: +* 'type' => The type of the item being shown in the timeline. This should match the 'class' property used in Hooks::TIMELINE_ANSWER_ACTIONS. +* 'item' => Array of information to pass to the 'template' used in Hooks::TIMELINE_ANSWER_ACTIONS, and notifications. -``add_css_anonymous_page`` - Add CSS stylesheet on **all anonymous** pages headers +SET_ITEM_IMPACT_ICON +******************** - .. versionadded:: 10.0.18 +Register a function to set the icon used by an item in the impact graph. +The function is called with the following parameters: +* 'itemtype' => The type of the item being shown in the graph +* 'items_id' => The ID of the item being shown in the graph +The function is expected to return a URL starting with a '/' relative to the GLPI root directory, or an empty string. - Minified CSS files are checked automatically. You will just have to provide a minified file along with the original to get it used! - The name of the minified ``plugin_anonymous.css`` file must be ``plugin_anonymous.min.css`` +SECURED_FIELDS +************** -``add_header_tag_anonymous_page`` - Add header tags in **all anonymous** pages headers +An array of database columns (example: glpi_mytable.myfield) that are stored using GLPI encrypting methods. +This allows plugin fields to be handled by the `glpi:security:changekey` command. +Added in version 9.4.6 - .. versionadded:: 10.0.18 +SECURED_CONFIGS +*************** -``display_central`` - Displays something on central page +An array of configuration keys that are stored using GLPI encrypting methods. +This allows plugin configuration values to be handled by the `glpi:security:changekey` command. +Added in version 9.4.6 -``display_login`` - Displays something on the login page +PROLOG_RESPONSE +*************** -``status`` - Displays status -``post_init`` - After the framework initialization -``rule_matched`` - After a rule has matched. +NETWORK_DISCOVERY +***************** - This hook will receive a specific array that looks like: - .. code-block:: php - 'an item type', - 'rule_id' => 'rule id', - 'input' => array(), //original input - 'output' => array() //output modified by rule - ]; +NETWORK_INVENTORY +***************** -``redefine_menus`` - Add, edit or remove items from the GLPI menus. - This hook will receive the current GLPI menus definition as an argument and must return the new definition. +INVENTORY_GET_PARAMS +******************** -``init_session`` - At session initialization -``change_entity`` - When entity is changed -``change_profile`` - When profile is changed +PRE_INVENTORY +************* -``pre_kanban_content`` - .. versionadded:: 9.5 - Set or modify the content that shows before the main content in a Kanban card. + You may modify the inventory data which is passed as a parameter (stdClass) and return the modified data. + Returning null will cancel the inventory submission with no specific reason. + Throwing an Exception will cancel the inventory submission with the exception message as the reason. + To avoid unrelated exception messages from being sent to the agent, you must handle all exceptions (except the one you would throw to cancel the inventory) within the hook function. - This hook will receive a specific array that looks like: - .. code-block:: php +POST_INVENTORY +************** - string, //item type that is showing the Kanban - 'items_id' => int, //ID of itemtype showing the Kanban - 'content' => string //current content shown before main content - ]; -``post_kanban_content`` - .. versionadded:: 9.5 + You may view the inventory data which is passed as a parameter (stdClass). + Nothing is expected to be returned. + This hook is only called if the inventory submission was successful. - Set or modify the content that shows after the main content in a Kanban card. - This hook will receive a specific array that looks like: +HANDLE_INVENTORY_TASK +********************* - .. code-block:: php - string, //item type that is showing the Kanban - 'items_id' => int, //ID of itemtype showing the Kanban - 'content' => string //current content shown after main content - ]; -``kanban_filters`` - .. versionadded 10.0 +HANDLE_NETDISCOVERY_TASK +************************ - Add new filter definitions for Kanban by itemtype. - This data is set directly in $PLUGIN_HOOKS like: - .. code-block:: php +HANDLE_NETINVENTORY_TASK +************************ - [ - 'tag' => [ - 'description' => _x('filters', 'If the item has a tag'), - 'supported_prefixes' => ['!'] - ], - 'tagged' => [ - 'description' => _x('filters', 'If the item is tagged'), - 'supported_prefixes' => ['!'] - ] - ], - 'Project' => [ - 'tag' => [ - 'description' => _x('filters', 'If the item has a tag'), - 'supported_prefixes' => ['!'] - ], - 'tagged' => [ - 'description' => _x('filters', 'If the item is tagged'), - 'supported_prefixes' => ['!'] - ] - ]; - ] -``kanban_item_metadata`` - .. versionadded 10.0 - Set or modify the metadata for a Kanban card. This metadata isn't displayed directly but will be used by the filtering system. +HANDLE_ESX_TASK +*************** - This hook will receive a specific array that looks like: - .. code-block:: php - string, //item type that is showing the Kanban - 'items_id' => int, //ID of itemtype showing the Kanban - 'metadata' => array //current metadata array - ]; -``vcard_data`` - .. versionadded 9.5 +HANDLE_COLLECT_TASK +******************* - Add or modify data in vCards such as IM contact information - .. code-block:: php - CommonDBTM, //The item the vCard is for such as a User or Contact - 'data' => array, //The current vCard data for the item - ]; +HANDLE_DEPLOY_TASK +****************** -``filter_actors`` - .. versionadded 9.5 - Add or modify data actor fields provided in the right panel of ITIL objects +HANDLE_WAKEONLAN_TASK +********************* - .. code-block:: php - array, // actors array send to select2 field - 'params' => array, // actor field param - ]; -``helpdesk_menu_entry`` - Add a link to the menu for users with the simplified interface +HANDLE_REMOTEINV_TASK +********************* - .. code-block:: php - The label to be used for the action. +* 'render_callback' => Callable used to display the configuration field. The callable will be called with the inventory configuration values array. +* 'action_callback' => Callable used to perform the action. The callable will be called with the following parameters: + * 'agent' => The agent to be cleaned + * 'config' => The inventory configuration values array + * 'item' => The asset that the agent is for - Array of item types to be added +* 'icon' => The icon for the top-level menu item which is expected to be a Tabler icon CSS class - 'ExampleTab', - 'display_callable' => 'ExampleClass::displayDebugTab' - ] - ]; -``post_plugin_install`` - Called after a plugin is installed +HELPDESK_MENU_ENTRY +******************* -``post_plugin_enable`` - Called after a plugin is enabled +Add a menu item in the simplified interface. +The hook is expected to be a URL relative to the plugin's directory. -``post_plugin_disable`` - Called after a plugin is disabled -``post_plugin_uninstall`` - Called after a plugin is uninstalled +HELPDESK_MENU_ENTRY_ICON +************************ -``post_plugin_clean`` - Called after a plugin is cleaned (removed from the database after the folder is deleted) +Add an icon for the menu item added with the Hooks::HELPDESK_MENU_ENTRY hook. +The hook is expected to be a Tabler icon CSS class. -.. _business_related_hooks: -Items business related -++++++++++++++++++++++ +DASHBOARD_CARDS +*************** -Hooks that can do some business stuff on items. +Register a function to add new dashboard cards. +The function is called with no parameters. +The function is expected to return an array of dashboard cards. +Each key in the returned array should be a unique identifier for the card. +The value should be an array with the following properties (but not limited to): +* 'widgettype' => Array of widget types this card can use (pie, bar, line, etc) +* 'label' => The label to be used for the card +* 'group' => Group string to be used to organize the card in dropdowns +* 'filters' => An optional array of filters that can apply to this card -``item_empty`` - When a new (empty) item has been created. Allow to change / add fields. -``post_prepareadd`` - Before an item has been added, after ``prepareInputForAdd()`` has been run, so after rule engine has ben run, allow to edit ``input`` property, setting it to false will stop the process. +DASHBOARD_FILTERS +***************** -``pre_item_add`` - Before an item has been added, allow to edit ``input`` property, setting it to false will stop the process. +Add new dashboard filters. +The hook is expected to be an array of classes which extend Glpi\Dashboard\Filters\AbstractFilter. -``item_add`` - After adding an item, ``fields`` property can be used. -``pre_item_update`` - Before an item is updated, allow to edit ``input`` property, setting it to false will stop the process. +DASHBOARD_PALETTES +****************** -``item_update`` - While updating an item, ``fields`` and ``updates`` properties can be used. +Add new dashboard color palettes. +The hook is expected to be an array where the keys are unique identifiers and the values are arrays of #rrggbb color strings. -``pre_item_purge`` - Before an item is purged, allow to edit ``input`` property, setting it to false will stop the process. -``item_purge`` - After an item is purged (not pushed to trash, see ``item_delete``). The ``fields`` property still available. +DASHBOARD_TYPES +*************** -``pre_item_restore`` - Before an item is restored from trash. +Register a function to add new dashboard widget types. +The function is called with no parameters. +The function is expected to return an array where the keys are unique identifiers and the values are arrays with the following properties: +* 'label' => The label to be used for the widget type +* 'function' => A callable to be used to display the widget +* 'image' => The image to be used for the widget +* 'limit' => Indicate if the amount of data shown by the widget can be limited +* 'width' => The default width of cards using this widget +* 'height' => The default height of cards using this widget -``item_restore`` - After an item is restored from trash. -``pre_item_delete`` - Before an item is deleted (moved to trash), allow to edit ``input`` property, setting it to false will stop the process. +REDEFINE_API_SCHEMAS +******************** -``item_delete`` - After an item is moved to trash. +The hook function to call to redefine schemas. +Each time a controller's schemas are retrieved, the hook is called with a $data parameter. +The $data parameter will contain the Controller class name in the 'controller' key and an array of schemas in the 'schemas' key. +The function should return the modified $data array. +The controller value should not be changed as it would result in undefined behavior. -``autoinventory_information`` - After an automated inventory has occurred -``item_transfer`` - When an item is transferred from an entity to another +API_CONTROLLERS +*************** -``item_can`` - .. versionadded:: 9.2 +This hook should provide an array of the plugin's API controller class names. - Allow to restrict user rights (can't grant more right). - If ``right`` property is set (called during CommonDBTM::can) changing it allow to - deny evaluated access. Else (called from Search::addDefaultWhere) ``add_where`` - property can be set to filter search results. -``add_plugin_where`` - .. versionadded:: 9.2 +API_MIDDLEWARE +************** - Permit to filter search results. +This hook should provide an array of arrays containing a 'middlware' value that is the class name. +The middleware classes should extend HL_API\Middleware\AbstractMiddleware and +implement either {@link HL_API\Middleware\RequestMiddlewareInterface{ or HL_API\Middleware\ResponseMiddlewareInterface. +The arrays may also contain values for 'priority' and 'condition' where priority is an integer (higher is more important) and condition is a callable. +If a condition is provided, that callable will be called with the current controller as a parameter, and it must return true for the middleware to be used, or false to not be. -.. _display_related_hooks: -Items display related -+++++++++++++++++++++ +STATS +***** -Hooks that permits to add display on items. +Add new statistics reports. +The hook is expected to be an array where the keys are URLs relative to the plugin's directory and the values are the report names. -``pre_itil_info_section`` - .. versionadded:: 11 - Before displaying ITIL object sections (Ticket, Change, Problem) Waits for a ``
``. +MAIL_SERVER_PROTOCOLS +********************* +Register a function to add new email server protocols. +The function is called with no parameters. +The function is expected to return an array where the keys are the protocol name and the values are arrays with the following properties: +* 'label' => The label to be used for the protocol. +* 'protocol' => The name of the class to be used for the protocol. The class should use the `Laminas\Mail\Protocol\ProtocolTrait` trait. +* 'storage' => The name of the class to be used for the protocol storage. The class should extend the `Laminas\Mail\Storage\AbstractStorage` class. -``post_itil_info_section`` - .. versionadded:: 11 - After displaying ITIL object sections (ticket, Change, Problem) Waits for a ``
``. +AUTO_MASSIVE_ACTIONS +******************** +Automatic hook function to add new massive actions. +The function is called with the itemtype as a parameter. +The function is expected to return an array of massive action. +Only called if the plugin also uses the Hooks::USE_MASSIVE_ACTION hook set to true. -``pre_item_form`` - .. versionadded:: 9.1.2 - Before an item is displayed; just after the form header if any; or at the beginning of the form. Waits for a ````. +AUTO_MASSIVE_ACTIONS_FIELDS_DISPLAY +*********************************** +Automatic hook function to display the form for the "update" massive action for itemtypes or search options related to the plugin. +The function is called with the following parameters: +* 'itemtype' => The type of the item for which the fields are shown +* 'options' => The search option array +The function is expected to return true if the display is handled, or false if the default behavior should be used. -``post_item_form`` - .. versionadded:: 9.1.2 - After an item form has been displayed; just before the dates or the save buttons. Waits for a ````. +AUTO_DYNAMIC_REPORT +******************* -``pre_show_item`` - Before an item is displayed +Automatic hook function called to handle the export display of an itemtype added by the plugin. +The function is called with the $_GET array containing several properties including: +* 'item_type' => The type of the item for which the fields are shown +* 'display_type' => The numeric type of the display. See the constants in the `Search` class. +* 'export_all' => If all pages are being exported or just the current one. +The function is expected to return true if the display is handled, or false if the default behavior should be used. -``post_show_item`` - After an item has been displayed -``pre_show_tab`` - Before a tab is displayed +AUTO_ASSIGN_TO_TICKET +********************* -``post_show_tab`` - After a tab has been displayed +Automatic hook function to add new itemtypes which can be linked to Tickets, Changes or Problems. +The function is called with the current array of plugin itemtypes allowed to be linked. +The function is expected to modify the given array as needed and return it. -``show_item_stats`` - .. versionadded:: 9.2.1 - Add display from statistics tab of a item like ticket +AUTO_GET_DROPDOWN +***************** -``timeline_actions`` - .. versionadded:: 9.4.1 - .. versionchanged:: 10.0.0 The timeline action buttons were moved to the timeline footer. Some previous actions may no longer be compatible with the new timeline and will need to be adjusted. +Automatic hook function called to get additional dropdown classes which would be displayed in Setup > Dropdowns. +The function is called with no parameters. +The function is expected to return an array where the class names are in the keys or null. For the array values, anything can be used, but typically it is just `null`. - Display new actions in the ITIL object's timeline -``timeline_answer_actions`` - .. versionadded:: 10.0.0 +AUTO_GET_RULE_CRITERIA +********************** - Display new actions in the ITIL object's answer dropdown +Automatic hook function called with an array with the key 'rule_itemtype' set to the itemtype and 'values' set to the input sent to the rule engine. +The function is expected to return an array of criteria to add. +Only called if the plugin also uses the Hooks::USE_RULES hook set to true. -``show_in_timeline`` - .. versionadded:: 10.0.0 - Display forms in the ITIL object's timeline -Notifications -+++++++++++++ -Hooks that are called from notifications +AUTO_GET_RULE_ACTIONS +********************* -``item_add_targets`` - When a target has been added to an item +Automatic hook function called with an array with the key 'rule_itemtype' set to the itemtype and 'values' set to the input sent to the rule engine. +The function is expected to return an array of actions to add. +Only called if the plugin also uses the Hooks::USE_RULES hook set to true. -``item_get_events`` - After notifications events have been retrieved -``item_action_targets`` - After target addresses have been retrieved -``item_get_datas`` - After data for template have been retrieved +AUTO_RULE_COLLECTION_PREPARE_INPUT_DATA_FOR_PROCESS +*************************************************** -``add_recipient_to_target`` - .. versionadded:: 9.4.0 +Only called if the plugin also uses the Hooks::USE_RULES hook set to true. - When a recipient is added to targets. - The object passed as hook method parameter will contain a property ``recipient_data`` which will - be an array containing `itemtype` and `items_id` fields corresponding to the added target. +AUTO_PRE_PROCESS_RULE_COLLECTION_PREVIEW_RESULTS +************************************************ -Functions hooks -^^^^^^^^^^^^^^^ +Only called if the plugin also uses the Hooks::USE_RULES hook set to true. -Usage -+++++ -Functions hooks declarations are the same than standards hooks one. The main difference is that the hook will wait as output what have been passed as argument. +AUTO_RULEIMPORTASSET_GET_SQL_RESTRICTION +**************************************** -.. code-block:: php +Automatic hook function called with an array containing several criteria including: +* 'where_entity' => the entity to restrict +* 'input' => the rule input +* 'criteria' => the rule criteria +* 'sql_where' => the SQL WHERE clause as a string +* 'sql_from' => the SQL FROM clause as a string +The function is expected to modify the given array as needed and return it. +Only called if the plugin also uses the Hooks::USE_RULES hook set to true. - The HTML input name expected. +* searchtype' => The search type of the criteria (contains, equals, etc). +* 'searchoption' => The search option array related to the criteria. +* 'value' => The current value of the criteria. +The function is expected to output HTML content if it customizes the value field and then return true. If the default behavior is desired, the function should not output anything and return false. -``infocom`` - Additional infocom information oin an item. Will receive an item instance as parameter, is expected to return a table line (````). -``retrieve_more_field_from_ldap`` - Retrieve additional fields from LDAP for a user. Will receive the current fields lists, is expected to return a fields list. +AUTO_ADD_PARAM_FOR_DYNAMIC_REPORT +********************************* -``retrieve_more_data_from_ldap`` - Retrieve additional data from LDAP for a user. Will receive current fields list, is expected to return a fields list. +Automatic hook function to add URL parameters needed for a dynamic report/export. +The function is called with the itemtype as a parameter. +The function is expected to return a key/value array of parameters to add. -``display_locked_fields`` - To manage fields locks. Will receive an array with ``item`` and ``header`` entries. Is expected to output a table line (````). -``migratetypes`` - Item types to migrate, will receive an array of types to be updated; must return an array of item types to migrate. +AUTO_ADD_DEFAULT_JOIN +********************* -Automatic hooks -^^^^^^^^^^^^^^^ +Automatic hook function to add a JOIN clause to the SQL query for a search of itemtypes added by the plugin. +This can be a LEFT JOIN , INNER JOIN or RIGHT JOIN. +The function is called with the following parameters: +* 'itemtype' => The type of the items being searched. +* 'reference_table' => The name of the reference table. This should be the table for the itemtype. +* 'already_link_table' => An array of tables that are already joined. +The function is expected to return a SQL JOIN clause as a string or an empty string if the default behavior should be used. -Some hooks are automated; they'll be called if the relevant function exists in you plugin's ``hook.php`` file. Required function must be of the form ``plugin_{plugin_name}_{hook_name}``. -``MassiveActionsFieldsDisplay`` - Add massive actions. Will receive an array with ``item`` (the item type) and ``options`` (the search options) as input. These hook have to output its content, and to return true if there is some specific output, false otherwise. +AUTO_ADD_DEFAULT_SELECT +*********************** -``dynamicReport`` - Add parameters for print. Will receive the ``$_GET`` array used for query. Is expected to return an array of parameters to add. +Automatic hook function to add a SELECT clause to the SQL query for a searchof itemtypes added by the plugin. +The function is called with the following parameters: +* 'itemtype' => The type of the items being searched. +The function is expected to return a SQL SELECT clause as a string or an empty string if the default behavior should be used. -``AssignToTicket`` - Declare types an ITIL object can be assigned to. Will receive an empty array adn is expected to return a list an array of type of the form: - .. code-block:: php +AUTO_ADD_DEFAULT_WHERE +********************** - 'label' - ]; +Automatic hook function to add a WHERE clause to the SQL query for a searchof itemtypes added by the plugin. +The function is called with the following parameters: +* 'itemtype' => The type of the items being searched. +The function is expected to return a SQL WHERE clause as a string or an empty string if the default behavior should be used. -``MassiveActions`` - If plugin provides massive actions (via ``$PLUGIN_HOOKS['use_massive_actions']``), will pass the item type as parameter, and expect an array of additional massive actions of the form: - .. code-block:: php +ADD_DEFAULT_JOIN +**************** - 'label' - ]; +Automatic hook function to add a JOIN clause to the SQL query for a search. +The function is called with the following parameters: +* 'itemtype' => The type of the items being searched. +* 'join' => The current JOIN clause in the iterator format. +The function is expected to return the modified join array or an empty array if no join should be added. + This function is called after the Hooks::AUTO_ADD_DEFAULT_JOIN hook and after the default joins are added. -``getDropDown`` - To declare extra dropdowns. Will not receive any parameter, and is expected to return an array of the form: - .. code-block:: php +ADD_DEFAULT_WHERE +***************** - 'label' - ]; +Automatic hook function to add a WHERE clause to the SQL query for a search. +The function is called with the following parameters: +* 'itemtype' => The type of the items being searched. +* 'criteria' => The current WHERE clause in the iterator format. +The function is expected to return the modified criteria array or an empty array if no criteria should be added. +This function is called after the Hooks::AUTO_ADD_DEFAULT_WHERE hook and after the default WHERE clauses are added. -``rulePrepareInputDataForProcess`` - Provide data to process rules. Will receive an array with ``item`` (data used to check criteria) and ``params`` (the parameters) keys. Is expected to retrun an array of rules. -``executeActions`` - Actions to execute for rule. Will receive an array with ``output``, ``params`` ans ``action`` keys. Is expected to return an array of actions to execute. +AUTO_ADD_HAVING +*************** -``preProcessRulePreviewResults`` +Automatic hook function to add a HAVING clause to the SQL query for a specific search criteria. +The function is called with the following parameters: +* 'link' => The linking operator (AND/OR) for the criteria. +* 'not' => Indicates if the criteria is negated. +* 'itemtype' => The type of the items being searched. +* 'search_option_id' => The ID of the search option of the criteria. +* 'search_value' => The value to search for. +* 'num' => A string in the form of "${itemtype}_{$search_option_id}". The alias of the related field in the SELECT clause will be "ITEM_{$num}". +The function is expected to return a SQL HAVING clause as a string or an empty string if the default behavior should be used. - .. todo:: - Write documentation for this hook. +AUTO_ADD_LEFT_JOIN +****************** -``use_rules`` +Automatic hook function to add a JOIN clause to the SQL query for a specific search criteria. +Despite the name, this can be a LEFT JOIN , INNER JOIN or RIGHT JOIN. +The function is called with the following parameters: +* 'itemtype' => The type of the items being searched. +* 'reference_table' => The name of the reference table. This is typically the table for the itemtype. +* 'new_table' => The name of the table to be joined. Typically, this is the table related to the search option. +* 'link_field' => The name of the field in the reference table that links to the new table. +* 'already_link_table' => An array of tables that are already joined. +The function is expected to return a SQL JOIN clause as a string or an empty string if the default behavior should be used. - .. todo:: - Write documentation for this hook. It looks a bit particular. +AUTO_ADD_ORDER_BY +***************** -``ruleCollectionPrepareInputDataForProcess`` - Prepare input data for rules collections. Will receive an array of the form: +Automatic hook function to add an ORDER clause to the SQL query for a specific search criteria. +The function is called with the following parameters: +* 'itemtype' => The type of the items being searched. +* 'search_option_id' => The ID of the search option of the criteria. +* 'order' => The order requested (ASC/DESC). +* 'num' => A string in the form of "${itemtype}_{$search_option_id}". The alias of the related field in the SELECT clause will be "ITEM_{$num}". +The function is expected to return a SQL ORDER clause as a string or an empty string if the default behavior should be used. - .. code-block:: php - 'name fo the rule itemtype', - 'values' => array( - 'input' => 'input array', - 'params' => 'array of parameters' - ) - ); +AUTO_ADD_SELECT +*************** - Is expected to return an array. +Automatic hook function to add a SELECT clause to the SQL query for a specific search criteria. +The function is called with the following parameters: +* 'itemtype' => The type of the items being searched. +* 'search_option_id' => The ID of the search option of the criteria. +* 'num' => A string in the form of "${itemtype}_{$search_option_id}". The alias of the related field in the clause returned should be "ITEM_{$num}". +The function is expected to return a SQL SELECT clause as a string or an empty string if the default behavior should be used. -``preProcessRuleCollectionPreviewResults`` -.. todo:: +AUTO_ADD_WHERE +************** - Write documentation for this hook. +Automatic hook function to add a WHERE clause to the SQL query for a specific search criteria. +The function is called with the following parameters: +* 'link' => No longer used but used to indicate the linking operator (AND/OR) for the criteria. +* 'not' => Indicates if the criteria is negated. +* 'itemtype' => The type of the items being searched. +* 'search_option_id' => The ID of the search option of the criteria. +* 'search_value' => The value to search for. +* 'search_type' => The type of the search (notcontains, contains, equals, etc.). +The function is expected to return a SQL WHERE clause as a string or an empty string if the default behavior should be used. -``ruleImportComputer_addGlobalCriteria`` - Add global criteria for computer import. Will receive an array of global criteria, is expected to return global criteria array. -``ruleImportComputer_getSqlRestriction`` - Adds SQL restriction to links. Will receive an array of the form: +AUTO_GIVE_ITEM +************** - .. code-block:: php +Automatic hook function to show an HTML search result column value for an item of one of the itemtypes added by the plugin. +The function is called with the following parameters: +* 'itemtype' => The type of the result items. +* 'search_option_id' => The ID of the search option. +* 'data' => The data retrieved from the database. +* 'id' => The ID of the result item. +The function is expected to return the HTML content to display or an empty string if the default display should be used. - 'where entity clause', - 'input' => 'input array', - 'criteria' => 'complex criteria array', - 'sql_where' => 'sql where clause as string', - 'sql_from' => 'sql from clause as string' - ) - Is expected to return the input array modified. +AUTO_DISPLAY_CONFIG_ITEM +************************ + +Automatic hook function to show an export (CSV, PDF, etc) search result column value for an item of one of the itemtypes added by the plugin. +This function is called with the following parameters: +* 'itemtype' => The type of the items being searched. +* 'search_option_id' => The ID of the search option. +* 'data' => The data retrieved from the database. +* 'num' => A string in the form of "${itemtype}_{$search_option_id}". The alias of the related field in the SELECT clause will be "ITEM_{$num}". +The function is expected to return content to display or an empty string if the default display should be used. -``getAddSearchOptions`` - Adds :ref:`search options `, using "old" method. Will receive item type as string, is expected to return an array of search options. -``getAddSearchOptionsNew`` - Adds :ref:`search options `, using "new" method. Will receive item type as string, is expected to return an **indexed** array of search options. + +AUTO_STATUS +*********** + +Automatic hook function to report status information through the GLPI status feature. +The function receives a parameter with the following keys: +* 'ok' => Always true +* '_public_only' => True if only non-sensitive/public information should be returned +The function is expected to return an array containing at least a 'status' key with a `StatusChecker::STATUS_*` value. +`https://glpi-user-documentation.readthedocs.io/fr/latest/advanced/status.html `_ From 8d2f0aaa4bc040714c69316335d6bbef03291a3b Mon Sep 17 00:00:00 2001 From: Curtis Conard Date: Mon, 30 Mar 2026 09:35:03 -0400 Subject: [PATCH 2/3] update generated docs --- source/plugins/hooks.rst | 1121 ++++++++++++++++++++++++-------------- 1 file changed, 720 insertions(+), 401 deletions(-) diff --git a/source/plugins/hooks.rst b/source/plugins/hooks.rst index 6c4f9099..57364f57 100644 --- a/source/plugins/hooks.rst +++ b/source/plugins/hooks.rst @@ -9,235 +9,255 @@ This page describes the different currently existing hooks. For more information Hooks ##### -ADD_CSS -******* -Add CSS file in the head of all non-anonymous pages. +Glpi\Plugin\Hooks::CSRF_COMPLIANT +********************************* + +.. warning::\nDeprecated: 11.0.0\n + +Glpi\Plugin\Hooks::ADD_CSS +************************** +Add CSS file in the head of all non-anonymous pages. -ADD_JAVASCRIPT -************** + -Add classic JavaScript file in the head of all non-anonymous pages. +Glpi\Plugin\Hooks::ADD_JAVASCRIPT +********************************* +Add classic JavaScript file in the head of all non-anonymous pages. + -ADD_JAVASCRIPT_MODULE -********************* +Glpi\Plugin\Hooks::ADD_JAVASCRIPT_MODULE +**************************************** Add ESM JavaScript module in the head of all non-anonymous pages. + - -ADD_HEADER_TAG -************** +Glpi\Plugin\Hooks::ADD_HEADER_TAG +********************************* Add a header tag in the head of all non-anonymous pages. + - -JAVASCRIPT -********** +Glpi\Plugin\Hooks::JAVASCRIPT +***************************** Register one or more on-demand JavaScript files. On-demand JS files are loaded based on the `$CFG_GLPI['javascript']` array. Example: `$PLUGIN_HOOKS[Hooks::JAVASCRIPT]['your_js_name'] = ['path/to/your/file.js'];` + - -ADD_CSS_ANONYMOUS_PAGE -********************** +Glpi\Plugin\Hooks::ADD_CSS_ANONYMOUS_PAGE +***************************************** Add CSS file in the head of all anonymous pages. + - -ADD_JAVASCRIPT_ANONYMOUS_PAGE -***************************** +Glpi\Plugin\Hooks::ADD_JAVASCRIPT_ANONYMOUS_PAGE +************************************************ Add classic JavaScript file in the head of all anonymous pages. + - -ADD_JAVASCRIPT_MODULE_ANONYMOUS_PAGE -************************************ +Glpi\Plugin\Hooks::ADD_JAVASCRIPT_MODULE_ANONYMOUS_PAGE +******************************************************* Add ESM JavaScript module in the head of all anonymous pages. + - -ADD_HEADER_TAG_ANONYMOUS_PAGE -***************************** +Glpi\Plugin\Hooks::ADD_HEADER_TAG_ANONYMOUS_PAGE +************************************************ Add a header tag in the head of all anonymous pages. + - -CHANGE_ENTITY -************* +Glpi\Plugin\Hooks::CHANGE_ENTITY +******************************** Register a function to be called when the entity is changed. + - -CHANGE_PROFILE -************** +Glpi\Plugin\Hooks::CHANGE_PROFILE +********************************* Register a function to be called when the profile is changed. + - -DISPLAY_LOGIN -************* +Glpi\Plugin\Hooks::DISPLAY_LOGIN +******************************** Register a function to output some content on the login page. + - -DISPLAY_CENTRAL -*************** +Glpi\Plugin\Hooks::DISPLAY_CENTRAL +********************************** Register a function to output some content on the standard (central) or simplified interface (helpdesk) home page. This hook is called inside a table element. + - -DISPLAY_NETPORT_LIST_BEFORE -*************************** +Glpi\Plugin\Hooks::DISPLAY_NETPORT_LIST_BEFORE +********************************************** Register a function to output some content before the network port list. + - -INIT_SESSION -************ +Glpi\Plugin\Hooks::INIT_SESSION +******************************* Register a function to be called when the session is initialized. + - -POST_INIT -********* +Glpi\Plugin\Hooks::POST_INIT +**************************** Register a function to be called after all plugins are initialized. + - -CONFIG_PAGE -*********** +Glpi\Plugin\Hooks::CONFIG_PAGE +****************************** Register a URL relative to the plugin's root URL for the plugin's config page. + - -USE_MASSIVE_ACTION -****************** +Glpi\Plugin\Hooks::USE_MASSIVE_ACTION +************************************* Set to true if the plugin wants to use the Hooks::AUTO_MASSIVE_ACTIONS hook. Example: $PLUGIN_HOOKS[Hooks::USE_MASSIVE_ACTION]['myplugin'] = true; + - -ASSIGN_TO_TICKET -**************** +Glpi\Plugin\Hooks::ASSIGN_TO_TICKET +*********************************** Set to true if the plugin wants to use the Hooks::AUTO_ASSIGN_TO_TICKET hook. Example: $PLUGIN_HOOKS[Hooks::ASSIGN_TO_TICKET]['myplugin'] = true; + - -IMPORT_ITEM -*********** +Glpi\Plugin\Hooks::IMPORT_ITEM +****************************** Set to true if the plugin can import items. Adds the plugin as a source criteria for 'Rules for assigning an item to an entity' + - -RULE_MATCHED -************ +Glpi\Plugin\Hooks::RULE_MATCHED +******************************* Register a function to be called when the rules engine matches a rule. The function is called with an array containing several properties including: + * 'sub_type' => The subtype of the rule (Example: RuleTicket) * 'ruleid' => The ID of the rule * 'input' => The input data sent to the rule engine * 'output' => The current output data -The function is not expected to return anything and the data provided to it cannot be modified. +The function is not expected to return anything and the data provided to it cannot be modified. + -VCARD_DATA -********** +Glpi\Plugin\Hooks::VCARD_DATA +***************************** Register a function to be called when a vCard is generated. The function is called with an array containing several properties including: + * 'item' => The item for which the vCard is generated * 'data' => The vCard data -The function is expected to modify the given array as needed and return it. +The function is expected to modify the given array as needed and return it. + -POST_PLUGIN_DISABLE -******************* +Glpi\Plugin\Hooks::POST_PLUGIN_DISABLE +************************************** -Register a function to be called when the plugin is disabled. +Register a function to be called when another plugin is disabled. The function is called with the plugin name as a parameter. + - -POST_PLUGIN_CLEAN -***************** +Glpi\Plugin\Hooks::POST_PLUGIN_CLEAN +************************************ Register a function to be called when the plugin is cleaned from the database. The function is called with the plugin name as a parameter. + +Glpi\Plugin\Hooks::POST_PLUGIN_INSTALL +************************************** -POST_PLUGIN_INSTALL -******************* - -Register a function to be called when the plugin is installed. +Register a function to be called when another plugin is installed. The function is called with the plugin name as a parameter. + +Glpi\Plugin\Hooks::POST_PLUGIN_UNINSTALL +**************************************** -POST_PLUGIN_UNINSTALL -********************* - -Register a function to be called when the plugin is uninstalled. +Register a function to be called when another plugin is uninstalled. The function is called with the plugin name as a parameter. + +Glpi\Plugin\Hooks::POST_PLUGIN_ENABLE +************************************* -POST_PLUGIN_ENABLE -****************** - -Register a function to be called when the plugin is enabled. +Register a function to be called when another the plugin is enabled. The function is called with the plugin name as a parameter. + - -DISPLAY_LOCKED_FIELDS -********************* +Glpi\Plugin\Hooks::DISPLAY_LOCKED_FIELDS +**************************************** Register a function to be called to show locked fields managed by the plugin. The function is called with an array containing several properties including: + * 'item' => The item for which the locked fields are shown * 'header' => Always false. //TODO WHY!? + -PRE_KANBAN_CONTENT -****************** +Glpi\Plugin\Hooks::PRE_KANBAN_CONTENT +************************************* Register a function to define content to show before the main content of a Kanban card. This function is called with an array containing several properties including: + * 'itemtype' => The type of the item represented by the Kanban card * 'items_id' => The ID of the item represented by the Kanban card -The function is expected to return HTML content. +The function is expected to return HTML content. + -POST_KANBAN_CONTENT -******************* +Glpi\Plugin\Hooks::POST_KANBAN_CONTENT +************************************** Register a function to define content to show after the main content of a Kanban card. This function is called with an array containing several properties including: + * 'itemtype' => The type of the item represented by the Kanban card * 'items_id' => The ID of the item represented by the Kanban card -The function is expected to return HTML content. +The function is expected to return HTML content. + -KANBAN_ITEM_METADATA -******************** +Glpi\Plugin\Hooks::KANBAN_ITEM_METADATA +*************************************** Register a function to redefine metadata for a Kanban card. This function is called with an array containing several properties including: + * 'itemtype' => The type of the item represented by the Kanban card * 'items_id' => The ID of the item represented by the Kanban card * 'metadata' => The current metadata for the Kanban card -The function is expected to modify the given array as needed and return it. +The function is expected to modify the given array as needed and return it. + -KANBAN_FILTERS -************** +Glpi\Plugin\Hooks::KANBAN_FILTERS +********************************* Define extra Kanban filters by itemtype. Example: + ``` $PLUGIN_HOOKS[Hooks::KANBAN_FILTERS]['myplugin'] = [ 'Ticket' => [ @@ -248,139 +268,160 @@ $PLUGIN_HOOKS[Hooks::KANBAN_FILTERS]['myplugin'] = [ ] ] ``` + - -PRE_KANBAN_PANEL_CONTENT -************************ +Glpi\Plugin\Hooks::PRE_KANBAN_PANEL_CONTENT +******************************************* Register a function to display content at the beginning of the item details panel in the Kanban. The function is called with an array containing several properties including: + * 'itemtype' => The type of the item represented by the Kanban card * 'items_id' => The ID of the item represented by the Kanban card -The function is expected to return HTML content. +The function is expected to return HTML content. + -POST_KANBAN_PANEL_CONTENT -************************* +Glpi\Plugin\Hooks::POST_KANBAN_PANEL_CONTENT +******************************************** Register a function to display content at the end of the item details panel in the Kanban. The function is called with an array containing several properties including: + * 'itemtype' => The type of the item represented by the Kanban card * 'items_id' => The ID of the item represented by the Kanban card -The function is expected to return HTML content. +The function is expected to return HTML content. + -PRE_KANBAN_PANEL_MAIN_CONTENT -***************************** +Glpi\Plugin\Hooks::PRE_KANBAN_PANEL_MAIN_CONTENT +************************************************ Register a function to display content at the beginning of the item details panel in the Kanban after the content from Hooks::PRE_KANBAN_PANEL_CONTENT but before the default main content. The function is called with an array containing several properties including: + * 'itemtype' => The type of the item represented by the Kanban card * 'items_id' => The ID of the item represented by the Kanban card -The function is expected to return HTML content. +The function is expected to return HTML content. + -POST_KANBAN_PANEL_MAIN_CONTENT -****************************** +Glpi\Plugin\Hooks::POST_KANBAN_PANEL_MAIN_CONTENT +************************************************* Register a function to display content at the end of the item details panel in the Kanban after the default main content but before the content from Hooks::POST_KANBAN_PANEL_CONTENT. The function is called with an array containing several properties including: + * 'itemtype' => The type of the item represented by the Kanban card * 'items_id' => The ID of the item represented by the Kanban card -The function is expected to return HTML content. +The function is expected to return HTML content. + -REDEFINE_MENUS -************** +Glpi\Plugin\Hooks::REDEFINE_MENUS +********************************* Register a function to redefine the GLPI menu. The function is called with the current menu as a parameter. The function is expected to modify the given array as needed and return it. + - -RETRIEVE_MORE_DATA_FROM_LDAP -**************************** +Glpi\Plugin\Hooks::RETRIEVE_MORE_DATA_FROM_LDAP +*********************************************** Register a function to get more user field data from LDAP. The function is called with an array containing the current fields for the user along with: + * '_ldap_result' => The LDAP query result * '_ldap_conn' => The LDAP connection resource -The function is expected to modify the given array as needed and return it. +The function is expected to modify the given array as needed and return it. + -RETRIEVE_MORE_FIELD_FROM_LDAP -***************************** +Glpi\Plugin\Hooks::RETRIEVE_MORE_FIELD_FROM_LDAP +************************************************ Register a function to get more LDAP -> Field mappings. The function is called with an array containing the current mappings. The function is expected to modify the given array as needed and return it. + - -RESTRICT_LDAP_AUTH -****************** +Glpi\Plugin\Hooks::RESTRICT_LDAP_AUTH +************************************* Register a function to add additional checks to the LDAP authentication. The function is called with an array containing several properties including: + * 'dn' => The DN of the user * login field => Login field value where 'login field' is the name of the login field (usually samaccountname or uid) set in the LDAP config in GLPI. * sync field => Sync field value where 'sync field' is the name of the sync field (usually objectguid or entryuuid) set in the LDAP config in GLPI + -UNLOCK_FIELDS -************* +Glpi\Plugin\Hooks::UNLOCK_FIELDS +******************************** Register a function to handle unlocking additional fields. The function is called with the $_POST array containing several properties including: + * 'itemtype' => The type of the item for which the fields are unlocked * 'id' => The ID of the item for which the fields are unlocked * itemtype => Array of fields to unlock where 'itemtype' is the name of the item type (usually the same as the itemtype value). -The function is expected to return nothing. +The function is expected to return nothing. + -UNDISCLOSED_CONFIG_VALUE -************************ +Glpi\Plugin\Hooks::UNDISCLOSED_CONFIG_VALUE +******************************************* Register a function to optionally hide a config value in certain locations such as the API. The function is called with an array containing several properties including: + * 'context' => The context of the config option ('core' for core GLPI configs) * 'name' => The name of the config option * 'value' => The value of the config option -The function is expected to modify the given array as needed (typically unsetting the value if it should be hidden) and return it. +The function is expected to modify the given array as needed (typically unsetting the value if it should be hidden) and return it. + -FILTER_ACTORS -************* +Glpi\Plugin\Hooks::FILTER_ACTORS +******************************** Register a function to modify the actor results in the right panel of ITIL objects. The function is called with an array containing several properties including: + * 'actors' => The current actor results * 'params' => The parameters used to retrieve the actors -The function is expected to modify the given array as needed and return it. +The function is expected to modify the given array as needed and return it. + -DEFAULT_DISPLAY_PREFS -********************* +Glpi\Plugin\Hooks::DEFAULT_DISPLAY_PREFS +**************************************** Register a function to declare what the default display preferences are for an itemtype. -This is not used when no display preferences are set for the itemtype, but rather when hte preferences are being reset. +This is not used when no display preferences are set for the itemtype, but rather when the preferences are being reset. Therefore, defaults should be set during the plugin installation and the result of the function should be the same as the default values set in the plugin installation. Core GLPI itemtypes with display preferences set in `install/empty_data.php` will never use this hook. The function is called with an array containing several properties including: + * 'itemtype' => The type of the item for which the display preferences are set * 'prefs' => The current defaults (usually empty unless also modified by another plugin) -The function is expected to modify the given array as needed and return it. +The function is expected to modify the given array as needed and return it. + -USE_RULES -********* +Glpi\Plugin\Hooks::USE_RULES +**************************** Must be set to true for some other hooks to function including: + * Hooks::AUTO_GET_RULE_CRITERIA * Hooks::AUTO_GET_RULE_ACTIONS * Hooks::AUTO_RULE_COLLECTION_PREPARE_INPUT_DATA_FOR_PROCESS @@ -388,9 +429,10 @@ Must be set to true for some other hooks to function including: * Hooks::AUTO_RULEIMPORTASSET_GET_SQL_RESTRICTION * Hooks::AUTO_RULEIMPORTASSET_ADD_GLOBAL_CRITERIA + -ADD_RECIPIENT_TO_TARGET -*********************** +Glpi\Plugin\Hooks::ADD_RECIPIENT_TO_TARGET +****************************************** Register a function to be called when a notification recipient is to be added. The function is called with the NotificationTarget object as a parameter. @@ -398,56 +440,56 @@ The function is expected to return nothing. The added notification target information can be found in the `recipient_data` property of the object. Modifying this information will have no effect. The current list of all added notification targets can be found in the `target` property of the object. If you wish to remove/modify targets, you must do so in the `target` property. + - -AUTOINVENTORY_INFORMATION -************************* +Glpi\Plugin\Hooks::AUTOINVENTORY_INFORMATION +******************************************** Register a function to be called to display some automatic inventory information. The function is called with the item as a parameter. The function is expected to return nothing, but the information may be output directly. The function is only called for items that have the `is_dynamic` field, and it is set to 1. + - -INFOCOM -******* +Glpi\Plugin\Hooks::INFOCOM +************************** Register a function to be called to display extra Infocom form fields/information. The function is called with the item as a parameter. The function is expected to return nothing, but the information may be output directly. + - -ITEM_ACTION_TARGETS -******************* +Glpi\Plugin\Hooks::ITEM_ACTION_TARGETS +************************************** Register a function to handle adding a plugin-specific notification target. The function is called with the NotificationTarget object as a parameter. The function is expected to return nothing. The notification target data can be found in the `data` property of the object. + - -ITEM_ADD_TARGETS -**************** +Glpi\Plugin\Hooks::ITEM_ADD_TARGETS +*********************************** Register a function to handle adding new possible recipients for notification targets. The function is called with the NotificationTarget object as a parameter. The function is expected to return nothing. + - -ITEM_EMPTY -********** +Glpi\Plugin\Hooks::ITEM_EMPTY +***************************** Register a function to handle the 'item_empty' lifecycle event for an item. The function is called with the item as a parameter. The function is expected to return nothing. The hook is called at the very end of the process of initializing an empty item. + - -PRE_ITEM_ADD -************ +Glpi\Plugin\Hooks::PRE_ITEM_ADD +******************************* Register a function to handle the 'pre_item_add' lifecycle event for an item. The function is called with the item as a parameter. @@ -455,10 +497,10 @@ The function is expected to return nothing. This hook is called at the very beginning of the add process, before the input has been modified. The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the add process. + - -POST_PREPAREADD -*************** +Glpi\Plugin\Hooks::POST_PREPAREADD +********************************** Register a function to handle the 'post_prepareadd' lifecycle event for an item. The function is called with the item as a parameter. @@ -466,19 +508,19 @@ The function is expected to return nothing. This hook is called after the input has been modified, but before the item is added to the database. The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the add process. + - -ITEM_ADD -******** +Glpi\Plugin\Hooks::ITEM_ADD +*************************** Register a function to handle the 'item_add' lifecycle event for an item. The function is called with the item as a parameter. The function is expected to return nothing. This hook is called at the very end of the add process, after the item has been added to the database. + - -PRE_ITEM_UPDATE -*************** +Glpi\Plugin\Hooks::PRE_ITEM_UPDATE +********************************** Register a function to handle the 'pre_item_update' lifecycle event for an item. The function is called with the item as a parameter. @@ -486,10 +528,10 @@ The function is expected to return nothing. This hook is called at the very beginning of the update process, before the input has been modified. The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the update process. + - -ITEM_UPDATE -*********** +Glpi\Plugin\Hooks::ITEM_UPDATE +****************************** Register a function to handle the 'item_update' lifecycle event for an item. The function is called with the item as a parameter. @@ -497,95 +539,95 @@ The function is expected to return nothing. This hook is called at the very end of the update process, after the item has been updated in the database. The input can be found in the `input` property of the item while the updated field names can be found in the `updates` property. The old values of changed field can be found in the `oldvalues` property. + - -PRE_ITEM_DELETE -*************** +Glpi\Plugin\Hooks::PRE_ITEM_DELETE +********************************** Register a function to handle the 'pre_item_delete' lifecycle event for an item. The function is called with the item as a parameter. The function is expected to return nothing. This hook is called at the very beginning of the soft-deletion process. The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the deletion process. + - -ITEM_DELETE -*********** +Glpi\Plugin\Hooks::ITEM_DELETE +****************************** Register a function to handle the 'item_delete' lifecycle event for an item. The function is called with the item as a parameter. The function is expected to return nothing. This hook is called at the very end of the soft-deletion process, after the item has been soft-deleted from the database (`is_deleted` set to 1). + - -PRE_ITEM_PURGE -************** +Glpi\Plugin\Hooks::PRE_ITEM_PURGE +********************************* Register a function to handle the 'pre_item_purge' lifecycle event for an item. The function is called with the item as a parameter. The function is expected to return nothing. This hook is called at the very beginning of the purge process. The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the purge process. + - -ITEM_PURGE -********** +Glpi\Plugin\Hooks::ITEM_PURGE +***************************** Register a function to handle the 'item_purge' lifecycle event for an item. The function is called with the item as a parameter. The function is expected to return nothing. This hook is called at the very end of the purge process, after the item has been purged from the database. + - -PRE_ITEM_RESTORE -**************** +Glpi\Plugin\Hooks::PRE_ITEM_RESTORE +*********************************** Register a function to handle the 'pre_item_restore' lifecycle event for an item. The function is called with the item as a parameter. The function is expected to return nothing. This hook is called at the very beginning of the restore process. The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the restore process. + - -ITEM_RESTORE -************ +Glpi\Plugin\Hooks::ITEM_RESTORE +******************************* Register a function to handle the 'item_restore' lifecycle event for an item. The function is called with the item as a parameter. The function is expected to return nothing. This hook is called at the very end of the restore process, after the item has been restored in the database (`is_deleted` set to 0). + - -ITEM_GET_DATA -************* +Glpi\Plugin\Hooks::ITEM_GET_DATA +******************************** Register a function to handle adding data for a notification target. The function is called with the NotificationTarget object as a parameter. The function is expected to return nothing. The notification target data can be found in the `data` property of the object. + - -ITEM_GET_EVENTS -*************** +Glpi\Plugin\Hooks::ITEM_GET_EVENTS +********************************** Register a function to handle adding events for a notification target. The function is called with the NotificationTarget object as a parameter. The function is expected to return nothing. The notification target events can be found in the `events` property of the object. + - -SHOW_ITEM_STATS -*************** +Glpi\Plugin\Hooks::SHOW_ITEM_STATS +********************************** Register a function to show additional statistics in the Statistics tab of Tickets, Changes and Problems. The function is called with the item as a parameter. The function is expected to return nothing, but the information may be output directly. + - -ITEM_CAN -******** +Glpi\Plugin\Hooks::ITEM_CAN +*************************** Register a function to add additional permission restrictions for the item. The function is called with the item as a parameter. @@ -593,153 +635,182 @@ The function is expected to return nothing. The permission being checked can be found in the `right` property of the item. The input used to create, update or delete the item can be found in the `input` property of the item. If you change the `right` property to any other value, it will be treated as a failed check. Take care when reading this property as it may have been changed by another plugin. If it isn't an integer greater than 0, you should assume the check already failed. + - -PRE_ITIL_INFO_SECTION -********************* +Glpi\Plugin\Hooks::PRE_ITIL_INFO_SECTION +**************************************** Register a function to show additional fields at the top of a Ticket, Change or Problem fields panel. The function is called with the following parameters: + * 'item' => The item for which the fields are shown * 'options' => An array of form parameters + - -POST_ITIL_INFO_SECTION -********************** +Glpi\Plugin\Hooks::POST_ITIL_INFO_SECTION +***************************************** Register a function to show additional fields at the bottom of a Ticket, Change or Problem fields panel. The function is called with the following parameters: + * 'item' => The item for which the fields are shown * 'options' => An array of form parameters + - -ITEM_TRANSFER -************* +Glpi\Plugin\Hooks::ITEM_TRANSFER +******************************** Register a function to be called after an item is transferred to another entity. The function is called with an array containing several properties including: + * 'type' => The type of the item being transferred. * 'id' => The original ID of the item being transferred. * 'newID' => The new ID of the item being transferred. If the item was cloned into the new entity, this ID will differ from the original ID. * 'entities_id' => The ID of the destination entity. -The function is expected to return nothing. +The function is expected to return nothing. + -PRE_SHOW_ITEM -************* +Glpi\Plugin\Hooks::PRE_SHOW_ITEM +******************************** Register a function to be called before showing an item in the timeline of a Ticket, Change or Problem. The function is called with the following parameters: + * 'item' => The item being shown in the timeline * 'options' => An array containing the following properties: + + * 'parent' => The Ticket, Change or Problem * 'rand' => A random number that may be used for unique element IDs within the timeline item HTML The function is expected to return nothing, but the information may be output directly. + - -POST_SHOW_ITEM -************** +Glpi\Plugin\Hooks::POST_SHOW_ITEM +********************************* Register a function to be called after showing an item in the timeline of a Ticket, Change or Problem. The function is called with the following parameters: + * 'item' => The item being shown in the timeline * 'options' => An array containing the following properties: + + * 'parent' => The Ticket, Change or Problem * 'rand' => A random number that may be used for unique element IDs within the timeline item HTML The function is expected to return nothing, but the information may be output directly. + - -PRE_ITEM_FORM -************* +Glpi\Plugin\Hooks::PRE_ITEM_FORM +******************************** Register a function to show additional fields at the top of an item form. The function is called with the following parameters: + * 'item' => The item for which the fields are shown * 'options' => An array of form parameters -The function is expected to return nothing, but the information may be output directly. +The function is expected to return nothing, but the information may be output directly. + -POST_ITEM_FORM -************** +Glpi\Plugin\Hooks::POST_ITEM_FORM +********************************* Register a function to show additional fields at the bottom of an item form. The function is called with the following parameters: + * 'item' => The item for which the fields are shown * 'options' => An array of form parameters -The function is expected to return nothing, but the information may be output directly. +The function is expected to return nothing, but the information may be output directly. + -PRE_SHOW_TAB -************ +Glpi\Plugin\Hooks::PRE_SHOW_TAB +******************************* Register a function to show additional content before the main content in a tab. This function is not called for the main tab of a form. The function is called with the following parameters: + * 'item' => The item for which the tab is shown * 'options' => An array containing the following properties: + + * 'itemtype' => The type of the item being shown in the tab * 'tabnum' => The number of the tab being shown for the itemtype The function is expected to return HTML content or an empty string. + - -POST_SHOW_TAB -************* +Glpi\Plugin\Hooks::POST_SHOW_TAB +******************************** Register a function to show additional content after the main content in a tab. This function is not called for the main tab of a form. The function is called with the following parameters: + * 'item' => The item for which the tab is shown * 'options' => An array containing the following properties: + + * 'itemtype' => The type of the item being shown in the tab * 'tabnum' => The number of the tab being shown for the itemtype The function is expected to return HTML content or an empty string. + - -PRE_ITEM_LIST -************* +Glpi\Plugin\Hooks::PRE_ITEM_LIST +******************************** Register a function to show additional content before the search result list for an itemtype. The function is called with the following parameters: + * 'itemtype' => The type of the item being shown in the list * 'options' => Unused. Always an empty array. -The function is expected to return nothing, but the information may be output directly. +The function is expected to return nothing, but the information may be output directly. + -POST_ITEM_LIST -************** +Glpi\Plugin\Hooks::POST_ITEM_LIST +********************************* Register a function to show additional content after the search result list for an itemtype. The function is called with the following parameters: + * 'itemtype' => The type of the item being shown in the list * 'options' => Unused. Always an empty array. -The function is expected to return nothing, but the information may be output directly. +The function is expected to return nothing, but the information may be output directly. + -TIMELINE_ACTIONS -**************** +Glpi\Plugin\Hooks::TIMELINE_ACTIONS +*********************************** Register a function to show action buttons in the footer of a Ticket, Change or Problem timeline. This is how timeline actions were displayed before version 10.0, but now using the Hooks::TIMELINE_ANSWER_ACTIONS is the preferred way. The function is called with the following parameters: + * 'item' => The item for which the actions are shown * 'rand' => A random number that may be used for unique element IDs within the HTML -The function is expected to return nothing, but the information may be output directly. +The function is expected to return nothing, but the information may be output directly. + -TIMELINE_ANSWER_ACTIONS -*********************** +Glpi\Plugin\Hooks::TIMELINE_ANSWER_ACTIONS +****************************************** Register a function to add new itemtypes to the answer/action split dropdown, and be made available to show in a Ticket, Change or Problem timeline. The function is called with the following parameters: + * 'item' => The item for which the actions are shown + The function is expected to return an array of options to be added to the dropdown. Each option should have a unique key and be an array with the following properties: + * 'type' => The type of the item to be used for the action. In some cases, this is a parent/abstract class such as ITILTask. This is used as a CSS class on the main timeline item element. * 'class' => The actual type of the item to be used for the action such as TicketTask. * 'icon' => The icon to be used for the action. @@ -749,167 +820,376 @@ Each option should have a unique key and be an array with the following properti * 'item' => An instance of the related itemtype. * 'hide_in_menu' => If true, the option is not available in the dropdown menu but the related items may still be shown in the timeline. + -SHOW_IN_TIMELINE -**************** +Glpi\Plugin\Hooks::SHOW_IN_TIMELINE +*********************************** .. warning::\nDeprecated: 11.0.0 Use `TIMELINE_ITEMS` instead. The usage of both hooks is the same.\n + - -TIMELINE_ITEMS -************** +Glpi\Plugin\Hooks::TIMELINE_ITEMS +********************************* Register a function to add new items to the timeline of a Ticket, Change or Problem. The function is called with the following parameters: + * 'item' => The item for which the actions are shown. * 'timeline' => The array of items currently shown in the timeline. This is passed by reference. + The function is expected to modify the timeline array as needed. The timeline item array contains arrays where the keys are typically "${itemtype}_${items_id}" and the values are arrays with the following properties: + * 'type' => The type of the item being shown in the timeline. This should match the 'class' property used in Hooks::TIMELINE_ANSWER_ACTIONS. * 'item' => Array of information to pass to the 'template' used in Hooks::TIMELINE_ANSWER_ACTIONS, and notifications. + -SET_ITEM_IMPACT_ICON -******************** +Glpi\Plugin\Hooks::SET_ITEM_IMPACT_ICON +*************************************** Register a function to set the icon used by an item in the impact graph. The function is called with the following parameters: + * 'itemtype' => The type of the item being shown in the graph * 'items_id' => The ID of the item being shown in the graph -The function is expected to return a URL starting with a '/' relative to the GLPI root directory, or an empty string. +The function is expected to return a URL starting with a '/' relative to the GLPI root directory, or an empty string. + -SECURED_FIELDS -************** +Glpi\Plugin\Hooks::SECURED_FIELDS +********************************* An array of database columns (example: glpi_mytable.myfield) that are stored using GLPI encrypting methods. This allows plugin fields to be handled by the `glpi:security:changekey` command. Added in version 9.4.6 -SECURED_CONFIGS -*************** +Glpi\Plugin\Hooks::SECURED_CONFIGS +********************************** An array of configuration keys that are stored using GLPI encrypting methods. This allows plugin configuration values to be handled by the `glpi:security:changekey` command. Added in version 9.4.6 -PROLOG_RESPONSE -*************** +Glpi\Plugin\Hooks::PROLOG_RESPONSE +********************************** + +Register a function to insert extra data into the PROLOG response from the server to an agent. +This includes netdiscovery and netinventory tasks to run (ip ranges, jobs configuration, credentials). +It excludes data from ESX, Deploy and Collect which are handled differently. +Wakeonlan related is outdated and not supported in glpi-agent. +Agent has to run netdiscovery and netinventory tasks if it receives data in PROLOG response for them. +The function is called with the following parameters: + +* 'params' => An array containing the following properties: + + + * 'mode' => The response mode. See the `Glpi\Agent\CommunicationAgent::*_MODE` constants. + * 'deviceid' => The device ID string assigned to the agent. + * 'response' => An array containing the PROLOG response data which may differ based on the type of agent (GLPI Agent or an older type of agent). +If the agent is a GLPI Agent, the response array will contain the following properties: + +* 'expiration' => The inventory frequency in seconds. +* 'status' => Always 'ok'. + +If the agent is not a GLPI Agent, the response array will contain the following properties (backwards compatibility with older types of agents): +* 'PROLOG_FREQ' => The inventory frequency in seconds. +* 'RESPONSE' => Always 'SEND'. + +The function is expected to modify the given array as needed and return it. + + +Glpi\Plugin\Hooks::NETWORK_DISCOVERY +************************************ + +Register a function to modify the network discovery data sent from an agent. +The function is called with the following parameters: +* 'mode' => The response mode. See the `Glpi\Agent\CommunicationAgent::*_MODE` constants. +* 'inventory' => An `Glpi\Inventory\Inventory` object containing the discovery data. +* 'deviceid' => The device ID string assigned to the agent. +* 'response' => An array that can be filled with data to be sent back to the agent. This will be empty unless modified by another plugin. +* 'errors' => An array that can be filled with errors to be sent back to the agent. This may not exist unless added by another plugin. +* 'query' => Should be 'netdiscovery'. +The function is expected to modify the given array as needed and return it. +Only the 'response' and 'errors' keys will be taken into account in the returned data. +If no response or error data is provided, the agent will be told that the server does not support network discovery. + -NETWORK_DISCOVERY -***************** +Glpi\Plugin\Hooks::NETWORK_INVENTORY +************************************ +Register a function to modify the network inventory data sent from an agent. +The function is called with the following parameters: +* 'mode' => The response mode. See the `Glpi\Agent\CommunicationAgent::*_MODE` constants. +* 'inventory' => An `Glpi\Inventory\Inventory` object containing the inventory data. +* 'deviceid' => The device ID string assigned to the agent. +* 'response' => An array that can be filled with data to be sent back to the agent. This will be empty unless modified by another plugin. +* 'errors' => An array that can be filled with errors to be sent back to the agent. This may not exist unless added by another plugin. +* 'query' => Should be 'netinventory'. -NETWORK_INVENTORY -***************** +The function is expected to modify the given array as needed and return it. +Only the 'response' and 'errors' keys will be taken into account in the returned data. +If no response or error data is provided, the agent will be told that the server does not support network inventory. + +Glpi\Plugin\Hooks::INVENTORY_GET_PARAMS +*************************************** +Register a function to provide an agent with additional requested parameters for inventory. +An example of this usage can be found in the `databaseinventory` plugin which responds to the GLPI Agent's request for database credentials to allow it to collect database information. +The GLPI Agent will only ask for these parameters if the server indicates that it has them available in the inventory task response. +The function is called with the following parameters: -INVENTORY_GET_PARAMS -******************** +* 'options' => An array containing the following properties: + * 'content' => The request from the agent. + * 'response' => An array that can be filled with data to be sent back to the agent. By default, it is an array with the following properties: -PRE_INVENTORY -************* + * 'expiration' => The inventory frequency in seconds. + * 'status' => Always 'ok'. + * 'item' => The Agent item +The function is expected to modify the given array as needed and return it. + +Glpi\Plugin\Hooks::PRE_INVENTORY +******************************** - You may modify the inventory data which is passed as a parameter (stdClass) and return the modified data. - Returning null will cancel the inventory submission with no specific reason. - Throwing an Exception will cancel the inventory submission with the exception message as the reason. - To avoid unrelated exception messages from being sent to the agent, you must handle all exceptions (except the one you would throw to cancel the inventory) within the hook function. +Register a function to be called before the inventory submission is handled. +The function is called with the following parameters: +* 'data' => An object containing the inventory data submitted by the agent. -POST_INVENTORY -************** +The function is expected to return the modified data object or null to cancel the inventory submission with no specific reason. +Throwing an Exception will cancel the inventory submission with the exception message as the reason. +To avoid unrelated exception messages from being sent to the agent, you must handle all exceptions (except the one you would throw to cancel the inventory) within the hook function. + +Glpi\Plugin\Hooks::POST_INVENTORY +********************************* - You may view the inventory data which is passed as a parameter (stdClass). - Nothing is expected to be returned. - This hook is only called if the inventory submission was successful. +Register a function to be called after the inventory submission is handled. +The function is called with the following parameters: + * 'data' => An object containing the inventory data submitted by the agent. +The function is expected to return nothing. +This hook is only called if the inventory submission was successful. + + +Glpi\Plugin\Hooks::HANDLE_INVENTORY_TASK +**************************************** -HANDLE_INVENTORY_TASK -********************* +Register a function to be called when an agent asks if the server supports the inventory task. +The function is called with an array containing the following properties: +* 'options' => An array containing the following properties: -HANDLE_NETDISCOVERY_TASK -************************ + * 'response' => An array that can be filled with data to be sent back to the agent. By default, it is an array with the following properties: + * 'inventory' => An array containing the following properties: + * 'server' => 'glpi' to indicate that GLPI natively supports the inventory task. + * 'version' => The GLPI server version. +* 'item' => The Agent item -HANDLE_NETINVENTORY_TASK -************************ +The function is expected to modify the given array as needed and return it. +Only the 'response' key will be taken into account in the returned data. + + +Glpi\Plugin\Hooks::HANDLE_NETDISCOVERY_TASK +******************************************* + +Register a function to be called when an agent asks if the server supports the network discovery task. +The function is called with an array containing the following properties: + +* 'options' => An array containing the following properties: + * 'response' => An array that can be filled with data to be sent back to the agent. It is an array that may contain the following properties: + + * 'inventory' => An array containing the following properties: + + * 'server' => The server/plugin that can handle the task. + * 'version' => The server/plugin version. +* 'item' => The Agent item + +The function is expected to modify the given array as needed and return it. +Only the 'response' key will be taken into account in the returned data. + + +Glpi\Plugin\Hooks::HANDLE_NETINVENTORY_TASK +******************************************* + +Register a function to be called when an agent asks if the server supports the network inventory task. +The function is called with an array containing the following properties: + +* 'options' => An array containing the following properties: + + + * 'response' => An array that can be filled with data to be sent back to the agent. It is an array that may contain the following properties: + + * 'inventory' => An array containing the following properties: + + * 'server' => The server/plugin that can handle the task. + * 'version' => The server/plugin version. +* 'item' => The Agent item + +The function is expected to modify the given array as needed and return it. +Only the 'response' key will be taken into account in the returned data. + + +Glpi\Plugin\Hooks::HANDLE_ESX_TASK +********************************** + +Register a function to be called when an agent asks if the server supports the ESX inventory task. +The function is called with an array containing the following properties: + +* 'options' => An array containing the following properties: + + + * 'response' => An array that can be filled with data to be sent back to the agent. It is an array that may contain the following properties: + + * 'inventory' => An array containing the following properties: + + * 'server' => The server/plugin that can handle the task. + * 'version' => The server/plugin version. +* 'item' => The Agent item + +The function is expected to modify the given array as needed and return it. +Only the 'response' key will be taken into account in the returned data. + + +Glpi\Plugin\Hooks::HANDLE_COLLECT_TASK +************************************** + +Register a function to be called when an agent asks if the server supports the collect task. +The function is called with an array containing the following properties: + +* 'options' => An array containing the following properties: + + + * 'response' => An array that can be filled with data to be sent back to the agent. It is an array that may contain the following properties: + + * 'inventory' => An array containing the following properties: + + * 'server' => The server/plugin that can handle the task. + * 'version' => The server/plugin version. +* 'item' => The Agent item + +The function is expected to modify the given array as needed and return it. +Only the 'response' key will be taken into account in the returned data. + + +Glpi\Plugin\Hooks::HANDLE_DEPLOY_TASK +************************************* + +Register a function to be called when an agent asks if the server supports the deploy task. +The function is called with an array containing the following properties: + +* 'options' => An array containing the following properties: + + + * 'response' => An array that can be filled with data to be sent back to the agent. It is an array that may contain the following properties: + + * 'inventory' => An array containing the following properties: + + * 'server' => The server/plugin that can handle the task. + * 'version' => The server/plugin version. +* 'item' => The Agent item + +The function is expected to modify the given array as needed and return it. +Only the 'response' key will be taken into account in the returned data. + + +Glpi\Plugin\Hooks::HANDLE_WAKEONLAN_TASK +**************************************** -HANDLE_ESX_TASK -*************** +Register a function to be called when an agent asks if the server supports the wake-on-lan task. +The function is called with an array containing the following properties: +* 'options' => An array containing the following properties: -HANDLE_COLLECT_TASK -******************* + * 'response' => An array that can be filled with data to be sent back to the agent. It is an array that may contain the following properties: + * 'inventory' => An array containing the following properties: + * 'server' => The server/plugin that can handle the task. + * 'version' => The server/plugin version. +* 'item' => The Agent item -HANDLE_DEPLOY_TASK -****************** +The function is expected to modify the given array as needed and return it. +Only the 'response' key will be taken into account in the returned data. + +Glpi\Plugin\Hooks::HANDLE_REMOTEINV_TASK +**************************************** +Register a function to be called when an agent asks if the server supports the remote inventory task. +The function is called with an array containing the following properties: -HANDLE_WAKEONLAN_TASK -********************* +* 'options' => An array containing the following properties: + * 'response' => An array that can be filled with data to be sent back to the agent. It is an array that may contain the following properties: -HANDLE_REMOTEINV_TASK -********************* + * 'inventory' => An array containing the following properties: + * 'server' => The server/plugin that can handle the task. + * 'version' => The server/plugin version. +* 'item' => The Agent item +The function is expected to modify the given array as needed and return it. +Only the 'response' key will be taken into account in the returned data. + -STALE_AGENT_CONFIG -****************** +Glpi\Plugin\Hooks::STALE_AGENT_CONFIG +************************************* Add new agent cleanup actions. The hook is expected to be an array where each value is an array with the following properties: + * 'label' => The label to be used for the action. * 'render_callback' => Callable used to display the configuration field. The callable will be called with the inventory configuration values array. * 'action_callback' => Callable used to perform the action. The callable will be called with the following parameters: + + * 'agent' => The agent to be cleaned * 'config' => The inventory configuration values array * 'item' => The asset that the agent is for + - -MENU_TOADD -********** +Glpi\Plugin\Hooks::MENU_TOADD +***************************** Add menu items. The hook is expected to be an array where the keys are identiifers for the top-level menu items, and the values are arrays with the following properties: + * 'types' => Array of item types to be added * 'icon' => The icon for the top-level menu item which is expected to be a Tabler icon CSS class + -HELPDESK_MENU_ENTRY -******************* +Glpi\Plugin\Hooks::HELPDESK_MENU_ENTRY +************************************** Add a menu item in the simplified interface. The hook is expected to be a URL relative to the plugin's directory. + - -HELPDESK_MENU_ENTRY_ICON -************************ +Glpi\Plugin\Hooks::HELPDESK_MENU_ENTRY_ICON +******************************************* Add an icon for the menu item added with the Hooks::HELPDESK_MENU_ENTRY hook. The hook is expected to be a Tabler icon CSS class. + - -DASHBOARD_CARDS -*************** +Glpi\Plugin\Hooks::DASHBOARD_CARDS +********************************** Register a function to add new dashboard cards. The function is called with no parameters. @@ -921,27 +1201,29 @@ The value should be an array with the following properties (but not limited to): * 'group' => Group string to be used to organize the card in dropdowns * 'filters' => An optional array of filters that can apply to this card + -DASHBOARD_FILTERS -***************** +Glpi\Plugin\Hooks::DASHBOARD_FILTERS +************************************ Add new dashboard filters. The hook is expected to be an array of classes which extend Glpi\Dashboard\Filters\AbstractFilter. + - -DASHBOARD_PALETTES -****************** +Glpi\Plugin\Hooks::DASHBOARD_PALETTES +************************************* Add new dashboard color palettes. The hook is expected to be an array where the keys are unique identifiers and the values are arrays of #rrggbb color strings. + - -DASHBOARD_TYPES -*************** +Glpi\Plugin\Hooks::DASHBOARD_TYPES +********************************** Register a function to add new dashboard widget types. The function is called with no parameters. The function is expected to return an array where the keys are unique identifiers and the values are arrays with the following properties: + * 'label' => The label to be used for the widget type * 'function' => A callable to be used to display the widget * 'image' => The image to be used for the widget @@ -949,315 +1231,352 @@ The function is expected to return an array where the keys are unique identifier * 'width' => The default width of cards using this widget * 'height' => The default height of cards using this widget + -REDEFINE_API_SCHEMAS -******************** +Glpi\Plugin\Hooks::REDEFINE_API_SCHEMAS +*************************************** The hook function to call to redefine schemas. Each time a controller's schemas are retrieved, the hook is called with a $data parameter. The $data parameter will contain the Controller class name in the 'controller' key and an array of schemas in the 'schemas' key. The function should return the modified $data array. The controller value should not be changed as it would result in undefined behavior. + - -API_CONTROLLERS -*************** +Glpi\Plugin\Hooks::API_CONTROLLERS +********************************** This hook should provide an array of the plugin's API controller class names. + - -API_MIDDLEWARE -************** +Glpi\Plugin\Hooks::API_MIDDLEWARE +********************************* This hook should provide an array of arrays containing a 'middlware' value that is the class name. -The middleware classes should extend HL_API\Middleware\AbstractMiddleware and -implement either {@link HL_API\Middleware\RequestMiddlewareInterface{ or HL_API\Middleware\ResponseMiddlewareInterface. +The middleware classes should extend \Glpi\Api\HL\Middleware\AbstractMiddleware and +implement either {@link \Glpi\Api\HL\Middleware\RequestMiddlewareInterface{ or \Glpi\Api\HL\Middleware\ResponseMiddlewareInterface. The arrays may also contain values for 'priority' and 'condition' where priority is an integer (higher is more important) and condition is a callable. If a condition is provided, that callable will be called with the current controller as a parameter, and it must return true for the middleware to be used, or false to not be. + - -STATS -***** +Glpi\Plugin\Hooks::STATS +************************ Add new statistics reports. The hook is expected to be an array where the keys are URLs relative to the plugin's directory and the values are the report names. + - -MAIL_SERVER_PROTOCOLS -********************* +Glpi\Plugin\Hooks::MAIL_SERVER_PROTOCOLS +**************************************** Register a function to add new email server protocols. The function is called with no parameters. The function is expected to return an array where the keys are the protocol name and the values are arrays with the following properties: + * 'label' => The label to be used for the protocol. * 'protocol' => The name of the class to be used for the protocol. The class should use the `Laminas\Mail\Protocol\ProtocolTrait` trait. * 'storage' => The name of the class to be used for the protocol storage. The class should extend the `Laminas\Mail\Storage\AbstractStorage` class. + -AUTO_MASSIVE_ACTIONS -******************** +Glpi\Plugin\Hooks::AUTO_MASSIVE_ACTIONS +*************************************** Automatic hook function to add new massive actions. The function is called with the itemtype as a parameter. The function is expected to return an array of massive action. Only called if the plugin also uses the Hooks::USE_MASSIVE_ACTION hook set to true. + - -AUTO_MASSIVE_ACTIONS_FIELDS_DISPLAY -*********************************** +Glpi\Plugin\Hooks::AUTO_MASSIVE_ACTIONS_FIELDS_DISPLAY +****************************************************** Automatic hook function to display the form for the "update" massive action for itemtypes or search options related to the plugin. The function is called with the following parameters: + * 'itemtype' => The type of the item for which the fields are shown * 'options' => The search option array -The function is expected to return true if the display is handled, or false if the default behavior should be used. +The function is expected to return true if the display is handled, or false if the default behavior should be used. + -AUTO_DYNAMIC_REPORT -******************* +Glpi\Plugin\Hooks::AUTO_DYNAMIC_REPORT +************************************** Automatic hook function called to handle the export display of an itemtype added by the plugin. The function is called with the $_GET array containing several properties including: + * 'item_type' => The type of the item for which the fields are shown * 'display_type' => The numeric type of the display. See the constants in the `Search` class. * 'export_all' => If all pages are being exported or just the current one. -The function is expected to return true if the display is handled, or false if the default behavior should be used. +The function is expected to return true if the display is handled, or false if the default behavior should be used. + -AUTO_ASSIGN_TO_TICKET -********************* +Glpi\Plugin\Hooks::AUTO_ASSIGN_TO_TICKET +**************************************** Automatic hook function to add new itemtypes which can be linked to Tickets, Changes or Problems. The function is called with the current array of plugin itemtypes allowed to be linked. The function is expected to modify the given array as needed and return it. + - -AUTO_GET_DROPDOWN -***************** +Glpi\Plugin\Hooks::AUTO_GET_DROPDOWN +************************************ Automatic hook function called to get additional dropdown classes which would be displayed in Setup > Dropdowns. The function is called with no parameters. The function is expected to return an array where the class names are in the keys or null. For the array values, anything can be used, but typically it is just `null`. + - -AUTO_GET_RULE_CRITERIA -********************** +Glpi\Plugin\Hooks::AUTO_GET_RULE_CRITERIA +***************************************** Automatic hook function called with an array with the key 'rule_itemtype' set to the itemtype and 'values' set to the input sent to the rule engine. The function is expected to return an array of criteria to add. Only called if the plugin also uses the Hooks::USE_RULES hook set to true. + - -AUTO_GET_RULE_ACTIONS -********************* +Glpi\Plugin\Hooks::AUTO_GET_RULE_ACTIONS +**************************************** Automatic hook function called with an array with the key 'rule_itemtype' set to the itemtype and 'values' set to the input sent to the rule engine. The function is expected to return an array of actions to add. Only called if the plugin also uses the Hooks::USE_RULES hook set to true. + - -AUTO_RULE_COLLECTION_PREPARE_INPUT_DATA_FOR_PROCESS -*************************************************** +Glpi\Plugin\Hooks::AUTO_RULE_COLLECTION_PREPARE_INPUT_DATA_FOR_PROCESS +********************************************************************** Only called if the plugin also uses the Hooks::USE_RULES hook set to true. + - -AUTO_PRE_PROCESS_RULE_COLLECTION_PREVIEW_RESULTS -************************************************ +Glpi\Plugin\Hooks::AUTO_PRE_PROCESS_RULE_COLLECTION_PREVIEW_RESULTS +******************************************************************* Only called if the plugin also uses the Hooks::USE_RULES hook set to true. + - -AUTO_RULEIMPORTASSET_GET_SQL_RESTRICTION -**************************************** +Glpi\Plugin\Hooks::AUTO_RULEIMPORTASSET_GET_SQL_RESTRICTION +*********************************************************** Automatic hook function called with an array containing several criteria including: + * 'where_entity' => the entity to restrict * 'input' => the rule input * 'criteria' => the rule criteria * 'sql_where' => the SQL WHERE clause as a string * 'sql_from' => the SQL FROM clause as a string + The function is expected to modify the given array as needed and return it. Only called if the plugin also uses the Hooks::USE_RULES hook set to true. + - -AUTO_RULEIMPORTASSET_ADD_GLOBAL_CRITERIA -**************************************** +Glpi\Plugin\Hooks::AUTO_RULEIMPORTASSET_ADD_GLOBAL_CRITERIA +*********************************************************** Automatic hook function called with an array of the current global criteria. The function is expected to modify the given array as needed and return it. + - -AUTO_SEARCH_OPTION_VALUES -************************* +Glpi\Plugin\Hooks::AUTO_SEARCH_OPTION_VALUES +******************************************** Automatic hook function to display the value field for a search option criteria. The function is called with an array with the following properties: + * 'name' => The HTML input name expected. * searchtype' => The search type of the criteria (contains, equals, etc). * 'searchoption' => The search option array related to the criteria. * 'value' => The current value of the criteria. -The function is expected to output HTML content if it customizes the value field and then return true. If the default behavior is desired, the function should not output anything and return false. +The function is expected to output HTML content if it customizes the value field and then return true. If the default behavior is desired, the function should not output anything and return false. + -AUTO_ADD_PARAM_FOR_DYNAMIC_REPORT -********************************* +Glpi\Plugin\Hooks::AUTO_ADD_PARAM_FOR_DYNAMIC_REPORT +**************************************************** Automatic hook function to add URL parameters needed for a dynamic report/export. The function is called with the itemtype as a parameter. The function is expected to return a key/value array of parameters to add. + - -AUTO_ADD_DEFAULT_JOIN -********************* +Glpi\Plugin\Hooks::AUTO_ADD_DEFAULT_JOIN +**************************************** Automatic hook function to add a JOIN clause to the SQL query for a search of itemtypes added by the plugin. This can be a LEFT JOIN , INNER JOIN or RIGHT JOIN. The function is called with the following parameters: + * 'itemtype' => The type of the items being searched. * 'reference_table' => The name of the reference table. This should be the table for the itemtype. * 'already_link_table' => An array of tables that are already joined. -The function is expected to return a SQL JOIN clause as a string or an empty string if the default behavior should be used. +The function is expected to return a SQL JOIN clause in the iterator array format, raw SQL string or an empty string if the default behavior should be used. + -AUTO_ADD_DEFAULT_SELECT -*********************** +Glpi\Plugin\Hooks::AUTO_ADD_DEFAULT_SELECT +****************************************** Automatic hook function to add a SELECT clause to the SQL query for a searchof itemtypes added by the plugin. The function is called with the following parameters: + * 'itemtype' => The type of the items being searched. -The function is expected to return a SQL SELECT clause as a string or an empty string if the default behavior should be used. +The function is expected to return a SQL SELECT clause as a string or an empty string if the default behavior should be used. + -AUTO_ADD_DEFAULT_WHERE -********************** +Glpi\Plugin\Hooks::AUTO_ADD_DEFAULT_WHERE +***************************************** Automatic hook function to add a WHERE clause to the SQL query for a searchof itemtypes added by the plugin. The function is called with the following parameters: + * 'itemtype' => The type of the items being searched. -The function is expected to return a SQL WHERE clause as a string or an empty string if the default behavior should be used. +The function is expected to return a SQL WHERE clause in the iterator array format, raw SQL string or an empty string if the default behavior should be used. + -ADD_DEFAULT_JOIN -**************** +Glpi\Plugin\Hooks::ADD_DEFAULT_JOIN +*********************************** Automatic hook function to add a JOIN clause to the SQL query for a search. The function is called with the following parameters: + * 'itemtype' => The type of the items being searched. * 'join' => The current JOIN clause in the iterator format. + The function is expected to return the modified join array or an empty array if no join should be added. This function is called after the Hooks::AUTO_ADD_DEFAULT_JOIN hook and after the default joins are added. + - -ADD_DEFAULT_WHERE -***************** +Glpi\Plugin\Hooks::ADD_DEFAULT_WHERE +************************************ Automatic hook function to add a WHERE clause to the SQL query for a search. The function is called with the following parameters: + * 'itemtype' => The type of the items being searched. * 'criteria' => The current WHERE clause in the iterator format. + The function is expected to return the modified criteria array or an empty array if no criteria should be added. This function is called after the Hooks::AUTO_ADD_DEFAULT_WHERE hook and after the default WHERE clauses are added. + - -AUTO_ADD_HAVING -*************** +Glpi\Plugin\Hooks::AUTO_ADD_HAVING +********************************** Automatic hook function to add a HAVING clause to the SQL query for a specific search criteria. The function is called with the following parameters: + * 'link' => The linking operator (AND/OR) for the criteria. * 'not' => Indicates if the criteria is negated. * 'itemtype' => The type of the items being searched. * 'search_option_id' => The ID of the search option of the criteria. * 'search_value' => The value to search for. * 'num' => A string in the form of "${itemtype}_{$search_option_id}". The alias of the related field in the SELECT clause will be "ITEM_{$num}". -The function is expected to return a SQL HAVING clause as a string or an empty string if the default behavior should be used. +The function is expected to return a SQL HAVING clause in the iterator array format, raw SQL string or an empty string if the default behavior should be used. + -AUTO_ADD_LEFT_JOIN -****************** +Glpi\Plugin\Hooks::AUTO_ADD_LEFT_JOIN +************************************* Automatic hook function to add a JOIN clause to the SQL query for a specific search criteria. Despite the name, this can be a LEFT JOIN , INNER JOIN or RIGHT JOIN. The function is called with the following parameters: + * 'itemtype' => The type of the items being searched. * 'reference_table' => The name of the reference table. This is typically the table for the itemtype. * 'new_table' => The name of the table to be joined. Typically, this is the table related to the search option. * 'link_field' => The name of the field in the reference table that links to the new table. * 'already_link_table' => An array of tables that are already joined. -The function is expected to return a SQL JOIN clause as a string or an empty string if the default behavior should be used. +The function is expected to return a SQL JOIN clause in the iterator array format, raw SQL string or an empty string if the default behavior should be used. + -AUTO_ADD_ORDER_BY -***************** +Glpi\Plugin\Hooks::AUTO_ADD_ORDER_BY +************************************ Automatic hook function to add an ORDER clause to the SQL query for a specific search criteria. The function is called with the following parameters: + * 'itemtype' => The type of the items being searched. * 'search_option_id' => The ID of the search option of the criteria. * 'order' => The order requested (ASC/DESC). * 'num' => A string in the form of "${itemtype}_{$search_option_id}". The alias of the related field in the SELECT clause will be "ITEM_{$num}". -The function is expected to return a SQL ORDER clause as a string or an empty string if the default behavior should be used. +The function is expected to return a SQL ORDER clause as a string or an empty string if the default behavior should be used. + -AUTO_ADD_SELECT -*************** +Glpi\Plugin\Hooks::AUTO_ADD_SELECT +********************************** Automatic hook function to add a SELECT clause to the SQL query for a specific search criteria. The function is called with the following parameters: + * 'itemtype' => The type of the items being searched. * 'search_option_id' => The ID of the search option of the criteria. * 'num' => A string in the form of "${itemtype}_{$search_option_id}". The alias of the related field in the clause returned should be "ITEM_{$num}". -The function is expected to return a SQL SELECT clause as a string or an empty string if the default behavior should be used. +The function is expected to return a SQL SELECT clause as a string or an empty string if the default behavior should be used. + -AUTO_ADD_WHERE -************** +Glpi\Plugin\Hooks::AUTO_ADD_WHERE +********************************* Automatic hook function to add a WHERE clause to the SQL query for a specific search criteria. The function is called with the following parameters: + * 'link' => No longer used but used to indicate the linking operator (AND/OR) for the criteria. * 'not' => Indicates if the criteria is negated. * 'itemtype' => The type of the items being searched. * 'search_option_id' => The ID of the search option of the criteria. * 'search_value' => The value to search for. * 'search_type' => The type of the search (notcontains, contains, equals, etc.). -The function is expected to return a SQL WHERE clause as a string or an empty string if the default behavior should be used. +The function is expected to return a SQL WHERE clause in the iterator array format, raw SQL string or an empty string if the default behavior should be used. + -AUTO_GIVE_ITEM -************** +Glpi\Plugin\Hooks::AUTO_GIVE_ITEM +********************************* Automatic hook function to show an HTML search result column value for an item of one of the itemtypes added by the plugin. The function is called with the following parameters: + * 'itemtype' => The type of the result items. * 'search_option_id' => The ID of the search option. * 'data' => The data retrieved from the database. * 'id' => The ID of the result item. -The function is expected to return the HTML content to display or an empty string if the default display should be used. +The function is expected to return the HTML content to display or an empty string if the default display should be used. + -AUTO_DISPLAY_CONFIG_ITEM -************************ +Glpi\Plugin\Hooks::AUTO_DISPLAY_CONFIG_ITEM +******************************************* -Automatic hook function to show an export (CSV, PDF, etc) search result column value for an item of one of the itemtypes added by the plugin. +Automatic hook function to change the display of a search result cell. +It is recommended to not use this hook and instead use the Hooks::AUTO_GIVE_ITEM hook to customize the content. This function is called with the following parameters: + * 'itemtype' => The type of the items being searched. * 'search_option_id' => The ID of the search option. * 'data' => The data retrieved from the database. * 'num' => A string in the form of "${itemtype}_{$search_option_id}". The alias of the related field in the SELECT clause will be "ITEM_{$num}". -The function is expected to return content to display or an empty string if the default display should be used. - +The function is expected to return a string with HTML attributes. + -AUTO_STATUS -*********** +Glpi\Plugin\Hooks::AUTO_STATUS +****************************** Automatic hook function to report status information through the GLPI status feature. The function receives a parameter with the following keys: + * 'ok' => Always true * '_public_only' => True if only non-sensitive/public information should be returned + The function is expected to return an array containing at least a 'status' key with a `StatusChecker::STATUS_*` value. `https://glpi-user-documentation.readthedocs.io/fr/latest/advanced/status.html `_ From da688262e28e3699b60723f6e6e3519cce64875d Mon Sep 17 00:00:00 2001 From: Curtis Conard Date: Mon, 30 Mar 2026 09:38:07 -0400 Subject: [PATCH 3/3] fix namespace --- source/plugins/hooks.rst | 553 ++++++++++++++++++++------------------- 1 file changed, 277 insertions(+), 276 deletions(-) diff --git a/source/plugins/hooks.rst b/source/plugins/hooks.rst index 57364f57..3893c920 100644 --- a/source/plugins/hooks.rst +++ b/source/plugins/hooks.rst @@ -10,141 +10,141 @@ This page describes the different currently existing hooks. For more information Hooks ##### -Glpi\Plugin\Hooks::CSRF_COMPLIANT -********************************* +Glpi\\Plugin\\Hooks::CSRF_COMPLIANT +*********************************** .. warning::\nDeprecated: 11.0.0\n -Glpi\Plugin\Hooks::ADD_CSS -************************** +Glpi\\Plugin\\Hooks::ADD_CSS +**************************** Add CSS file in the head of all non-anonymous pages. -Glpi\Plugin\Hooks::ADD_JAVASCRIPT -********************************* +Glpi\\Plugin\\Hooks::ADD_JAVASCRIPT +*********************************** Add classic JavaScript file in the head of all non-anonymous pages. -Glpi\Plugin\Hooks::ADD_JAVASCRIPT_MODULE -**************************************** +Glpi\\Plugin\\Hooks::ADD_JAVASCRIPT_MODULE +****************************************** Add ESM JavaScript module in the head of all non-anonymous pages. -Glpi\Plugin\Hooks::ADD_HEADER_TAG -********************************* +Glpi\\Plugin\\Hooks::ADD_HEADER_TAG +*********************************** Add a header tag in the head of all non-anonymous pages. -Glpi\Plugin\Hooks::JAVASCRIPT -***************************** +Glpi\\Plugin\\Hooks::JAVASCRIPT +******************************* Register one or more on-demand JavaScript files. On-demand JS files are loaded based on the `$CFG_GLPI['javascript']` array. Example: `$PLUGIN_HOOKS[Hooks::JAVASCRIPT]['your_js_name'] = ['path/to/your/file.js'];` -Glpi\Plugin\Hooks::ADD_CSS_ANONYMOUS_PAGE -***************************************** +Glpi\\Plugin\\Hooks::ADD_CSS_ANONYMOUS_PAGE +******************************************* Add CSS file in the head of all anonymous pages. -Glpi\Plugin\Hooks::ADD_JAVASCRIPT_ANONYMOUS_PAGE -************************************************ +Glpi\\Plugin\\Hooks::ADD_JAVASCRIPT_ANONYMOUS_PAGE +************************************************** Add classic JavaScript file in the head of all anonymous pages. -Glpi\Plugin\Hooks::ADD_JAVASCRIPT_MODULE_ANONYMOUS_PAGE -******************************************************* +Glpi\\Plugin\\Hooks::ADD_JAVASCRIPT_MODULE_ANONYMOUS_PAGE +********************************************************* Add ESM JavaScript module in the head of all anonymous pages. -Glpi\Plugin\Hooks::ADD_HEADER_TAG_ANONYMOUS_PAGE -************************************************ +Glpi\\Plugin\\Hooks::ADD_HEADER_TAG_ANONYMOUS_PAGE +************************************************** Add a header tag in the head of all anonymous pages. -Glpi\Plugin\Hooks::CHANGE_ENTITY -******************************** +Glpi\\Plugin\\Hooks::CHANGE_ENTITY +********************************** Register a function to be called when the entity is changed. -Glpi\Plugin\Hooks::CHANGE_PROFILE -********************************* +Glpi\\Plugin\\Hooks::CHANGE_PROFILE +*********************************** Register a function to be called when the profile is changed. -Glpi\Plugin\Hooks::DISPLAY_LOGIN -******************************** +Glpi\\Plugin\\Hooks::DISPLAY_LOGIN +********************************** Register a function to output some content on the login page. -Glpi\Plugin\Hooks::DISPLAY_CENTRAL -********************************** +Glpi\\Plugin\\Hooks::DISPLAY_CENTRAL +************************************ Register a function to output some content on the standard (central) or simplified interface (helpdesk) home page. This hook is called inside a table element. -Glpi\Plugin\Hooks::DISPLAY_NETPORT_LIST_BEFORE -********************************************** +Glpi\\Plugin\\Hooks::DISPLAY_NETPORT_LIST_BEFORE +************************************************ Register a function to output some content before the network port list. -Glpi\Plugin\Hooks::INIT_SESSION -******************************* +Glpi\\Plugin\\Hooks::INIT_SESSION +********************************* Register a function to be called when the session is initialized. -Glpi\Plugin\Hooks::POST_INIT -**************************** +Glpi\\Plugin\\Hooks::POST_INIT +****************************** Register a function to be called after all plugins are initialized. -Glpi\Plugin\Hooks::CONFIG_PAGE -****************************** +Glpi\\Plugin\\Hooks::CONFIG_PAGE +******************************** Register a URL relative to the plugin's root URL for the plugin's config page. -Glpi\Plugin\Hooks::USE_MASSIVE_ACTION -************************************* +Glpi\\Plugin\\Hooks::USE_MASSIVE_ACTION +*************************************** Set to true if the plugin wants to use the Hooks::AUTO_MASSIVE_ACTIONS hook. Example: $PLUGIN_HOOKS[Hooks::USE_MASSIVE_ACTION]['myplugin'] = true; -Glpi\Plugin\Hooks::ASSIGN_TO_TICKET -*********************************** +Glpi\\Plugin\\Hooks::ASSIGN_TO_TICKET +************************************* Set to true if the plugin wants to use the Hooks::AUTO_ASSIGN_TO_TICKET hook. Example: $PLUGIN_HOOKS[Hooks::ASSIGN_TO_TICKET]['myplugin'] = true; -Glpi\Plugin\Hooks::IMPORT_ITEM -****************************** +Glpi\\Plugin\\Hooks::IMPORT_ITEM +******************************** Set to true if the plugin can import items. Adds the plugin as a source criteria for 'Rules for assigning an item to an entity' -Glpi\Plugin\Hooks::RULE_MATCHED -******************************* +Glpi\\Plugin\\Hooks::RULE_MATCHED +********************************* Register a function to be called when the rules engine matches a rule. The function is called with an array containing several properties including: @@ -157,8 +157,8 @@ The function is called with an array containing several properties including: The function is not expected to return anything and the data provided to it cannot be modified. -Glpi\Plugin\Hooks::VCARD_DATA -***************************** +Glpi\\Plugin\\Hooks::VCARD_DATA +******************************* Register a function to be called when a vCard is generated. The function is called with an array containing several properties including: @@ -169,43 +169,43 @@ The function is called with an array containing several properties including: The function is expected to modify the given array as needed and return it. -Glpi\Plugin\Hooks::POST_PLUGIN_DISABLE -************************************** +Glpi\\Plugin\\Hooks::POST_PLUGIN_DISABLE +**************************************** Register a function to be called when another plugin is disabled. The function is called with the plugin name as a parameter. -Glpi\Plugin\Hooks::POST_PLUGIN_CLEAN -************************************ +Glpi\\Plugin\\Hooks::POST_PLUGIN_CLEAN +************************************** Register a function to be called when the plugin is cleaned from the database. The function is called with the plugin name as a parameter. -Glpi\Plugin\Hooks::POST_PLUGIN_INSTALL -************************************** +Glpi\\Plugin\\Hooks::POST_PLUGIN_INSTALL +**************************************** Register a function to be called when another plugin is installed. The function is called with the plugin name as a parameter. -Glpi\Plugin\Hooks::POST_PLUGIN_UNINSTALL -**************************************** +Glpi\\Plugin\\Hooks::POST_PLUGIN_UNINSTALL +****************************************** Register a function to be called when another plugin is uninstalled. The function is called with the plugin name as a parameter. -Glpi\Plugin\Hooks::POST_PLUGIN_ENABLE -************************************* +Glpi\\Plugin\\Hooks::POST_PLUGIN_ENABLE +*************************************** Register a function to be called when another the plugin is enabled. The function is called with the plugin name as a parameter. -Glpi\Plugin\Hooks::DISPLAY_LOCKED_FIELDS -**************************************** +Glpi\\Plugin\\Hooks::DISPLAY_LOCKED_FIELDS +****************************************** Register a function to be called to show locked fields managed by the plugin. The function is called with an array containing several properties including: @@ -215,8 +215,8 @@ The function is called with an array containing several properties including: -Glpi\Plugin\Hooks::PRE_KANBAN_CONTENT -************************************* +Glpi\\Plugin\\Hooks::PRE_KANBAN_CONTENT +*************************************** Register a function to define content to show before the main content of a Kanban card. This function is called with an array containing several properties including: @@ -227,8 +227,8 @@ This function is called with an array containing several properties including: The function is expected to return HTML content. -Glpi\Plugin\Hooks::POST_KANBAN_CONTENT -************************************** +Glpi\\Plugin\\Hooks::POST_KANBAN_CONTENT +**************************************** Register a function to define content to show after the main content of a Kanban card. This function is called with an array containing several properties including: @@ -239,8 +239,8 @@ This function is called with an array containing several properties including: The function is expected to return HTML content. -Glpi\Plugin\Hooks::KANBAN_ITEM_METADATA -*************************************** +Glpi\\Plugin\\Hooks::KANBAN_ITEM_METADATA +***************************************** Register a function to redefine metadata for a Kanban card. This function is called with an array containing several properties including: @@ -252,8 +252,8 @@ This function is called with an array containing several properties including: The function is expected to modify the given array as needed and return it. -Glpi\Plugin\Hooks::KANBAN_FILTERS -********************************* +Glpi\\Plugin\\Hooks::KANBAN_FILTERS +*********************************** Define extra Kanban filters by itemtype. Example: @@ -270,8 +270,8 @@ $PLUGIN_HOOKS[Hooks::KANBAN_FILTERS]['myplugin'] = [ ``` -Glpi\Plugin\Hooks::PRE_KANBAN_PANEL_CONTENT -******************************************* +Glpi\\Plugin\\Hooks::PRE_KANBAN_PANEL_CONTENT +********************************************* Register a function to display content at the beginning of the item details panel in the Kanban. The function is called with an array containing several properties including: @@ -283,8 +283,8 @@ The function is expected to return HTML content. -Glpi\Plugin\Hooks::POST_KANBAN_PANEL_CONTENT -******************************************** +Glpi\\Plugin\\Hooks::POST_KANBAN_PANEL_CONTENT +********************************************** Register a function to display content at the end of the item details panel in the Kanban. The function is called with an array containing several properties including: @@ -296,8 +296,8 @@ The function is expected to return HTML content. -Glpi\Plugin\Hooks::PRE_KANBAN_PANEL_MAIN_CONTENT -************************************************ +Glpi\\Plugin\\Hooks::PRE_KANBAN_PANEL_MAIN_CONTENT +************************************************** Register a function to display content at the beginning of the item details panel in the Kanban after the content from Hooks::PRE_KANBAN_PANEL_CONTENT but before the default main content. The function is called with an array containing several properties including: @@ -309,8 +309,8 @@ The function is expected to return HTML content. -Glpi\Plugin\Hooks::POST_KANBAN_PANEL_MAIN_CONTENT -************************************************* +Glpi\\Plugin\\Hooks::POST_KANBAN_PANEL_MAIN_CONTENT +*************************************************** Register a function to display content at the end of the item details panel in the Kanban after the default main content but before the content from Hooks::POST_KANBAN_PANEL_CONTENT. The function is called with an array containing several properties including: @@ -322,8 +322,8 @@ The function is expected to return HTML content. -Glpi\Plugin\Hooks::REDEFINE_MENUS -********************************* +Glpi\\Plugin\\Hooks::REDEFINE_MENUS +*********************************** Register a function to redefine the GLPI menu. The function is called with the current menu as a parameter. @@ -331,8 +331,8 @@ The function is expected to modify the given array as needed and return it. -Glpi\Plugin\Hooks::RETRIEVE_MORE_DATA_FROM_LDAP -*********************************************** +Glpi\\Plugin\\Hooks::RETRIEVE_MORE_DATA_FROM_LDAP +************************************************* Register a function to get more user field data from LDAP. The function is called with an array containing the current fields for the user along with: @@ -343,8 +343,8 @@ The function is called with an array containing the current fields for the user The function is expected to modify the given array as needed and return it. -Glpi\Plugin\Hooks::RETRIEVE_MORE_FIELD_FROM_LDAP -************************************************ +Glpi\\Plugin\\Hooks::RETRIEVE_MORE_FIELD_FROM_LDAP +************************************************** Register a function to get more LDAP -> Field mappings. The function is called with an array containing the current mappings. @@ -352,8 +352,8 @@ The function is expected to modify the given array as needed and return it. -Glpi\Plugin\Hooks::RESTRICT_LDAP_AUTH -************************************* +Glpi\\Plugin\\Hooks::RESTRICT_LDAP_AUTH +*************************************** Register a function to add additional checks to the LDAP authentication. The function is called with an array containing several properties including: @@ -364,8 +364,8 @@ The function is called with an array containing several properties including: -Glpi\Plugin\Hooks::UNLOCK_FIELDS -******************************** +Glpi\\Plugin\\Hooks::UNLOCK_FIELDS +********************************** Register a function to handle unlocking additional fields. The function is called with the $_POST array containing several properties including: @@ -377,8 +377,8 @@ The function is called with the $_POST array containing several properties inclu The function is expected to return nothing. -Glpi\Plugin\Hooks::UNDISCLOSED_CONFIG_VALUE -******************************************* +Glpi\\Plugin\\Hooks::UNDISCLOSED_CONFIG_VALUE +********************************************* Register a function to optionally hide a config value in certain locations such as the API. The function is called with an array containing several properties including: @@ -390,8 +390,8 @@ The function is called with an array containing several properties including: The function is expected to modify the given array as needed (typically unsetting the value if it should be hidden) and return it. -Glpi\Plugin\Hooks::FILTER_ACTORS -******************************** +Glpi\\Plugin\\Hooks::FILTER_ACTORS +********************************** Register a function to modify the actor results in the right panel of ITIL objects. The function is called with an array containing several properties including: @@ -402,8 +402,8 @@ The function is called with an array containing several properties including: The function is expected to modify the given array as needed and return it. -Glpi\Plugin\Hooks::DEFAULT_DISPLAY_PREFS -**************************************** +Glpi\\Plugin\\Hooks::DEFAULT_DISPLAY_PREFS +****************************************** Register a function to declare what the default display preferences are for an itemtype. This is not used when no display preferences are set for the itemtype, but rather when the preferences are being reset. @@ -417,8 +417,8 @@ The function is called with an array containing several properties including: The function is expected to modify the given array as needed and return it. -Glpi\Plugin\Hooks::USE_RULES -**************************** +Glpi\\Plugin\\Hooks::USE_RULES +****************************** Must be set to true for some other hooks to function including: @@ -431,8 +431,8 @@ Must be set to true for some other hooks to function including: -Glpi\Plugin\Hooks::ADD_RECIPIENT_TO_TARGET -****************************************** +Glpi\\Plugin\\Hooks::ADD_RECIPIENT_TO_TARGET +******************************************** Register a function to be called when a notification recipient is to be added. The function is called with the NotificationTarget object as a parameter. @@ -442,8 +442,8 @@ The current list of all added notification targets can be found in the `target` If you wish to remove/modify targets, you must do so in the `target` property. -Glpi\Plugin\Hooks::AUTOINVENTORY_INFORMATION -******************************************** +Glpi\\Plugin\\Hooks::AUTOINVENTORY_INFORMATION +********************************************** Register a function to be called to display some automatic inventory information. The function is called with the item as a parameter. @@ -451,16 +451,16 @@ The function is expected to return nothing, but the information may be output di The function is only called for items that have the `is_dynamic` field, and it is set to 1. -Glpi\Plugin\Hooks::INFOCOM -************************** +Glpi\\Plugin\\Hooks::INFOCOM +**************************** Register a function to be called to display extra Infocom form fields/information. The function is called with the item as a parameter. The function is expected to return nothing, but the information may be output directly. -Glpi\Plugin\Hooks::ITEM_ACTION_TARGETS -************************************** +Glpi\\Plugin\\Hooks::ITEM_ACTION_TARGETS +**************************************** Register a function to handle adding a plugin-specific notification target. The function is called with the NotificationTarget object as a parameter. @@ -469,8 +469,8 @@ The notification target data can be found in the `data` property of the object. -Glpi\Plugin\Hooks::ITEM_ADD_TARGETS -*********************************** +Glpi\\Plugin\\Hooks::ITEM_ADD_TARGETS +************************************* Register a function to handle adding new possible recipients for notification targets. The function is called with the NotificationTarget object as a parameter. @@ -478,8 +478,8 @@ The function is expected to return nothing. -Glpi\Plugin\Hooks::ITEM_EMPTY -***************************** +Glpi\\Plugin\\Hooks::ITEM_EMPTY +******************************* Register a function to handle the 'item_empty' lifecycle event for an item. The function is called with the item as a parameter. @@ -488,8 +488,8 @@ The hook is called at the very end of the process of initializing an empty item. -Glpi\Plugin\Hooks::PRE_ITEM_ADD -******************************* +Glpi\\Plugin\\Hooks::PRE_ITEM_ADD +********************************* Register a function to handle the 'pre_item_add' lifecycle event for an item. The function is called with the item as a parameter. @@ -499,8 +499,8 @@ The input can be found in the `input` property of the item. Setting the `input` -Glpi\Plugin\Hooks::POST_PREPAREADD -********************************** +Glpi\\Plugin\\Hooks::POST_PREPAREADD +************************************ Register a function to handle the 'post_prepareadd' lifecycle event for an item. The function is called with the item as a parameter. @@ -510,8 +510,8 @@ The input can be found in the `input` property of the item. Setting the `input` -Glpi\Plugin\Hooks::ITEM_ADD -*************************** +Glpi\\Plugin\\Hooks::ITEM_ADD +***************************** Register a function to handle the 'item_add' lifecycle event for an item. The function is called with the item as a parameter. @@ -519,8 +519,8 @@ The function is expected to return nothing. This hook is called at the very end of the add process, after the item has been added to the database. -Glpi\Plugin\Hooks::PRE_ITEM_UPDATE -********************************** +Glpi\\Plugin\\Hooks::PRE_ITEM_UPDATE +************************************ Register a function to handle the 'pre_item_update' lifecycle event for an item. The function is called with the item as a parameter. @@ -530,8 +530,8 @@ The input can be found in the `input` property of the item. Setting the `input` -Glpi\Plugin\Hooks::ITEM_UPDATE -****************************** +Glpi\\Plugin\\Hooks::ITEM_UPDATE +******************************** Register a function to handle the 'item_update' lifecycle event for an item. The function is called with the item as a parameter. @@ -541,8 +541,8 @@ The input can be found in the `input` property of the item while the updated fie The old values of changed field can be found in the `oldvalues` property. -Glpi\Plugin\Hooks::PRE_ITEM_DELETE -********************************** +Glpi\\Plugin\\Hooks::PRE_ITEM_DELETE +************************************ Register a function to handle the 'pre_item_delete' lifecycle event for an item. The function is called with the item as a parameter. @@ -551,8 +551,8 @@ This hook is called at the very beginning of the soft-deletion process. The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the deletion process. -Glpi\Plugin\Hooks::ITEM_DELETE -****************************** +Glpi\\Plugin\\Hooks::ITEM_DELETE +******************************** Register a function to handle the 'item_delete' lifecycle event for an item. The function is called with the item as a parameter. @@ -560,8 +560,8 @@ The function is expected to return nothing. This hook is called at the very end of the soft-deletion process, after the item has been soft-deleted from the database (`is_deleted` set to 1). -Glpi\Plugin\Hooks::PRE_ITEM_PURGE -********************************* +Glpi\\Plugin\\Hooks::PRE_ITEM_PURGE +*********************************** Register a function to handle the 'pre_item_purge' lifecycle event for an item. The function is called with the item as a parameter. @@ -570,8 +570,8 @@ This hook is called at the very beginning of the purge process. The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the purge process. -Glpi\Plugin\Hooks::ITEM_PURGE -***************************** +Glpi\\Plugin\\Hooks::ITEM_PURGE +******************************* Register a function to handle the 'item_purge' lifecycle event for an item. The function is called with the item as a parameter. @@ -579,8 +579,8 @@ The function is expected to return nothing. This hook is called at the very end of the purge process, after the item has been purged from the database. -Glpi\Plugin\Hooks::PRE_ITEM_RESTORE -*********************************** +Glpi\\Plugin\\Hooks::PRE_ITEM_RESTORE +************************************* Register a function to handle the 'pre_item_restore' lifecycle event for an item. The function is called with the item as a parameter. @@ -589,8 +589,8 @@ This hook is called at the very beginning of the restore process. The input can be found in the `input` property of the item. Setting the `input` property to false will cancel the restore process. -Glpi\Plugin\Hooks::ITEM_RESTORE -******************************* +Glpi\\Plugin\\Hooks::ITEM_RESTORE +********************************* Register a function to handle the 'item_restore' lifecycle event for an item. The function is called with the item as a parameter. @@ -598,8 +598,8 @@ The function is expected to return nothing. This hook is called at the very end of the restore process, after the item has been restored in the database (`is_deleted` set to 0). -Glpi\Plugin\Hooks::ITEM_GET_DATA -******************************** +Glpi\\Plugin\\Hooks::ITEM_GET_DATA +********************************** Register a function to handle adding data for a notification target. The function is called with the NotificationTarget object as a parameter. @@ -608,8 +608,8 @@ The notification target data can be found in the `data` property of the object. -Glpi\Plugin\Hooks::ITEM_GET_EVENTS -********************************** +Glpi\\Plugin\\Hooks::ITEM_GET_EVENTS +************************************ Register a function to handle adding events for a notification target. The function is called with the NotificationTarget object as a parameter. @@ -618,16 +618,16 @@ The notification target events can be found in the `events` property of the obje -Glpi\Plugin\Hooks::SHOW_ITEM_STATS -********************************** +Glpi\\Plugin\\Hooks::SHOW_ITEM_STATS +************************************ Register a function to show additional statistics in the Statistics tab of Tickets, Changes and Problems. The function is called with the item as a parameter. The function is expected to return nothing, but the information may be output directly. -Glpi\Plugin\Hooks::ITEM_CAN -*************************** +Glpi\\Plugin\\Hooks::ITEM_CAN +***************************** Register a function to add additional permission restrictions for the item. The function is called with the item as a parameter. @@ -637,8 +637,8 @@ The input used to create, update or delete the item can be found in the `input` If you change the `right` property to any other value, it will be treated as a failed check. Take care when reading this property as it may have been changed by another plugin. If it isn't an integer greater than 0, you should assume the check already failed. -Glpi\Plugin\Hooks::PRE_ITIL_INFO_SECTION -**************************************** +Glpi\\Plugin\\Hooks::PRE_ITIL_INFO_SECTION +****************************************** Register a function to show additional fields at the top of a Ticket, Change or Problem fields panel. The function is called with the following parameters: @@ -648,8 +648,8 @@ The function is called with the following parameters: -Glpi\Plugin\Hooks::POST_ITIL_INFO_SECTION -***************************************** +Glpi\\Plugin\\Hooks::POST_ITIL_INFO_SECTION +******************************************* Register a function to show additional fields at the bottom of a Ticket, Change or Problem fields panel. The function is called with the following parameters: @@ -659,8 +659,8 @@ Register a function to show additional fields at the bottom of a Ticket, Change -Glpi\Plugin\Hooks::ITEM_TRANSFER -******************************** +Glpi\\Plugin\\Hooks::ITEM_TRANSFER +********************************** Register a function to be called after an item is transferred to another entity. The function is called with an array containing several properties including: @@ -673,8 +673,8 @@ The function is called with an array containing several properties including: The function is expected to return nothing. -Glpi\Plugin\Hooks::PRE_SHOW_ITEM -******************************** +Glpi\\Plugin\\Hooks::PRE_SHOW_ITEM +********************************** Register a function to be called before showing an item in the timeline of a Ticket, Change or Problem. The function is called with the following parameters: @@ -689,8 +689,8 @@ The function is expected to return nothing, but the information may be output di -Glpi\Plugin\Hooks::POST_SHOW_ITEM -********************************* +Glpi\\Plugin\\Hooks::POST_SHOW_ITEM +*********************************** Register a function to be called after showing an item in the timeline of a Ticket, Change or Problem. The function is called with the following parameters: @@ -705,8 +705,8 @@ The function is expected to return nothing, but the information may be output di -Glpi\Plugin\Hooks::PRE_ITEM_FORM -******************************** +Glpi\\Plugin\\Hooks::PRE_ITEM_FORM +********************************** Register a function to show additional fields at the top of an item form. The function is called with the following parameters: @@ -717,8 +717,8 @@ The function is called with the following parameters: The function is expected to return nothing, but the information may be output directly. -Glpi\Plugin\Hooks::POST_ITEM_FORM -********************************* +Glpi\\Plugin\\Hooks::POST_ITEM_FORM +*********************************** Register a function to show additional fields at the bottom of an item form. The function is called with the following parameters: @@ -729,8 +729,8 @@ The function is called with the following parameters: The function is expected to return nothing, but the information may be output directly. -Glpi\Plugin\Hooks::PRE_SHOW_TAB -******************************* +Glpi\\Plugin\\Hooks::PRE_SHOW_TAB +********************************* Register a function to show additional content before the main content in a tab. This function is not called for the main tab of a form. @@ -745,8 +745,8 @@ The function is called with the following parameters: The function is expected to return HTML content or an empty string. -Glpi\Plugin\Hooks::POST_SHOW_TAB -******************************** +Glpi\\Plugin\\Hooks::POST_SHOW_TAB +********************************** Register a function to show additional content after the main content in a tab. This function is not called for the main tab of a form. @@ -761,8 +761,8 @@ The function is called with the following parameters: The function is expected to return HTML content or an empty string. -Glpi\Plugin\Hooks::PRE_ITEM_LIST -******************************** +Glpi\\Plugin\\Hooks::PRE_ITEM_LIST +********************************** Register a function to show additional content before the search result list for an itemtype. The function is called with the following parameters: @@ -774,8 +774,8 @@ The function is expected to return nothing, but the information may be output di -Glpi\Plugin\Hooks::POST_ITEM_LIST -********************************* +Glpi\\Plugin\\Hooks::POST_ITEM_LIST +*********************************** Register a function to show additional content after the search result list for an itemtype. The function is called with the following parameters: @@ -787,8 +787,8 @@ The function is expected to return nothing, but the information may be output di -Glpi\Plugin\Hooks::TIMELINE_ACTIONS -*********************************** +Glpi\\Plugin\\Hooks::TIMELINE_ACTIONS +************************************* Register a function to show action buttons in the footer of a Ticket, Change or Problem timeline. This is how timeline actions were displayed before version 10.0, but now using the Hooks::TIMELINE_ANSWER_ACTIONS is the preferred way. @@ -800,8 +800,8 @@ The function is called with the following parameters: The function is expected to return nothing, but the information may be output directly. -Glpi\Plugin\Hooks::TIMELINE_ANSWER_ACTIONS -****************************************** +Glpi\\Plugin\\Hooks::TIMELINE_ANSWER_ACTIONS +******************************************** Register a function to add new itemtypes to the answer/action split dropdown, and be made available to show in a Ticket, Change or Problem timeline. The function is called with the following parameters: @@ -822,14 +822,14 @@ Each option should have a unique key and be an array with the following properti -Glpi\Plugin\Hooks::SHOW_IN_TIMELINE -*********************************** +Glpi\\Plugin\\Hooks::SHOW_IN_TIMELINE +************************************* .. warning::\nDeprecated: 11.0.0 Use `TIMELINE_ITEMS` instead. The usage of both hooks is the same.\n -Glpi\Plugin\Hooks::TIMELINE_ITEMS -********************************* +Glpi\\Plugin\\Hooks::TIMELINE_ITEMS +*********************************** Register a function to add new items to the timeline of a Ticket, Change or Problem. The function is called with the following parameters: @@ -845,8 +845,8 @@ The timeline item array contains arrays where the keys are typically "${itemtype -Glpi\Plugin\Hooks::SET_ITEM_IMPACT_ICON -*************************************** +Glpi\\Plugin\\Hooks::SET_ITEM_IMPACT_ICON +***************************************** Register a function to set the icon used by an item in the impact graph. The function is called with the following parameters: @@ -857,22 +857,22 @@ The function is called with the following parameters: The function is expected to return a URL starting with a '/' relative to the GLPI root directory, or an empty string. -Glpi\Plugin\Hooks::SECURED_FIELDS -********************************* +Glpi\\Plugin\\Hooks::SECURED_FIELDS +*********************************** An array of database columns (example: glpi_mytable.myfield) that are stored using GLPI encrypting methods. This allows plugin fields to be handled by the `glpi:security:changekey` command. Added in version 9.4.6 -Glpi\Plugin\Hooks::SECURED_CONFIGS -********************************** +Glpi\\Plugin\\Hooks::SECURED_CONFIGS +************************************ An array of configuration keys that are stored using GLPI encrypting methods. This allows plugin configuration values to be handled by the `glpi:security:changekey` command. Added in version 9.4.6 -Glpi\Plugin\Hooks::PROLOG_RESPONSE -********************************** +Glpi\\Plugin\\Hooks::PROLOG_RESPONSE +************************************ Register a function to insert extra data into the PROLOG response from the server to an agent. This includes netdiscovery and netinventory tasks to run (ip ranges, jobs configuration, credentials). @@ -899,8 +899,8 @@ If the agent is not a GLPI Agent, the response array will contain the following The function is expected to modify the given array as needed and return it. -Glpi\Plugin\Hooks::NETWORK_DISCOVERY -************************************ +Glpi\\Plugin\\Hooks::NETWORK_DISCOVERY +************************************** Register a function to modify the network discovery data sent from an agent. The function is called with the following parameters: @@ -917,8 +917,8 @@ Only the 'response' and 'errors' keys will be taken into account in the returned If no response or error data is provided, the agent will be told that the server does not support network discovery. -Glpi\Plugin\Hooks::NETWORK_INVENTORY -************************************ +Glpi\\Plugin\\Hooks::NETWORK_INVENTORY +************************************** Register a function to modify the network inventory data sent from an agent. The function is called with the following parameters: @@ -935,8 +935,8 @@ Only the 'response' and 'errors' keys will be taken into account in the returned If no response or error data is provided, the agent will be told that the server does not support network inventory. -Glpi\Plugin\Hooks::INVENTORY_GET_PARAMS -*************************************** +Glpi\\Plugin\\Hooks::INVENTORY_GET_PARAMS +***************************************** Register a function to provide an agent with additional requested parameters for inventory. An example of this usage can be found in the `databaseinventory` plugin which responds to the GLPI Agent's request for database credentials to allow it to collect database information. @@ -955,8 +955,8 @@ The function is called with the following parameters: The function is expected to modify the given array as needed and return it. -Glpi\Plugin\Hooks::PRE_INVENTORY -******************************** +Glpi\\Plugin\\Hooks::PRE_INVENTORY +********************************** Register a function to be called before the inventory submission is handled. The function is called with the following parameters: @@ -968,8 +968,8 @@ Throwing an Exception will cancel the inventory submission with the exception me To avoid unrelated exception messages from being sent to the agent, you must handle all exceptions (except the one you would throw to cancel the inventory) within the hook function. -Glpi\Plugin\Hooks::POST_INVENTORY -********************************* +Glpi\\Plugin\\Hooks::POST_INVENTORY +*********************************** Register a function to be called after the inventory submission is handled. The function is called with the following parameters: @@ -979,8 +979,8 @@ The function is expected to return nothing. This hook is only called if the inventory submission was successful. -Glpi\Plugin\Hooks::HANDLE_INVENTORY_TASK -**************************************** +Glpi\\Plugin\\Hooks::HANDLE_INVENTORY_TASK +****************************************** Register a function to be called when an agent asks if the server supports the inventory task. The function is called with an array containing the following properties: @@ -1000,8 +1000,8 @@ The function is expected to modify the given array as needed and return it. Only the 'response' key will be taken into account in the returned data. -Glpi\Plugin\Hooks::HANDLE_NETDISCOVERY_TASK -******************************************* +Glpi\\Plugin\\Hooks::HANDLE_NETDISCOVERY_TASK +********************************************* Register a function to be called when an agent asks if the server supports the network discovery task. The function is called with an array containing the following properties: @@ -1021,8 +1021,8 @@ The function is expected to modify the given array as needed and return it. Only the 'response' key will be taken into account in the returned data. -Glpi\Plugin\Hooks::HANDLE_NETINVENTORY_TASK -******************************************* +Glpi\\Plugin\\Hooks::HANDLE_NETINVENTORY_TASK +********************************************* Register a function to be called when an agent asks if the server supports the network inventory task. The function is called with an array containing the following properties: @@ -1042,8 +1042,8 @@ The function is expected to modify the given array as needed and return it. Only the 'response' key will be taken into account in the returned data. -Glpi\Plugin\Hooks::HANDLE_ESX_TASK -********************************** +Glpi\\Plugin\\Hooks::HANDLE_ESX_TASK +************************************ Register a function to be called when an agent asks if the server supports the ESX inventory task. The function is called with an array containing the following properties: @@ -1063,8 +1063,8 @@ The function is expected to modify the given array as needed and return it. Only the 'response' key will be taken into account in the returned data. -Glpi\Plugin\Hooks::HANDLE_COLLECT_TASK -************************************** +Glpi\\Plugin\\Hooks::HANDLE_COLLECT_TASK +**************************************** Register a function to be called when an agent asks if the server supports the collect task. The function is called with an array containing the following properties: @@ -1084,8 +1084,8 @@ The function is expected to modify the given array as needed and return it. Only the 'response' key will be taken into account in the returned data. -Glpi\Plugin\Hooks::HANDLE_DEPLOY_TASK -************************************* +Glpi\\Plugin\\Hooks::HANDLE_DEPLOY_TASK +*************************************** Register a function to be called when an agent asks if the server supports the deploy task. The function is called with an array containing the following properties: @@ -1105,8 +1105,8 @@ The function is expected to modify the given array as needed and return it. Only the 'response' key will be taken into account in the returned data. -Glpi\Plugin\Hooks::HANDLE_WAKEONLAN_TASK -**************************************** +Glpi\\Plugin\\Hooks::HANDLE_WAKEONLAN_TASK +****************************************** Register a function to be called when an agent asks if the server supports the wake-on-lan task. The function is called with an array containing the following properties: @@ -1126,8 +1126,8 @@ The function is expected to modify the given array as needed and return it. Only the 'response' key will be taken into account in the returned data. -Glpi\Plugin\Hooks::HANDLE_REMOTEINV_TASK -**************************************** +Glpi\\Plugin\\Hooks::HANDLE_REMOTEINV_TASK +****************************************** Register a function to be called when an agent asks if the server supports the remote inventory task. The function is called with an array containing the following properties: @@ -1147,8 +1147,8 @@ The function is expected to modify the given array as needed and return it. Only the 'response' key will be taken into account in the returned data. -Glpi\Plugin\Hooks::STALE_AGENT_CONFIG -************************************* +Glpi\\Plugin\\Hooks::STALE_AGENT_CONFIG +*************************************** Add new agent cleanup actions. The hook is expected to be an array where each value is an array with the following properties: @@ -1163,8 +1163,8 @@ The hook is expected to be an array where each value is an array with the follow * 'item' => The asset that the agent is for -Glpi\Plugin\Hooks::MENU_TOADD -***************************** +Glpi\\Plugin\\Hooks::MENU_TOADD +******************************* Add menu items. The hook is expected to be an array where the keys are identiifers for the top-level menu items, and the values are arrays with the following properties: @@ -1174,22 +1174,22 @@ The hook is expected to be an array where the keys are identiifers for the top-l -Glpi\Plugin\Hooks::HELPDESK_MENU_ENTRY -************************************** +Glpi\\Plugin\\Hooks::HELPDESK_MENU_ENTRY +**************************************** Add a menu item in the simplified interface. The hook is expected to be a URL relative to the plugin's directory. -Glpi\Plugin\Hooks::HELPDESK_MENU_ENTRY_ICON -******************************************* +Glpi\\Plugin\\Hooks::HELPDESK_MENU_ENTRY_ICON +********************************************* Add an icon for the menu item added with the Hooks::HELPDESK_MENU_ENTRY hook. The hook is expected to be a Tabler icon CSS class. -Glpi\Plugin\Hooks::DASHBOARD_CARDS -********************************** +Glpi\\Plugin\\Hooks::DASHBOARD_CARDS +************************************ Register a function to add new dashboard cards. The function is called with no parameters. @@ -1203,22 +1203,22 @@ The value should be an array with the following properties (but not limited to): -Glpi\Plugin\Hooks::DASHBOARD_FILTERS -************************************ +Glpi\\Plugin\\Hooks::DASHBOARD_FILTERS +************************************** Add new dashboard filters. The hook is expected to be an array of classes which extend Glpi\Dashboard\Filters\AbstractFilter. -Glpi\Plugin\Hooks::DASHBOARD_PALETTES -************************************* +Glpi\\Plugin\\Hooks::DASHBOARD_PALETTES +*************************************** Add new dashboard color palettes. The hook is expected to be an array where the keys are unique identifiers and the values are arrays of #rrggbb color strings. -Glpi\Plugin\Hooks::DASHBOARD_TYPES -********************************** +Glpi\\Plugin\\Hooks::DASHBOARD_TYPES +************************************ Register a function to add new dashboard widget types. The function is called with no parameters. @@ -1233,8 +1233,8 @@ The function is expected to return an array where the keys are unique identifier -Glpi\Plugin\Hooks::REDEFINE_API_SCHEMAS -*************************************** +Glpi\\Plugin\\Hooks::REDEFINE_API_SCHEMAS +***************************************** The hook function to call to redefine schemas. Each time a controller's schemas are retrieved, the hook is called with a $data parameter. @@ -1243,14 +1243,14 @@ The function should return the modified $data array. The controller value should not be changed as it would result in undefined behavior. -Glpi\Plugin\Hooks::API_CONTROLLERS -********************************** +Glpi\\Plugin\\Hooks::API_CONTROLLERS +************************************ This hook should provide an array of the plugin's API controller class names. -Glpi\Plugin\Hooks::API_MIDDLEWARE -********************************* +Glpi\\Plugin\\Hooks::API_MIDDLEWARE +*********************************** This hook should provide an array of arrays containing a 'middlware' value that is the class name. The middleware classes should extend \Glpi\Api\HL\Middleware\AbstractMiddleware and @@ -1259,15 +1259,15 @@ The arrays may also contain values for 'priority' and 'condition' where priority If a condition is provided, that callable will be called with the current controller as a parameter, and it must return true for the middleware to be used, or false to not be. -Glpi\Plugin\Hooks::STATS -************************ +Glpi\\Plugin\\Hooks::STATS +************************** Add new statistics reports. The hook is expected to be an array where the keys are URLs relative to the plugin's directory and the values are the report names. -Glpi\Plugin\Hooks::MAIL_SERVER_PROTOCOLS -**************************************** +Glpi\\Plugin\\Hooks::MAIL_SERVER_PROTOCOLS +****************************************** Register a function to add new email server protocols. The function is called with no parameters. @@ -1279,8 +1279,8 @@ The function is expected to return an array where the keys are the protocol name -Glpi\Plugin\Hooks::AUTO_MASSIVE_ACTIONS -*************************************** +Glpi\\Plugin\\Hooks::AUTO_MASSIVE_ACTIONS +***************************************** Automatic hook function to add new massive actions. The function is called with the itemtype as a parameter. @@ -1288,8 +1288,8 @@ The function is expected to return an array of massive action. Only called if the plugin also uses the Hooks::USE_MASSIVE_ACTION hook set to true. -Glpi\Plugin\Hooks::AUTO_MASSIVE_ACTIONS_FIELDS_DISPLAY -****************************************************** +Glpi\\Plugin\\Hooks::AUTO_MASSIVE_ACTIONS_FIELDS_DISPLAY +******************************************************** Automatic hook function to display the form for the "update" massive action for itemtypes or search options related to the plugin. The function is called with the following parameters: @@ -1300,8 +1300,8 @@ The function is called with the following parameters: The function is expected to return true if the display is handled, or false if the default behavior should be used. -Glpi\Plugin\Hooks::AUTO_DYNAMIC_REPORT -************************************** +Glpi\\Plugin\\Hooks::AUTO_DYNAMIC_REPORT +**************************************** Automatic hook function called to handle the export display of an itemtype added by the plugin. The function is called with the $_GET array containing several properties including: @@ -1313,24 +1313,24 @@ The function is called with the $_GET array containing several properties includ The function is expected to return true if the display is handled, or false if the default behavior should be used. -Glpi\Plugin\Hooks::AUTO_ASSIGN_TO_TICKET -**************************************** +Glpi\\Plugin\\Hooks::AUTO_ASSIGN_TO_TICKET +****************************************** Automatic hook function to add new itemtypes which can be linked to Tickets, Changes or Problems. The function is called with the current array of plugin itemtypes allowed to be linked. The function is expected to modify the given array as needed and return it. -Glpi\Plugin\Hooks::AUTO_GET_DROPDOWN -************************************ +Glpi\\Plugin\\Hooks::AUTO_GET_DROPDOWN +************************************** Automatic hook function called to get additional dropdown classes which would be displayed in Setup > Dropdowns. The function is called with no parameters. The function is expected to return an array where the class names are in the keys or null. For the array values, anything can be used, but typically it is just `null`. -Glpi\Plugin\Hooks::AUTO_GET_RULE_CRITERIA -***************************************** +Glpi\\Plugin\\Hooks::AUTO_GET_RULE_CRITERIA +******************************************* Automatic hook function called with an array with the key 'rule_itemtype' set to the itemtype and 'values' set to the input sent to the rule engine. The function is expected to return an array of criteria to add. @@ -1338,8 +1338,8 @@ Only called if the plugin also uses the Hooks::USE_RULES hook set to true. -Glpi\Plugin\Hooks::AUTO_GET_RULE_ACTIONS -**************************************** +Glpi\\Plugin\\Hooks::AUTO_GET_RULE_ACTIONS +****************************************** Automatic hook function called with an array with the key 'rule_itemtype' set to the itemtype and 'values' set to the input sent to the rule engine. The function is expected to return an array of actions to add. @@ -1347,20 +1347,20 @@ Only called if the plugin also uses the Hooks::USE_RULES hook set to true. -Glpi\Plugin\Hooks::AUTO_RULE_COLLECTION_PREPARE_INPUT_DATA_FOR_PROCESS -********************************************************************** +Glpi\\Plugin\\Hooks::AUTO_RULE_COLLECTION_PREPARE_INPUT_DATA_FOR_PROCESS +************************************************************************ Only called if the plugin also uses the Hooks::USE_RULES hook set to true. -Glpi\Plugin\Hooks::AUTO_PRE_PROCESS_RULE_COLLECTION_PREVIEW_RESULTS -******************************************************************* +Glpi\\Plugin\\Hooks::AUTO_PRE_PROCESS_RULE_COLLECTION_PREVIEW_RESULTS +********************************************************************* Only called if the plugin also uses the Hooks::USE_RULES hook set to true. -Glpi\Plugin\Hooks::AUTO_RULEIMPORTASSET_GET_SQL_RESTRICTION -*********************************************************** +Glpi\\Plugin\\Hooks::AUTO_RULEIMPORTASSET_GET_SQL_RESTRICTION +************************************************************* Automatic hook function called with an array containing several criteria including: @@ -1374,15 +1374,15 @@ The function is expected to modify the given array as needed and return it. Only called if the plugin also uses the Hooks::USE_RULES hook set to true. -Glpi\Plugin\Hooks::AUTO_RULEIMPORTASSET_ADD_GLOBAL_CRITERIA -*********************************************************** +Glpi\\Plugin\\Hooks::AUTO_RULEIMPORTASSET_ADD_GLOBAL_CRITERIA +************************************************************* Automatic hook function called with an array of the current global criteria. The function is expected to modify the given array as needed and return it. -Glpi\Plugin\Hooks::AUTO_SEARCH_OPTION_VALUES -******************************************** +Glpi\\Plugin\\Hooks::AUTO_SEARCH_OPTION_VALUES +********************************************** Automatic hook function to display the value field for a search option criteria. The function is called with an array with the following properties: @@ -1395,16 +1395,16 @@ The function is called with an array with the following properties: The function is expected to output HTML content if it customizes the value field and then return true. If the default behavior is desired, the function should not output anything and return false. -Glpi\Plugin\Hooks::AUTO_ADD_PARAM_FOR_DYNAMIC_REPORT -**************************************************** +Glpi\\Plugin\\Hooks::AUTO_ADD_PARAM_FOR_DYNAMIC_REPORT +****************************************************** Automatic hook function to add URL parameters needed for a dynamic report/export. The function is called with the itemtype as a parameter. The function is expected to return a key/value array of parameters to add. -Glpi\Plugin\Hooks::AUTO_ADD_DEFAULT_JOIN -**************************************** +Glpi\\Plugin\\Hooks::AUTO_ADD_DEFAULT_JOIN +****************************************** Automatic hook function to add a JOIN clause to the SQL query for a search of itemtypes added by the plugin. This can be a LEFT JOIN , INNER JOIN or RIGHT JOIN. @@ -1417,8 +1417,8 @@ The function is called with the following parameters: The function is expected to return a SQL JOIN clause in the iterator array format, raw SQL string or an empty string if the default behavior should be used. -Glpi\Plugin\Hooks::AUTO_ADD_DEFAULT_SELECT -****************************************** +Glpi\\Plugin\\Hooks::AUTO_ADD_DEFAULT_SELECT +******************************************** Automatic hook function to add a SELECT clause to the SQL query for a searchof itemtypes added by the plugin. The function is called with the following parameters: @@ -1428,8 +1428,8 @@ The function is called with the following parameters: The function is expected to return a SQL SELECT clause as a string or an empty string if the default behavior should be used. -Glpi\Plugin\Hooks::AUTO_ADD_DEFAULT_WHERE -***************************************** +Glpi\\Plugin\\Hooks::AUTO_ADD_DEFAULT_WHERE +******************************************* Automatic hook function to add a WHERE clause to the SQL query for a searchof itemtypes added by the plugin. The function is called with the following parameters: @@ -1439,8 +1439,8 @@ The function is called with the following parameters: The function is expected to return a SQL WHERE clause in the iterator array format, raw SQL string or an empty string if the default behavior should be used. -Glpi\Plugin\Hooks::ADD_DEFAULT_JOIN -*********************************** +Glpi\\Plugin\\Hooks::ADD_DEFAULT_JOIN +************************************* Automatic hook function to add a JOIN clause to the SQL query for a search. The function is called with the following parameters: @@ -1452,8 +1452,8 @@ The function is expected to return the modified join array or an empty array if This function is called after the Hooks::AUTO_ADD_DEFAULT_JOIN hook and after the default joins are added. -Glpi\Plugin\Hooks::ADD_DEFAULT_WHERE -************************************ +Glpi\\Plugin\\Hooks::ADD_DEFAULT_WHERE +************************************** Automatic hook function to add a WHERE clause to the SQL query for a search. The function is called with the following parameters: @@ -1465,8 +1465,8 @@ The function is expected to return the modified criteria array or an empty array This function is called after the Hooks::AUTO_ADD_DEFAULT_WHERE hook and after the default WHERE clauses are added. -Glpi\Plugin\Hooks::AUTO_ADD_HAVING -********************************** +Glpi\\Plugin\\Hooks::AUTO_ADD_HAVING +************************************ Automatic hook function to add a HAVING clause to the SQL query for a specific search criteria. The function is called with the following parameters: @@ -1481,8 +1481,8 @@ The function is called with the following parameters: The function is expected to return a SQL HAVING clause in the iterator array format, raw SQL string or an empty string if the default behavior should be used. -Glpi\Plugin\Hooks::AUTO_ADD_LEFT_JOIN -************************************* +Glpi\\Plugin\\Hooks::AUTO_ADD_LEFT_JOIN +*************************************** Automatic hook function to add a JOIN clause to the SQL query for a specific search criteria. Despite the name, this can be a LEFT JOIN , INNER JOIN or RIGHT JOIN. @@ -1497,8 +1497,8 @@ The function is called with the following parameters: The function is expected to return a SQL JOIN clause in the iterator array format, raw SQL string or an empty string if the default behavior should be used. -Glpi\Plugin\Hooks::AUTO_ADD_ORDER_BY -************************************ +Glpi\\Plugin\\Hooks::AUTO_ADD_ORDER_BY +************************************** Automatic hook function to add an ORDER clause to the SQL query for a specific search criteria. The function is called with the following parameters: @@ -1511,8 +1511,8 @@ The function is called with the following parameters: The function is expected to return a SQL ORDER clause as a string or an empty string if the default behavior should be used. -Glpi\Plugin\Hooks::AUTO_ADD_SELECT -********************************** +Glpi\\Plugin\\Hooks::AUTO_ADD_SELECT +************************************ Automatic hook function to add a SELECT clause to the SQL query for a specific search criteria. The function is called with the following parameters: @@ -1524,8 +1524,8 @@ The function is called with the following parameters: The function is expected to return a SQL SELECT clause as a string or an empty string if the default behavior should be used. -Glpi\Plugin\Hooks::AUTO_ADD_WHERE -********************************* +Glpi\\Plugin\\Hooks::AUTO_ADD_WHERE +*********************************** Automatic hook function to add a WHERE clause to the SQL query for a specific search criteria. The function is called with the following parameters: @@ -1540,8 +1540,8 @@ The function is called with the following parameters: The function is expected to return a SQL WHERE clause in the iterator array format, raw SQL string or an empty string if the default behavior should be used. -Glpi\Plugin\Hooks::AUTO_GIVE_ITEM -********************************* +Glpi\\Plugin\\Hooks::AUTO_GIVE_ITEM +*********************************** Automatic hook function to show an HTML search result column value for an item of one of the itemtypes added by the plugin. The function is called with the following parameters: @@ -1554,8 +1554,8 @@ The function is called with the following parameters: The function is expected to return the HTML content to display or an empty string if the default display should be used. -Glpi\Plugin\Hooks::AUTO_DISPLAY_CONFIG_ITEM -******************************************* +Glpi\\Plugin\\Hooks::AUTO_DISPLAY_CONFIG_ITEM +********************************************* Automatic hook function to change the display of a search result cell. It is recommended to not use this hook and instead use the Hooks::AUTO_GIVE_ITEM hook to customize the content. @@ -1569,8 +1569,8 @@ This function is called with the following parameters: The function is expected to return a string with HTML attributes. -Glpi\Plugin\Hooks::AUTO_STATUS -****************************** +Glpi\\Plugin\\Hooks::AUTO_STATUS +******************************** Automatic hook function to report status information through the GLPI status feature. The function receives a parameter with the following keys: @@ -1580,3 +1580,4 @@ The function receives a parameter with the following keys: The function is expected to return an array containing at least a 'status' key with a `StatusChecker::STATUS_*` value. `https://glpi-user-documentation.readthedocs.io/fr/latest/advanced/status.html `_ +