Guest User

Untitled

a guest
Nov 17th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.87 KB | None | 0 0
  1. <?php
  2.  
  3. class Application_Acl_Setup
  4. {
  5.     protected $_acl;
  6.  
  7.     public function __construct()
  8.     {
  9.         $this->_acl = new Zend_Acl();
  10.         $this->_initialize();
  11.     }
  12.  
  13.     protected function _initialize()
  14.     {
  15.         $this->_setupRoles();
  16.         $this->_setupResources();
  17.         $this->_setupPrivileges();
  18.         $this->_saveAcl();
  19.     }
  20.  
  21.     protected function _setupRoles()
  22.     {
  23.         $this->_acl->addRole( new Zend_Acl_Role('guest') );
  24.         $this->_acl->addRole( new Zend_Acl_Role('assistant') );
  25.         $this->_acl->addRole( new Zend_Acl_Role('provider'), 'assistant' );
  26.         $this->_acl->addRole( new Zend_Acl_Role('admin') );
  27.     }
  28.  
  29.     protected function _setupResources()
  30.     {
  31.         $this->_acl->addResource( new Zend_Acl_Resource('auth') );
  32.         $this->_acl->addResource( new Zend_Acl_Resource('error') );
  33.         $this->_acl->addResource( new Zend_Acl_Resource('provider_manager') );
  34.         $this->_acl->addResource( new Zend_Acl_Resource('users_manager') );
  35.         $this->_acl->addResource( new Zend_Acl_Resource('assistant_manager') );
  36.         $this->_acl->addResource( new Zend_Acl_Resource('tag_manager') );
  37.         $this->_acl->addResource( new Zend_Acl_Resource('positioning_manager') );
  38.         $this->_acl->addResource( new Zend_Acl_Resource('meet_budget') );
  39.     }
  40.  
  41.     protected function _setupPrivileges()
  42.     {
  43.         // guest
  44.  
  45.         $this->_acl->allow( 'guest', 'auth', array('index', 'login') )
  46.             ->allow('guest', 'error', array('error', 'forbidden') );
  47.  
  48.         // assistant
  49.  
  50.         $this->_acl->allow( 'assistant', 'auth', array('login', 'assistant_manager') )
  51.              ->allow( 'assistant', 'error', array( 'error', 'forbidden' ) )
  52.              ->allow( 'assistant', 'assistant_manager', array('editar') )
  53.              ->allow( 'assistant', 'meet_budget', array('responder') );
  54.  
  55.         // provider
  56.  
  57.         $this->_acl->allow( 'provider', 'auth', array('login') )
  58.              ->allow( 'provider', 'error', array( 'error', 'forbidden' ) )
  59.              ->allow( 'provider', 'assistant_manager', array('adicionar', 'editar', 'remover') )
  60.              ->allow( 'provider', 'provider_manager', array('adicionar', 'editar', 'remover') )
  61.              ->allow( 'provider', 'tag_manager', array('adicionar', 'editar', 'remover') )
  62.              ->allow( 'provider', 'positioning_manager', array('editar', 'remover') )
  63.              ->allow( 'provider', 'meet_budget', array('responder', 'remover') );
  64.  
  65.         // administrator
  66.  
  67.         $this->_acl->allow( 'admin', 'auth', array('login') )
  68.              ->allow( 'admin', 'error', array('error', 'forbidden') )
  69.              ->allow( 'admin', 'users_manager', array('adicionar', 'editar', 'remover') );
  70.     }
  71.  
  72.     protected function _saveAcl()
  73.     {
  74.         $registry = Zend_Registry::getInstance();
  75.         $registry->set('acl', $this->_acl );
  76.     }
  77. }
Add Comment
Please, Sign In to add comment