implements filter_actors hook

This commit is contained in:
Alexandre Delaunay 2022-01-10 11:13:15 +01:00 committed by GitHub
parent 4f6d2291e3
commit 44fe7d6b57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -686,3 +686,19 @@ function plugin_example_infocom_hook($params) {
echo __("Plugin example displays on central page", "example");
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;
}

View File

@ -31,6 +31,8 @@
// Purpose of file:
// ----------------------------------------------------------------------
use Glpi\Plugin\Hooks;
define ('PLUGIN_EXAMPLE_VERSION', '7.1');
/**
@ -202,13 +204,15 @@ function plugin_init_example() {
$PLUGIN_HOOKS['post_item_form']['example'] = ['PluginExampleItemForm', 'postItemForm'];
// 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
$PLUGIN_HOOKS['autoinventory_information']['exemple'] = [
$PLUGIN_HOOKS['autoinventory_information']['example'] = [
'Computer' => ['PluginExampleComputer', 'showInfo']
];
$PLUGIN_HOOKS[Hooks::FILTER_ACTORS]['example'] = "plugin_example_filter_actors";
}