Skip to content

Commit

Permalink
Fix escalation history (#222)
Browse files Browse the repository at this point in the history
* Fix escalation history

* Add suggestions

* Search group by id

* Add suggestions
  • Loading branch information
Lainow authored Jul 31, 2024
1 parent af2648e commit aec94ba
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions inc/ticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static function pre_item_update(CommonDBTM $item)
$item->input['_do_not_compute_status'] = true;
}
$config = $_SESSION['plugins']['escalade']['config'];
$old_groups = [];

// Get actual actors for the ticket
if ($item instanceof Ticket) {
Expand All @@ -71,6 +72,10 @@ function ($carry, $type) use ($item) {
[]
);

$old_groups = array_filter($ticket_actors['assign'], function ($actor) {
return isset($actor['itemtype']) && $actor['itemtype'] === 'Group';
});

// Get deletion rights for each type of actor
$deletion_rights = [
User::getType() => [
Expand Down Expand Up @@ -113,13 +118,34 @@ function ($carry, $type) use ($item) {
}
}
}
} else {
}
if (
isset($item->input['_actors']['assign'])
) {
$new_groups = array_filter($item->input['_actors']['assign'], function ($actor) {
return isset($actor['itemtype']) && $actor['itemtype'] === 'Group';
});
if (
(isset($item->input['actortype']) && $item->input['actortype'] == CommonITILActor::ASSIGN)
(isset($item->input['actortype']) && $item->input['actortype'] == CommonITILActor::ASSIGN) &&
(
count($old_groups) < count($new_groups)
)
) {
//disable notification to prevent notification for old AND new group
$item->input['_disablenotif'] = true;
return PluginEscaladeTicket::addHistoryOnAddGroup($item);
} else if (count($old_groups) == count($new_groups)) {
$old_group_ids = [];
foreach ($old_groups as $old_group) {
$old_group_ids[$old_group['items_id']] = true;
}

foreach ($new_groups as $new_group) {
if (!isset($old_group_ids[$new_group['items_id']])) {
$item->input['_disablenotif'] = true;
return PluginEscaladeTicket::addHistoryOnAddGroup($item);
}
}
}
return $item;
}
Expand Down

0 comments on commit aec94ba

Please sign in to comment.