Nette\Security\User::isAllowed PHP Method

isAllowed() public method

Has a user effective access to the Resource? If $resource is NULL, then the query applies to all resources.
public isAllowed ( $resource = IAuthorizator::ALL, $privilege = IAuthorizator::ALL ) : boolean
return boolean
    public function isAllowed($resource = IAuthorizator::ALL, $privilege = IAuthorizator::ALL)
    {
        foreach ($this->getRoles() as $role) {
            if ($this->getAuthorizator()->isAllowed($role, $resource, $privilege)) {
                return TRUE;
            }
        }
        return FALSE;
    }

Usage Example

Beispiel #1
0
 /**
  * Add menu item
  * @param string $title Text in anchor
  * @param string $module destination module
  * @param string $presenter destination presenter
  * @param string $action destination action
  * @param string $auth resource for authorizator
  * @param boolean $clickable is anchor clickable?
  * @return void
  */
 public function addItem($title, $module, $presenter, $action, $auth, $clickable = true)
 {
     if ($this->user->isAllowed($auth, "view")) {
         $this->items[] = array("title" => $title, "module" => $module, "presenter" => $presenter, "action" => $action, "clickable" => $clickable);
     }
     return;
 }
All Usage Examples Of Nette\Security\User::isAllowed