From 4f57c9b397462d7bf0436b0beec7f6658c8ad3b6 Mon Sep 17 00:00:00 2001 From: remicollet Date: Wed, 24 Feb 2010 07:18:23 +0000 Subject: [PATCH] improves getDatasForTemplate + create 'item_get_datas' hook git-svn-id: https://forge.glpi-project.org/svn/example/trunk@140 349b9182-4a13-0410-896f-e5e9767dd1b3 --- hook.php | 7 +++++-- inc/notificationtargetexample.class.php | 5 ++--- setup.php | 5 ++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hook.php b/hook.php index ed6400f..17135ad 100644 --- a/hook.php +++ b/hook.php @@ -692,8 +692,11 @@ function plugin_example_AssignToTicket($types) { return $types; } -function plugin_example_add_event(NotificationTargetTicket $target) { +function plugin_example_get_events(NotificationTargetTicket $target) { $target->events['plugin_example'] = "Example event"; - logDebug("plugin_example_add_event",$target->events); +} + +function plugin_example_get_datas(NotificationTargetTicket $target) { + $target->datas['##ticket.example##'] = "Example datas"; } ?> \ No newline at end of file diff --git a/inc/notificationtargetexample.class.php b/inc/notificationtargetexample.class.php index e2f78b1..3c8f6b5 100644 --- a/inc/notificationtargetexample.class.php +++ b/inc/notificationtargetexample.class.php @@ -40,11 +40,10 @@ class PluginExampleNotificationTargetExample extends NotificationTarget { return array ('alert' => 'alert example'); } - function getDatasForTemplate($event,$options=array()) { + function getDatasForTemplate($event, $options=array()) { global $DB, $LANG, $CFG_GLPI; - $tpldatas = array(); - return $tpldatas; + $this->datas['##example.name##'] = 'Example'; } } ?> \ No newline at end of file diff --git a/setup.php b/setup.php index e4a755d..b76a902 100755 --- a/setup.php +++ b/setup.php @@ -106,7 +106,10 @@ function plugin_init_example() { // Add event to GLPI core itemtype, event will be raised by the plugin. // See plugin_example_uninstall for cleanup of notification - $PLUGIN_HOOKS['item_get_events']['example'] = array('NotificationTargetTicket'=>'plugin_example_add_event'); + $PLUGIN_HOOKS['item_get_events']['example'] = array('NotificationTargetTicket'=>'plugin_example_get_events'); + + // Add datas to GLPI core itemtype for notifications template. + $PLUGIN_HOOKS['item_get_datas']['example'] = array('NotificationTargetTicket'=>'plugin_example_get_datas'); $PLUGIN_HOOKS['item_transfer']['example'] = 'plugin_item_transfer_example';