Skip to content

Instantly share code, notes, and snippets.

@kaiohken1982
Created November 11, 2013 20:04
Show Gist options
  • Select an option

  • Save kaiohken1982/7419430 to your computer and use it in GitHub Desktop.

Select an option

Save kaiohken1982/7419430 to your computer and use it in GitHub Desktop.
Zend Framework 1 Acl implementation #3
<?php
/**
* Ci da la possibilità di effettuare queries all'oggetto ACL
*
* @author Sergio Rinaudo
*/
class My_Controller_Action_Helper_Acl
extends Zend_Controller_Action_Helper_Abstract
{
protected $_acl = null;
protected $_auth = null;
protected $_front = null;
public function init()
{
$this->_acl = My_Acl::getInstance();
$this->_auth = Zend_Auth::getInstance();
$this->_front = Zend_Controller_Front::getInstance();
}
public function isAllowed($role = null, $resource = null, $privilege = null)
{
return $this->_acl->isAllowed($role,$resource,$privilege);
}
public function isCurrentUserAllowedHere()
{
$identity = $this->_auth->getIdentity();
$role = null !== $identity ? $identity->role : My_Acl::ROLE_GUEST;
$request = $this->_front->getRequest();
return $this->isAllowed($role,$request->getControllerName(),$request->getActionName());
}
/**
* Strategy Pattern
*
* @return bool
*/
public function direct()
{
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment