Skip to content

Commit

Permalink
fix group assignment logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ccailly authored Feb 21, 2024
1 parent ac57edc commit 1ac9eee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 7 additions & 4 deletions inc/group_group.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,31 @@ 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
if ($ticket_id > 0) {
$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 [];
}

Expand Down
10 changes: 4 additions & 6 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 1ac9eee

Please # to comment.