From 1ac9eee5de34951f6d06b5ac805cf3ab3a78e60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Cailly?= <42278610+ccailly@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:41:25 +0100 Subject: [PATCH] fix group assignment logic --- inc/group_group.class.php | 11 +++++++---- setup.php | 10 ++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/inc/group_group.class.php b/inc/group_group.class.php index 162f99f1..6e932bdb 100644 --- a/inc/group_group.class.php +++ b/inc/group_group.class.php @@ -128,13 +128,16 @@ function manageGroup($groups_id) { } function getGroups($ticket_id, $removeAlreadyAssigned = true) { - $groups = $user_groups = $ticket_groups = []; + $groups = $user_groups = []; // get groups for user connected $tmp_user_groups = Group_User::getUserGroups($_SESSION['glpiID']); foreach ($tmp_user_groups as $current_group) { $user_groups[$current_group['id']] = $current_group['id']; - $groups[$current_group['id']] = $current_group['id']; + + if (!$_SESSION['plugins']['escalade']['config']['use_filter_assign_group']) { + $groups[$current_group['id']] = $current_group['id']; + } } // get groups already assigned in the ticket @@ -142,14 +145,14 @@ function getGroups($ticket_id, $removeAlreadyAssigned = true) { $ticket = new Ticket(); $ticket->getFromDB($ticket_id); foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $current_group) { - $ticket_groups[$current_group['groups_id']] = $current_group['groups_id']; + $groups[$current_group['groups_id']] = $current_group['groups_id']; } } // To do an escalation, the user must be in a group currently assigned to the ticket // or no group is assigned to the ticket // TODO : matching with "view all tickets (yes/no) option in profile user" - if (!empty($ticket_groups) && count(array_intersect($ticket_groups, $user_groups)) == 0) { + if (!empty($groups) && count(array_intersect($groups, $user_groups)) == 0) { return []; } diff --git a/setup.php b/setup.php index 1f5b7594..b1d7fae2 100644 --- a/setup.php +++ b/setup.php @@ -138,12 +138,10 @@ function plugin_init_escalade() { ]; $PLUGIN_HOOKS['item_add']['escalade']['User'] = 'plugin_escalade_item_add_user'; - //filter group feature - if ($escalade_config['use_filter_assign_group']) { - $PLUGIN_HOOKS[Hooks::FILTER_ACTORS]['escalade'] = [ - 'PluginEscaladeTicket', 'filter_actors', - ]; - } + //filter group feature + $PLUGIN_HOOKS[Hooks::FILTER_ACTORS]['escalade'] = [ + 'PluginEscaladeTicket', 'filter_actors', + ]; // == Interface links == if (Session::haveRight('config', UPDATE)) {