From 02085611a74fdefcb76783078c0ba0cc9926cdc1 Mon Sep 17 00:00:00 2001 From: Lainow Date: Wed, 15 May 2024 10:17:21 +0200 Subject: [PATCH] Fix actors deletion --- inc/ticket.class.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/inc/ticket.class.php b/inc/ticket.class.php index a88bbec..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,12 +90,16 @@ function ($carry, $type) use ($item) { ], ]; - // 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 (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; + } } } }