Created
November 11, 2013 20:04
-
-
Save kaiohken1982/7419430 to your computer and use it in GitHub Desktop.
Zend Framework 1 Acl implementation #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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