From 2621e6ceb90ce58c2600dc741a22892c5ee1e1ed Mon Sep 17 00:00:00 2001 From: Alexandre Delaunay Date: Thu, 21 Feb 2019 09:50:53 +0100 Subject: [PATCH] implement new hook timeline_actions --- inc/itemform.class.php | 24 ++++++++++++++++++++++++ setup.php | 5 +++++ 2 files changed, 29 insertions(+) diff --git a/inc/itemform.class.php b/inc/itemform.class.php index 77dcaa7..8e7274f 100644 --- a/inc/itemform.class.php +++ b/inc/itemform.class.php @@ -117,4 +117,28 @@ class PluginExampleItemForm { echo $out; } + + static public function timelineActions($params = []) { + $rand = $params['rand']; + $ticket = $params['item']; + + if (get_class($ticket) !== "Ticket") { + return false; + } + + $edit_panel = "viewitem".$ticket->fields['id'].$rand; + $JS = << + ". + __("Send a notification"). + Html::scriptBlock($JS)." + "; + } } diff --git a/setup.php b/setup.php index 9f4b21a..0e32dd6 100755 --- a/setup.php +++ b/setup.php @@ -204,6 +204,11 @@ function plugin_init_example() { $PLUGIN_HOOKS['pre_item_form']['example'] = ['PluginExampleItemForm', 'preItemForm']; $PLUGIN_HOOKS['post_item_form']['example'] = ['PluginExampleItemForm', 'postItemForm']; + // Add new actions to timeline + $PLUGIN_HOOKS['timeline_actions']['example'] = [ + 'PluginExampleItemForm', 'timelineActions' + ]; + // declare this plugin as an import plugin for Computer itemtype $PLUGIN_HOOKS['import_item']['example'] = ['Computer' => ['Plugin']];