From 7ed3acbbd806794291794430d082f0416dc367c9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 26 Sep 2016 11:00:42 +0200 Subject: [PATCH] Module: Check a menu item's permission and don't overwrite its label This allows now totally different values for an item's name and label and fixes the bug that permissions declared in the configuration.php were not evaluated for menu items. fixes #11431 --- library/Icinga/Application/Modules/Module.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index f62684471..de40266e1 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -362,25 +362,28 @@ class Module public function getMenu() { $this->launchConfigScript(); - return $this->createMenu($this->menuItems); + return Navigation::fromArray($this->createMenu($this->menuItems)); } /** - * Create and return a new navigation for the given menu items + * Create and return an array structure for the given menu items * * @param MenuItemContainer[] $items * - * @return Navigation + * @return array */ private function createMenu(array $items) { - $navigation = new Navigation(); + $navigation = array(); foreach ($items as $item) { /** @var MenuItemContainer $item */ - $navigationItem = $navigation->createItem($item->getName(), $item->getProperties()); - $navigationItem->setChildren($this->createMenu($item->getChildren())); - $navigationItem->setLabel($this->translate($item->getName())); - $navigation->addItem($navigationItem); + $properties = $item->getProperties(); + $properties['children'] = $this->createMenu($item->getChildren()); + if (! isset($properties['label'])) { + $properties['label'] = $this->translate($item->getName()); + } + + $navigation[$item->getName()] = $properties; } return $navigation;