Exemple #1
0
 /**
  * Check if the use is allowed to view the resource
  *
  * @param string $resource
  * @param string $privilege
  * @param string $role
  * @return boolean
  */
 public function isAllowed($resource = null, $privilege = null, $role = null)
 {
     // Default business rule to return null instead of throwing exceptions for non-known resources
     if (!$this->_acl->has($resource)) {
         $resource = null;
     }
     if (null === $role) {
         return $this->_acl->isAllowedRole($resource, $privilege);
         // Attempt to automatically fetch the role
     } else {
         return $this->_acl->isAllowed($resource, $privilege, $role);
     }
 }
Exemple #2
0
    /**
     * Get the acl
     *
     * @throws Zym_ACL_Exception
     * @return Zym_ACL_Abstract
     */
    protected function _getAcl()
    {
        if ($this->_acl === null) {
            $this->_acl = Zym_Acl::getACL();
        }

        return $this->_acl;
    }