From 96cccde844d4c6a73b3eb8d88bdf68fbecb5a219 Mon Sep 17 00:00:00 2001 From: moyooo Date: Tue, 14 Feb 2012 15:59:44 +0000 Subject: [PATCH] add massiveacitn stats see #3272 git-svn-id: https://forge.glpi-project.org/svn/example/trunk@187 349b9182-4a13-0410-896f-e5e9767dd1b3 --- hook.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hook.php b/hook.php index 1245fdb..9047a35 100644 --- a/hook.php +++ b/hook.php @@ -310,8 +310,13 @@ function plugin_example_MassiveActionsDisplay($options=array()) { // How to process specific actions ? +// May return array of stats containing number of process: ok / ko / noright count to display stats function plugin_example_MassiveActionsProcess($data) { + $ok = 0; + $ko = 0; + $noright = 0; + switch ($data['action']) { case 'plugin_example_DoIt' : if ($data['itemtype'] == 'Computer') { @@ -322,6 +327,10 @@ function plugin_example_MassiveActionsProcess($data) { if ($val == 1) { if ($comp->getFromDB($key)) { Session::addMessageAfterRedirect("- ".$comp->getField("name")); + $ok++; + } else { + // Example of ko count + $ko++; } } } @@ -337,12 +346,20 @@ function plugin_example_MassiveActionsProcess($data) { if ($val == 1) { if ($ex->getFromDB($key)) { Session::addMessageAfterRedirect("- ".$ex->getField("name")); + $ok++; + } else { + // Example for noright / Maybe do it with can function is better + $noright++; } } } } break; } + return array('ok' => $ok, + 'ko' => $ko, + 'noright' => $noright); + }