Skip to content

Commit

Permalink
BugFix: Fixed some cases where the menu items were rendered despite t…
Browse files Browse the repository at this point in the history
…he fact that the user didn't have the access rights.
  • Loading branch information
NGjata committed Apr 9, 2021
1 parent 10c8795 commit 451dd51
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Core/Menu/MenuBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,16 @@ private function processMenu(array $menu, bool $child = false, string $type = se

private function unsetDisabledItem(array &$menu): void
{
foreach ($menu as $index => $menuItem) {
//Keep outside otherwise the variable references get lost due to unset call.
$firstKey = array_keys($menu)[0];
$menuLength = count($menu);

for ($i=$firstKey; $i<$menuLength; $i++) {
//todo: transform item in menuItem
if (!$this->isEnabled($menuItem) || !$menuItem['enable']) {
unset($menu[$index]);
} else if ($menuItem['submenu']) {
$this->unsetDisabledItem($menuItem['submenu']);
if (!$this->isEnabled($menu[$i]) || !$menu[$i]['enable']) {
unset($menu[$i]);
} else if ($menu[$i]['submenu']) {
$this->unsetDisabledItem($menu[$i]['submenu']);
}
}
}
Expand Down

0 comments on commit 451dd51

Please sign in to comment.