Skip to content

Fix group removal on escalation only - #483

Open
UncleTomsCabi wants to merge 4 commits into
pluginsGLPI:mainfrom
UncleTomsCabi:fix/group-reassignment-behavior
Open

Fix group removal on escalation only#483
UncleTomsCabi wants to merge 4 commits into
pluginsGLPI:mainfrom
UncleTomsCabi:fix/group-reassignment-behavior

Conversation

@UncleTomsCabi

Copy link
Copy Markdown

Previously, when the "Remove previously assigned group when assigning a group" option was enabled, adding a group through the standard GLPI actors field also removed all previously assigned groups.

Now, previously assigned groups are removed only when the Escalade reassignment action is used. Adding groups through the standard GLPI actors field keeps the existing assigned groups.

The visual group assignment history has also been updated so that all groups that were assigned before a reassignment remain visible in the history.

@stonebuzz
stonebuzz requested review from Rom1-B and stonebuzz August 13, 2026 07:45
@stonebuzz

Copy link
Copy Markdown
Contributor

Please Fix CI

Comment thread inc/history.class.php Outdated
Comment on lines +172 to +194
// Do not display a group as a previous assignment while it is still
// assigned to the ticket. Its history entry stays in the database and
// becomes visible after a real reassignment removes the group.
$group_ticket = new Group_Ticket();
$currently_assigned = $group_ticket->find([
'tickets_id' => $tickets_id,
'type' => CommonITILActor::ASSIGN,
]);

$currently_assigned_ids = array_map(
static fn(array $actor): int => (int) $actor['groups_id'],
$currently_assigned,
);

$found = array_filter(
$found,
static fn(array $history_entry): bool => !in_array(
(int) $history_entry['groups_id'],
$currently_assigned_ids,
true,
),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "hide currently-assigned groups from history" filter runs unconditionally, including when getHistory($tickets_id, true) is called for the "full assignation history" popup (front/popup_histories.php:50). Two consequences: (1) the popup, meant to be a complete audit trail, will never show a group that happens to still be assigned; (2) since only the single most-recently-modified group is shifted off as "current" (line 170), a ticket with several concurrently assigned groups — a scenario this very PR re-legitimizes via testStandardGroupAssignmentKeepsExistingGroups — will have all but one of its active groups vanish from the widget entirely, shown neither as current nor as history. Was hiding active groups meant to apply only to the compact/inline view ($full_history === false), and not to the full popup?

Comment thread inc/history.class.php Outdated
['tickets_id' => $tickets_id],
['date_mod DESC', 'id DESC'],
);
$nb_histories = count($found);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$nb_histories is captured before the new currently-assigned filter runs, so the "show ... full-history link" check at line 257 ($nb_histories - 1 > self::HISTORY_LIMIT) now overcounts relative to what's actually displayed.

Comment thread inc/history.class.php Outdated
@stonebuzz

Copy link
Copy Markdown
Contributor

hi @UncleTomsCabi

Can you rebase ?

UncleTomsCabi and others added 4 commits August 18, 2026 13:17
Previously, when the "Remove previously assigned group when assigning a group" option was enabled, adding a group through the standard GLPI actors field also removed all previously assigned groups.

Now, previously assigned groups are removed only when the Escalade reassignment action is used. Adding groups through the standard GLPI actors field keeps the existing assigned groups.

The visual group assignment history has also been updated so that all groups that were assigned before a reassignment remain visible in the history.
Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
@UncleTomsCabi
UncleTomsCabi force-pushed the fix/group-reassignment-behavior branch from ae2fe1f to 45040c7 Compare August 18, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants