Skip to content

Commit

Permalink
System: Access: Privileges - fix updating groups dropping privileges …
Browse files Browse the repository at this point in the history
…for #8046
  • Loading branch information
AdSchellevis committed Nov 13, 2024
1 parent f6b2a4f commit 0f5fc99
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,19 @@ public function setItemAction($id)
$result = parent::setAction();
if ($result['result'] != 'failed') {
$mdl = $this->getModel();
$u_uuids = explode(',', $mdl->users->getCurrentValue());
$g_uuids = explode(',', $mdl->groups->getCurrentValue());
$usermdl = new User();
$groupmdl = new Group();
foreach ([$usermdl->user, $groupmdl->group] as $topic) {
if ($topic == $usermdl->user) {
$uuids = explode(',', $mdl->users->getCurrentValue());
} else {
$uuids = explode(',', $mdl->groups->getCurrentValue());
}
foreach ($topic->iterateItems() as $uuid => $item) {
$privlist = array_filter(explode(',', $item->priv->getCurrentValue()));
if (!in_array($uuid, $u_uuids) && in_array($id, $privlist)) {
unset($privlist[array_search($uuid, $privlist)]);
} elseif (in_array($uuid, $u_uuids) && !in_array($id, $privlist)) {
if (!in_array($uuid, $uuids) && in_array($id, $privlist)) {
unset($privlist[array_search($id, $privlist)]);
} elseif (in_array($uuid, $uuids) && !in_array($id, $privlist)) {
$privlist[] = $id;
} else {
continue;
Expand Down

0 comments on commit 0f5fc99

Please sign in to comment.