mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
implement plugin history, (GLPI feature #3423)
git-svn-id: https://forge.glpi-project.org/svn/example/trunk@192 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
parent
1daf2a0372
commit
f8e2050de4
6
hook.php
6
hook.php
@ -290,7 +290,7 @@ function plugin_example_MassiveActionsDisplay($options=array()) {
|
||||
case "plugin_example_DoIt" :
|
||||
echo " <input type='hidden' name='toto' value='1'>".
|
||||
"<input type='submit' name='massiveaction' class='submit' value='".
|
||||
__s('Post')."'> ".__('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
|
||||
|
@ -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 '';
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user