From 0c30356d52b692c62a4d85a59000440f98f93334 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 12 Mar 2015 13:59:24 +0100 Subject: [PATCH] Add Menu::getPermission() and Menu::setPermission() Those two functions are required for filtering menu items based on a user's grants. refs #8720 --- library/Icinga/Web/Menu.php | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index 8d62563be2..872fd3249f 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -75,6 +75,17 @@ class Menu implements RecursiveIterator */ protected $parent; + /** + * Permission a user is required to have granted to display the menu item + * + * If a permission is set, authentication is of course required. + * + * Note that only one required permission can be set yet. + * + * @var string|null + */ + protected $permission; + /** * Create a new menu * @@ -442,15 +453,27 @@ public function addSubMenu($id, ConfigObject $menuConfig = null) } /** - * Set required Permissions + * Get the permission a user is required to have granted to display the menu item + * + * @return string|null + */ + public function getPermission() + { + return $this->permission; + } + + /** + * Set permission a user is required to have granted to display the menu item + * + * If a permission is set, authentication is of course required. * - * @param $permission + * @param string $permission * * @return $this */ - public function requirePermission($permission) + public function setPermission($permission) { - // Not implemented yet + $this->permission = (string) $permission; return $this; }