Skip to content

Commit

Permalink
fix: add maybeDeleted to check
Browse files Browse the repository at this point in the history
  • Loading branch information
Rom1-B authored and trasher committed Jun 4, 2024
1 parent d8a0b9f commit a6fc09b
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/CommonDBConnexity.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,22 +309,24 @@ public function checkAttachedItemChangesAllowed(array $input, array $fields)
// Solution 1 : If we cannot create the new item or delete the old item,
// then we cannot update the item
unset($new_item->fields);

if (
!$new_item->can(-1, CREATE, $input)
|| !$this->can($this->getID(), DELETE)
|| !$this->can($this->getID(), PURGE)
$new_item->can(-1, CREATE, $input)
&& (!$this->maybeDeleted() || $this->can($this->getID(), DELETE))
&& $this->can($this->getID(), PURGE)
) {
Session::addMessageAfterRedirect(
sprintf(
__('Cannot update item %s #%s: not enough right on the parent(s) item(s)'),
$new_item->getTypeName(),
$new_item->getID()
),
INFO,
true
);
return false;
return true;
}
Session::addMessageAfterRedirect(
sprintf(
__('Cannot update item %s #%s: not enough right on the parent(s) item(s)'),
$new_item->getTypeName(),
$new_item->getID()
),
INFO,
true
);
return false;

// Solution 2 : simple check ! Can we update the item with new values ?
// if (!$new_item->can($input['id'], 'w')) {
Expand Down

0 comments on commit a6fc09b

Please sign in to comment.