Skip to content

Commit

Permalink
Add Menu::getPermission() and Menu::setPermission()
Browse files Browse the repository at this point in the history
Those two functions are required for filtering menu items based on a user's grants.

refs #8720
  • Loading branch information
lippserd committed Mar 12, 2015
1 parent 83443a5 commit 0c30356
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions library/Icinga/Web/Menu.php
Expand Up @@ -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
*
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 0c30356

Please sign in to comment.