diff --git a/inc/ticket.class.php b/inc/ticket.class.php index 3c253d1..3313e16 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -73,9 +73,6 @@ function ($carry, $type) use ($item) { [] ); - // Get updated actors - $actors_update = $item->input['_actors'] ?? []; - // Get deletion rights for each type of actor $deletion_rights = [ User::getType() => [ @@ -93,21 +90,16 @@ function ($carry, $type) use ($item) { ], ]; - // Iteration through actor types and verification of deletion rights - foreach ($ticket_actors as $type => $actors) { - $updatedActors = array_map( - function ($a) { - return [$a['items_id'], $a['itemtype']]; - }, - $actors_update[$type] ?? [] - ); - - foreach ($actors as $actor) { - $actorKey = [$actor['items_id'], $actor['itemtype']]; - - // If the actor has been deleted and deletion is forbidden, it is readjusted to simulate a non-deletion - if (!in_array($actorKey, $updatedActors) && empty($deletion_rights[$actor['itemtype']][$type])) { - $item->input['_actors'][$type][] = $actor; + if (!isset($item->input['_actors'])) { + $item->input['_actors'] = $item->fields['_actors']; + } else { + // Iteration through actor types and verification of deletion rights + foreach ($ticket_actors as $type => $actors) { + foreach ($actors as $actor) { + // If the actor has been deleted and deletion is forbidden, it is readjusted to simulate a non-deletion + if ($deletion_rights[$actor['itemtype']][$type] == 0) { + $item->input['_actors'][$type][] = $actor; + } } } }