From e206ce99642b40410c58534688da3be3a5b69fd5 Mon Sep 17 00:00:00 2001 From: stonebuzz Date: Tue, 17 Sep 2024 09:43:33 +0200 Subject: [PATCH 1/3] add doc for new hook pre/post_itil_info_section --- patch.patch | 31 ++ source/plugins/hooks.rst | 13 +- source/plugins/hooks.rst.orig | 663 ++++++++++++++++++++++++++++++++++ 3 files changed, 706 insertions(+), 1 deletion(-) create mode 100644 patch.patch create mode 100644 source/plugins/hooks.rst.orig diff --git a/patch.patch b/patch.patch new file mode 100644 index 0000000..327640e --- /dev/null +++ b/patch.patch @@ -0,0 +1,31 @@ +diff --git a/source/plugins/hooks.rst b/source/plugins/hooks.rst +index 47708ff..51479fd 100644 +--- a/source/plugins/hooks.rst ++++ b/source/plugins/hooks.rst +@@ -124,7 +124,7 @@ These hooks will work just as the :ref:`hooks with item as parameter ``. ++ ++ ++``post_itil_info_section`` ++ .. versionadded:: 11 ++ ++ After displaying ITIL object sections (ticket, Change, Problem) Waits for a ``
``. ++ + + ``pre_item_form`` + .. versionadded:: 9.1.2 diff --git a/source/plugins/hooks.rst b/source/plugins/hooks.rst index 13d94c7..a8738d2 100644 --- a/source/plugins/hooks.rst +++ b/source/plugins/hooks.rst @@ -124,7 +124,7 @@ These hooks will work just as the :ref:`hooks with item as parameter ``. + + +``post_itil_info_section`` + .. versionadded:: 11 + + After displaying ITIL object sections (ticket, Change, Problem) Waits for a ``
``. + ``pre_item_form`` .. versionadded:: 9.1.2 diff --git a/source/plugins/hooks.rst.orig b/source/plugins/hooks.rst.orig new file mode 100644 index 0000000..13d94c7 --- /dev/null +++ b/source/plugins/hooks.rst.orig @@ -0,0 +1,663 @@ +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, ... + +This page describes current existing hooks; but not the way they must be implemented from plugins. Please refer to the plugins development documentation. + +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. + +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): + +.. code-block:: php + + 'myplugin_updateitem_called', + 'Phone' => 'myplugin_updateitem_called' + ]; + +You will also have to declare the function you want to call in you ``hook.php`` file: + +.. code-block:: php + + ` 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: + +.. 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``, ``item_transfer``. + +Some hooks will receive a specific array as parameter, they will be detailled below. + +Unclassified +++++++++++++ + +Hooks that cannot be classified in above categories :) + +``secured_fields`` + .. versionadded:: 9.4.6 + + An array of fields names (with table like ``glpi_mytable.myfield``) that are stored using GLPI crypting methods. + This allows plugins to add some fields to the ``glpi:security:changekey`` command. + + .. warning:: + + Plugins have to ensure crypt migration on their side is OK; and once using it, they **must** properly declare fields. + + 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 + + An array of configuration entries that are stored using GLPI crypting methods. + This allows plugins to add some entries to the ``glpi:security:changekey`` command. + + .. warning:: + + Plugins have to ensure crypt migration on their side is OK; and once using it, they **must** properly declare fields. + + 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). + +``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! + + The name of the minified ``plugin.js`` file must be ``plugin.min.js`` + + +``add_css`` + Add CSS stylesheet on **all** pages headers + + .. versionadded:: 9.2 + + 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.css`` file must be ``plugin.min.css`` + +``display_central`` + Displays something on central page + +``display_login`` + Displays something on the login page + +``status`` + Displays status + +``post_init`` + After the framework initialization + +``rule_matched`` + After a rule has matched. + + This hook will receive a specific array that looks like: + + .. code-block:: php + + 'an item type', + 'rule_id' => 'tule id', + 'input' => array(), //original input + 'output' => array() //output modified by rule + ]; + +``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. + + +``init_session`` + At session initialization + +``change_entity`` + When entity is changed + +``change_profile`` + When profile is changed + +``pre_kanban_content`` + .. versionadded:: 9.5 + + Set or modify the content that shows before the main content in a Kanban card. + + 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 + 'content' => string //current content shown before main content + ]; + +``post_kanban_content`` + .. versionadded:: 9.5 + + 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: + + .. 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 + + Add new filter definitions for Kanban by itemtype. + + This data is set directly in $PLUGIN_HOOKS like: + + .. code-block:: php + + [ + '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. + + 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 + + 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 + ]; + + +``filter_actors`` + .. versionadded 9.5 + + Add or modify data actor fields provided in the right panel of ITIL objects + + .. 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 + + .. code-block:: php + + 'ExampleTab', + 'display_callable' => 'ExampleClass::displayDebugTab' + ] + ]; + +``post_plugin_install`` + Called after a plugin is installed + +``post_plugin_enable`` + Called after a plugin is enabled + +``post_plugin_disable`` + Called after a plugin is disabled + +``post_plugin_uninstall`` + Called after a plugin is uninstalled + +``post_plugin_clean`` + Called after a plugin is cleaned (removed from the database after the folder is deleted) + +Items business related +++++++++++++++++++++++ + +Hooks that can do some busines stuff on items. + +``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. + +``pre_item_add`` + Before an item has been added, allow to edit ``input`` property, setting it to false will stop the process. + +``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. + +``item_update`` + While updating an item, ``fields`` and ``updates`` properties can be used. + +``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. + +``pre_item_restore`` + Before an item is restored from trash. + +``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. + +``item_delete`` + After an item is moved to tash. + +``autoinventory_information`` + After an automated inventory has occured + +``item_transfer`` + When an item is transfered from an entity to another + +``item_can`` + .. versionadded:: 9.2 + + 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 + + Permit to filter search results. + +Items display related ++++++++++++++++++++++ + +Hooks that permits to add display on items. + + +``pre_item_form`` + .. versionadded:: 9.1.2 + + Before an item is displayed; just after the form header if any; or at the beginnning of the form. Waits for a ````. + + +``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 ````. + +``pre_show_item`` + Before an item is displayed + +``post_show_item`` + After an item has been displayed + +``pre_show_tab`` + Before a tab is displayed + +``post_show_tab`` + After a tab has been displayed + +``show_item_stats`` + .. versionadded:: 9.2.1 + + Add display from statistics tab of a item like ticket + +``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 adjusted. + + Display new actions in the ITIL object's timeline + +``timeline_answer_actions`` + .. versionadded:: 10.0.0 + + Display new actions in the ITIL object's answer dropdown + +``show_in_timeline`` + .. versionadded:: 10.0.0 + + Display forms in the ITIL object's timeline + +Notifications ++++++++++++++ +Hooks that are called from notifications + +``item_add_targets`` + When a target has been added to an item + +``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 + +``add_recipient_to_target`` + .. versionadded:: 9.4.0 + + 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. + +Functions hooks +^^^^^^^^^^^^^^^ + +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. + +.. code-block:: php + + ``). + +``retrieve_more_field_from_ldap`` + Retrieve aditional fields from LDAP for a user. Will receive the current fields lists, is expected to return a fields list. + +``retrieve_more_data_from_ldap`` + Retrieve aditional data from LDAP for a user. Will receive current fields list, is expected to return a fields list. + +``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 aray of item types to migrate. + +Automatic hooks +^^^^^^^^^^^^^^^ + +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. + +``dynamicReport`` + Add parameters for print. Will receive the ``$_GET`` array used for query. Is expected to return an array of parameters to add. + +``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 + + 'label' + ]; + +``MassiveActions`` + If plugin is parameted to provide massive actions (via ``$PLUGIN_HOOKS['use_massive_actions']``), will pass the item type as parameter, and expect an array of aditional massives actions of the form: + + .. code-block:: php + + 'label' + ]; + +``getDropDown`` + To declare extra dropdowns. Will not receive any parameter, and is expected to return an array of the form: + + .. code-block:: php + + 'label' + ]; + +``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. + +``preProcessRulePreviewResults`` + + .. todo:: + + Write documentation for this hook. + +``use_rules`` + + .. todo:: + + Write documentation for this hook. It lloks at bit particular. + +``ruleCollectionPrepareInputDataForProcess`` + Prepare input data for rules collections. Will receive an array of the form: + + .. code-block:: php + + 'name fo the rule itemtype', + 'values' => array( + 'input' => 'input array', + 'params' => 'array of parameters' + ) + ); + + Is expected to return an array. + +``preProcessRuleCollectionPreviewResults`` + +.. todo:: + + Write documentation for this hook. + +``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: + + .. code-block:: php + + 'where entity clause', + 'input' => 'input array', + 'criteria' => 'complex cirteria array', + 'sql_where' => 'sql where clause as string', + 'sql_from' => 'sql from clause as string' + ) + + Is expected to return the input array modified. + +``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. From 0337e7feeb139a00d37a6f03980adb9bbf321794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Tue, 17 Sep 2024 09:54:51 +0200 Subject: [PATCH 2/3] Delete patch.patch --- patch.patch | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 patch.patch diff --git a/patch.patch b/patch.patch deleted file mode 100644 index 327640e..0000000 --- a/patch.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/source/plugins/hooks.rst b/source/plugins/hooks.rst -index 47708ff..51479fd 100644 ---- a/source/plugins/hooks.rst -+++ b/source/plugins/hooks.rst -@@ -124,7 +124,7 @@ These hooks will work just as the :ref:`hooks with item as parameter ``. -+ -+ -+``post_itil_info_section`` -+ .. versionadded:: 11 -+ -+ After displaying ITIL object sections (ticket, Change, Problem) Waits for a ``
``. -+ - - ``pre_item_form`` - .. versionadded:: 9.1.2 From 0e1b46c5d5c43ef5117c6de099ac7e83a910e73e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Tue, 17 Sep 2024 09:55:05 +0200 Subject: [PATCH 3/3] Delete source/plugins/hooks.rst.orig --- source/plugins/hooks.rst.orig | 663 ---------------------------------- 1 file changed, 663 deletions(-) delete mode 100644 source/plugins/hooks.rst.orig diff --git a/source/plugins/hooks.rst.orig b/source/plugins/hooks.rst.orig deleted file mode 100644 index 13d94c7..0000000 --- a/source/plugins/hooks.rst.orig +++ /dev/null @@ -1,663 +0,0 @@ -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, ... - -This page describes current existing hooks; but not the way they must be implemented from plugins. Please refer to the plugins development documentation. - -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. - -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): - -.. code-block:: php - - 'myplugin_updateitem_called', - 'Phone' => 'myplugin_updateitem_called' - ]; - -You will also have to declare the function you want to call in you ``hook.php`` file: - -.. code-block:: php - - ` 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: - -.. 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``, ``item_transfer``. - -Some hooks will receive a specific array as parameter, they will be detailled below. - -Unclassified -++++++++++++ - -Hooks that cannot be classified in above categories :) - -``secured_fields`` - .. versionadded:: 9.4.6 - - An array of fields names (with table like ``glpi_mytable.myfield``) that are stored using GLPI crypting methods. - This allows plugins to add some fields to the ``glpi:security:changekey`` command. - - .. warning:: - - Plugins have to ensure crypt migration on their side is OK; and once using it, they **must** properly declare fields. - - 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 - - An array of configuration entries that are stored using GLPI crypting methods. - This allows plugins to add some entries to the ``glpi:security:changekey`` command. - - .. warning:: - - Plugins have to ensure crypt migration on their side is OK; and once using it, they **must** properly declare fields. - - 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). - -``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! - - The name of the minified ``plugin.js`` file must be ``plugin.min.js`` - - -``add_css`` - Add CSS stylesheet on **all** pages headers - - .. versionadded:: 9.2 - - 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.css`` file must be ``plugin.min.css`` - -``display_central`` - Displays something on central page - -``display_login`` - Displays something on the login page - -``status`` - Displays status - -``post_init`` - After the framework initialization - -``rule_matched`` - After a rule has matched. - - This hook will receive a specific array that looks like: - - .. code-block:: php - - 'an item type', - 'rule_id' => 'tule id', - 'input' => array(), //original input - 'output' => array() //output modified by rule - ]; - -``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. - - -``init_session`` - At session initialization - -``change_entity`` - When entity is changed - -``change_profile`` - When profile is changed - -``pre_kanban_content`` - .. versionadded:: 9.5 - - Set or modify the content that shows before the main content in a Kanban card. - - 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 - 'content' => string //current content shown before main content - ]; - -``post_kanban_content`` - .. versionadded:: 9.5 - - 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: - - .. 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 - - Add new filter definitions for Kanban by itemtype. - - This data is set directly in $PLUGIN_HOOKS like: - - .. code-block:: php - - [ - '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. - - 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 - - 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 - ]; - - -``filter_actors`` - .. versionadded 9.5 - - Add or modify data actor fields provided in the right panel of ITIL objects - - .. 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 - - .. code-block:: php - - 'ExampleTab', - 'display_callable' => 'ExampleClass::displayDebugTab' - ] - ]; - -``post_plugin_install`` - Called after a plugin is installed - -``post_plugin_enable`` - Called after a plugin is enabled - -``post_plugin_disable`` - Called after a plugin is disabled - -``post_plugin_uninstall`` - Called after a plugin is uninstalled - -``post_plugin_clean`` - Called after a plugin is cleaned (removed from the database after the folder is deleted) - -Items business related -++++++++++++++++++++++ - -Hooks that can do some busines stuff on items. - -``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. - -``pre_item_add`` - Before an item has been added, allow to edit ``input`` property, setting it to false will stop the process. - -``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. - -``item_update`` - While updating an item, ``fields`` and ``updates`` properties can be used. - -``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. - -``pre_item_restore`` - Before an item is restored from trash. - -``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. - -``item_delete`` - After an item is moved to tash. - -``autoinventory_information`` - After an automated inventory has occured - -``item_transfer`` - When an item is transfered from an entity to another - -``item_can`` - .. versionadded:: 9.2 - - 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 - - Permit to filter search results. - -Items display related -+++++++++++++++++++++ - -Hooks that permits to add display on items. - - -``pre_item_form`` - .. versionadded:: 9.1.2 - - Before an item is displayed; just after the form header if any; or at the beginnning of the form. Waits for a ````. - - -``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 ````. - -``pre_show_item`` - Before an item is displayed - -``post_show_item`` - After an item has been displayed - -``pre_show_tab`` - Before a tab is displayed - -``post_show_tab`` - After a tab has been displayed - -``show_item_stats`` - .. versionadded:: 9.2.1 - - Add display from statistics tab of a item like ticket - -``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 adjusted. - - Display new actions in the ITIL object's timeline - -``timeline_answer_actions`` - .. versionadded:: 10.0.0 - - Display new actions in the ITIL object's answer dropdown - -``show_in_timeline`` - .. versionadded:: 10.0.0 - - Display forms in the ITIL object's timeline - -Notifications -+++++++++++++ -Hooks that are called from notifications - -``item_add_targets`` - When a target has been added to an item - -``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 - -``add_recipient_to_target`` - .. versionadded:: 9.4.0 - - 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. - -Functions hooks -^^^^^^^^^^^^^^^ - -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. - -.. code-block:: php - - ``). - -``retrieve_more_field_from_ldap`` - Retrieve aditional fields from LDAP for a user. Will receive the current fields lists, is expected to return a fields list. - -``retrieve_more_data_from_ldap`` - Retrieve aditional data from LDAP for a user. Will receive current fields list, is expected to return a fields list. - -``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 aray of item types to migrate. - -Automatic hooks -^^^^^^^^^^^^^^^ - -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. - -``dynamicReport`` - Add parameters for print. Will receive the ``$_GET`` array used for query. Is expected to return an array of parameters to add. - -``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 - - 'label' - ]; - -``MassiveActions`` - If plugin is parameted to provide massive actions (via ``$PLUGIN_HOOKS['use_massive_actions']``), will pass the item type as parameter, and expect an array of aditional massives actions of the form: - - .. code-block:: php - - 'label' - ]; - -``getDropDown`` - To declare extra dropdowns. Will not receive any parameter, and is expected to return an array of the form: - - .. code-block:: php - - 'label' - ]; - -``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. - -``preProcessRulePreviewResults`` - - .. todo:: - - Write documentation for this hook. - -``use_rules`` - - .. todo:: - - Write documentation for this hook. It lloks at bit particular. - -``ruleCollectionPrepareInputDataForProcess`` - Prepare input data for rules collections. Will receive an array of the form: - - .. code-block:: php - - 'name fo the rule itemtype', - 'values' => array( - 'input' => 'input array', - 'params' => 'array of parameters' - ) - ); - - Is expected to return an array. - -``preProcessRuleCollectionPreviewResults`` - -.. todo:: - - Write documentation for this hook. - -``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: - - .. code-block:: php - - 'where entity clause', - 'input' => 'input array', - 'criteria' => 'complex cirteria array', - 'sql_where' => 'sql where clause as string', - 'sql_from' => 'sql from clause as string' - ) - - Is expected to return the input array modified. - -``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.