mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
implements filter_actors hook
This commit is contained in:
parent
4f6d2291e3
commit
44fe7d6b57
16
hook.php
16
hook.php
@ -686,3 +686,19 @@ function plugin_example_infocom_hook($params) {
|
|||||||
echo __("Plugin example displays on central page", "example");
|
echo __("Plugin example displays on central page", "example");
|
||||||
echo "</th></tr>";
|
echo "</th></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function plugin_example_filter_actors(array $params = []): array {
|
||||||
|
$itemtype = $params['params']['itemtype'];
|
||||||
|
$items_id = $params['params']['items_id'];
|
||||||
|
|
||||||
|
// remove users_id = 1 for assignee list
|
||||||
|
if ($itemtype == 'Ticket' && $params['params']['actortype'] == 'assign') {
|
||||||
|
foreach ($params['actors'] as $index => &$actor) {
|
||||||
|
if ($actor['type'] == 'user' && $actor['items_id'] == 1) {
|
||||||
|
unset($params['actors'][$index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
// Purpose of file:
|
// Purpose of file:
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
use Glpi\Plugin\Hooks;
|
||||||
|
|
||||||
define ('PLUGIN_EXAMPLE_VERSION', '7.1');
|
define ('PLUGIN_EXAMPLE_VERSION', '7.1');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,13 +204,15 @@ function plugin_init_example() {
|
|||||||
$PLUGIN_HOOKS['post_item_form']['example'] = ['PluginExampleItemForm', 'postItemForm'];
|
$PLUGIN_HOOKS['post_item_form']['example'] = ['PluginExampleItemForm', 'postItemForm'];
|
||||||
|
|
||||||
// declare this plugin as an import plugin for Computer itemtype
|
// declare this plugin as an import plugin for Computer itemtype
|
||||||
$PLUGIN_HOOKS['import_item']['exemple'] = ['Computer' => ['Plugin']];
|
$PLUGIN_HOOKS['import_item']['example'] = ['Computer' => ['Plugin']];
|
||||||
|
|
||||||
// add additional informations on Computer::showForm
|
// add additional informations on Computer::showForm
|
||||||
$PLUGIN_HOOKS['autoinventory_information']['exemple'] = [
|
$PLUGIN_HOOKS['autoinventory_information']['example'] = [
|
||||||
'Computer' => ['PluginExampleComputer', 'showInfo']
|
'Computer' => ['PluginExampleComputer', 'showInfo']
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$PLUGIN_HOOKS[Hooks::FILTER_ACTORS]['example'] = "plugin_example_filter_actors";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user