From f8e2050de4eba1f95ca628b29ad501d049bc1e08 Mon Sep 17 00:00:00 2001 From: remicollet Date: Wed, 23 May 2012 14:36:02 +0000 Subject: [PATCH] implement plugin history, (GLPI feature #3423) git-svn-id: https://forge.glpi-project.org/svn/example/trunk@192 349b9182-4a13-0410-896f-e5e9767dd1b3 --- hook.php | 6 ++++-- inc/example.class.php | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/hook.php b/hook.php index a459328..da87c0e 100644 --- a/hook.php +++ b/hook.php @@ -290,7 +290,7 @@ function plugin_example_MassiveActionsDisplay($options=array()) { case "plugin_example_DoIt" : echo " ". " ".__('but do nothing :)'); + __s('Post')."'> ".__('Write in item history'); break; } break; @@ -322,11 +322,13 @@ function plugin_example_MassiveActionsProcess($data) { if ($data['itemtype'] == 'Computer') { $comp = new Computer(); Session::addMessageAfterRedirect(__("Right it is the type I want...")); - Session::addMessageAfterRedirect(__("But... I say I will do nothing for:")); + Session::addMessageAfterRedirect(__('Write in item history')); + $changes = array(0, 'old value', 'new value'); foreach ($data['item'] as $key => $val) { if ($val == 1) { if ($comp->getFromDB($key)) { Session::addMessageAfterRedirect("- ".$comp->getField("name")); + Log::history($key, 'Computer', $changes, 'PluginExampleExample', Log::HISTORY_PLUGIN); $ok++; } else { // Example of ko count diff --git a/inc/example.class.php b/inc/example.class.php index 69fbbeb..ad97128 100644 --- a/inc/example.class.php +++ b/inc/example.class.php @@ -305,5 +305,24 @@ class PluginExampleExample extends CommonDBTM { break; } } + + /** + * Get an history entry message + * + * @param $data Array from glpi_logs table + * + * @since GLPI version 0.84 + * + * @return string + **/ + static function getHistoryEntry($data) { + + switch($data['linked_action'] - Log::HISTORY_PLUGIN) { + case 0: + return _('History from plugin example'); + } + + return ''; + } } ?> \ No newline at end of file