Skip to content

Commit

Permalink
Fix actors deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Lainow committed May 15, 2024
1 parent 0f8bbec commit 0208561
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions inc/ticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() => [
Expand All @@ -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;
}
}
}
}
Expand Down

0 comments on commit 0208561

Please sign in to comment.