mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-24 06:14:25 +02:00
Web: Fix that shared child menu entries were not displayed for non-owners
fixes #10319
This commit is contained in:
parent
d5fe0c9610
commit
5fcd65a05a
@ -139,19 +139,37 @@ class Web extends EmbeddedWeb
|
|||||||
return $this->viewRenderer;
|
return $this->viewRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function hasAccessToSharedNavigationItem(& $config)
|
private function hasAccessToSharedNavigationItem(& $config, Config $navConfig)
|
||||||
{
|
{
|
||||||
// TODO: Provide a more sophisticated solution
|
// TODO: Provide a more sophisticated solution
|
||||||
|
|
||||||
if (isset($config['owner']) && $config['owner'] === $this->user->getUsername()) {
|
if (isset($config['owner']) && $config['owner'] === $this->user->getUsername()) {
|
||||||
unset($config['owner']);
|
unset($config['owner']);
|
||||||
|
unset($config['users']);
|
||||||
|
unset($config['groups']);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($config['parent']) && $navConfig->hasSection($config['parent'])) {
|
||||||
|
unset($config['owner']);
|
||||||
|
if (isset($this->accessibleMenuItems[$config['parent']])) {
|
||||||
|
return $this->accessibleMenuItems[$config['parent']];
|
||||||
|
}
|
||||||
|
|
||||||
|
$parentConfig = $navConfig->getSection($config['parent']);
|
||||||
|
$this->accessibleMenuItems[$config['parent']] = $this->hasAccessToSharedNavigationItem(
|
||||||
|
$parentConfig,
|
||||||
|
$navConfig
|
||||||
|
);
|
||||||
|
return $this->accessibleMenuItems[$config['parent']];
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($config['users'])) {
|
if (isset($config['users'])) {
|
||||||
$users = array_map('trim', explode(',', strtolower($config['users'])));
|
$users = array_map('trim', explode(',', strtolower($config['users'])));
|
||||||
if (in_array('*', $users, true) || in_array($this->user->getUsername(), $users, true)) {
|
if (in_array('*', $users, true) || in_array($this->user->getUsername(), $users, true)) {
|
||||||
|
unset($config['owner']);
|
||||||
unset($config['users']);
|
unset($config['users']);
|
||||||
|
unset($config['groups']);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,6 +177,8 @@ class Web extends EmbeddedWeb
|
|||||||
if (isset($config['groups'])) {
|
if (isset($config['groups'])) {
|
||||||
$groups = array_map('trim', explode(',', strtolower($config['groups'])));
|
$groups = array_map('trim', explode(',', strtolower($config['groups'])));
|
||||||
if (in_array('*', $groups, true)) {
|
if (in_array('*', $groups, true)) {
|
||||||
|
unset($config['owner']);
|
||||||
|
unset($config['users']);
|
||||||
unset($config['groups']);
|
unset($config['groups']);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -166,6 +186,8 @@ class Web extends EmbeddedWeb
|
|||||||
$userGroups = array_map('strtolower', $this->user->getGroups());
|
$userGroups = array_map('strtolower', $this->user->getGroups());
|
||||||
$matches = array_intersect($userGroups, $groups);
|
$matches = array_intersect($userGroups, $groups);
|
||||||
if (! empty($matches)) {
|
if (! empty($matches)) {
|
||||||
|
unset($config['owner']);
|
||||||
|
unset($config['users']);
|
||||||
unset($config['groups']);
|
unset($config['groups']);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -207,8 +229,17 @@ class Web extends EmbeddedWeb
|
|||||||
} else {
|
} else {
|
||||||
$items = array();
|
$items = array();
|
||||||
foreach ($config as $name => $typeConfig) {
|
foreach ($config as $name => $typeConfig) {
|
||||||
if ($this->hasAccessToSharedNavigationItem($typeConfig)) {
|
if (isset($this->accessibleMenuItems[$name])) {
|
||||||
$items[$name] = $typeConfig;
|
if ($this->accessibleMenuItems[$name]) {
|
||||||
|
$items[$name] = $typeConfig;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($this->hasAccessToSharedNavigationItem($typeConfig, $config)) {
|
||||||
|
$this->accessibleMenuItems[$name] = true;
|
||||||
|
$items[$name] = $typeConfig;
|
||||||
|
} else {
|
||||||
|
$this->accessibleMenuItems[$name] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user