mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
lib: Add View::hasPermission()
This commit is contained in:
parent
6da3cb8403
commit
cd8822ceff
@ -4,10 +4,11 @@
|
||||
|
||||
namespace Icinga\Web;
|
||||
|
||||
use Closure;
|
||||
use Zend_View_Abstract;
|
||||
use Icinga\Authentication\Manager;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Util\Translator;
|
||||
use Zend_View_Abstract;
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* Icinga view
|
||||
@ -36,6 +37,13 @@ class View extends Zend_View_Abstract
|
||||
*/
|
||||
private $helperFunctions = array();
|
||||
|
||||
/**
|
||||
* Authentication manager
|
||||
*
|
||||
* @type \Icinga\Authentication\Manager|null
|
||||
*/
|
||||
private $auth;
|
||||
|
||||
/**
|
||||
* Create a new view object
|
||||
*
|
||||
@ -154,6 +162,31 @@ class View extends Zend_View_Abstract
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authentication manager
|
||||
*
|
||||
* @return Manager
|
||||
*/
|
||||
public function Auth()
|
||||
{
|
||||
if ($this->auth === null) {
|
||||
$this->auth = Manager::getInstance();
|
||||
}
|
||||
return $this->auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the current user has the given permission
|
||||
*
|
||||
* @param string $permission Name of the permission
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPermission($permission)
|
||||
{
|
||||
return $this->Auth()->hasPermission($permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to include the view script in a scope that only allows public
|
||||
* members.
|
||||
|
Loading…
x
Reference in New Issue
Block a user