public function isAllowed($privilege)
 {
     $id = $this->_session->getSessionId();
     if (!is_null($id)) {
         $user = $this->_userRepo->get($id);
         if (!is_null($user)) {
             if ($this->_acl->isAllowed($user->getRole(), $this->_resource, $privilege)) {
                 return true;
             } else {
                 $this->redirect('home/notprivileged?resource=' . $this->_resource . '&privilege=' . $privilege . '&role=' . $user->getRole());
             }
         }
     }
     $this->login();
 }
Exemple #2
0
 public function __construct()
 {
     $this->addRole(new Zend_Acl_Role(self::GUEST));
     $this->add(new Zend_Acl_Resource('admin::error::error'));
     $this->add(new Zend_Acl_Resource('admin::index::error404'));
     $this->add(new Zend_Acl_Resource('admin::index::index'));
     $this->add(new Zend_Acl_Resource('admin::index::login'));
     $this->add(new Zend_Acl_Resource('admin::index::logout'));
     $this->add(new Zend_Acl_Resource('landing::*'));
     $this->add(new Zend_Acl_Resource('office::*'));
     $this->add(new Zend_Acl_Resource('service::*'));
     $this->add(new Zend_Acl_Resource('challenge::*'));
     $this->add(new Zend_Acl_Resource('admin-challenge::*'));
     $this->allow(self::GUEST, 'admin::error::error');
     $this->allow(self::GUEST, 'admin::index::error404');
     $this->allow(self::GUEST, 'admin::index::index');
     $this->allow(self::GUEST, 'admin::index::login');
     $this->allow(self::GUEST, 'admin::index::logout');
     $this->allow(self::GUEST, 'landing::*');
     $this->allow(self::GUEST, 'office::*');
     $this->allow(self::GUEST, 'service::*');
     $this->allow(self::GUEST, 'challenge::*');
     $this->allow(self::GUEST, 'admin-challenge::*');
     $modelAcl = new Application_Model_Acl();
     $listAcl = $modelAcl->getListResources();
     foreach ($listAcl as $resource) {
         try {
             if (!$this->has($resource)) {
                 $this->add(new Zend_Acl_Resource($resource));
             }
         } catch (Exception $ex) {
         }
     }
     $modelRole = new Application_Model_Role();
     $roles = $modelRole->getAllRoles();
     foreach ($roles as $item) {
         try {
             $this->addRole(new Zend_Acl_Role($item['desrol']), self::GUEST);
             $aclsRole = $modelAcl->getAclByRole($item['idrol']);
             foreach ($aclsRole as $permission) {
                 $this->allow($item['desrol'], $permission);
             }
         } catch (Exception $ex) {
         }
     }
     //  $this->add(new Zend_Acl_Resource('admin::tipo-antecedentes'));
     //PERMISOS
 }
Exemple #3
0
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemple #4
0
 public function __construct()
 {
     $this->addRole(new Zend_Acl_Role(self::GUEST));
     $this->add(new Zend_Acl_Resource('admin::error::error-privilegio'));
     $this->add(new Zend_Acl_Resource('admin::index::error404'));
     $this->add(new Zend_Acl_Resource('admin::index::index'));
     $this->add(new Zend_Acl_Resource('admin::index::login'));
     $this->add(new Zend_Acl_Resource('admin::index::logout'));
     $this->add(new Zend_Acl_Resource('admin::dashboard::index'));
     $this->add(new Zend_Acl_Resource('admin::index::*'));
     $this->add(new Zend_Acl_Resource('preview::*'));
     $this->add(new Zend_Acl_Resource('service::server::soap'));
     $this->allow(self::GUEST, 'admin::error::error-privilegio');
     $this->allow(self::GUEST, 'admin::index::error404');
     $this->allow(self::GUEST, 'admin::index::index');
     $this->allow(self::GUEST, 'admin::index::login');
     $this->allow(self::GUEST, 'admin::index::logout');
     $this->allow(self::GUEST, 'admin::dashboard::index');
     $this->allow(self::GUEST, 'admin::index::*');
     $this->allow(self::GUEST, 'preview::*');
     $this->allow(self::GUEST, 'service::server::soap');
     $modelAcl = new Application_Model_Acl();
     $listAcl = $modelAcl->getListResources();
     foreach ($listAcl as $resource) {
         try {
             if (!$this->has($resource)) {
                 $this->add(new Zend_Acl_Resource($resource));
             }
         } catch (Exception $ex) {
         }
     }
     $modelRole = new Application_Model_Role();
     $roles = $modelRole->getAllRoles();
     foreach ($roles as $item) {
         try {
             $this->addRole(new Zend_Acl_Role($item['name']), self::GUEST);
             $aclsRole = $modelAcl->getAclByRole($item['idrol']);
             foreach ($aclsRole as $permission) {
                 $this->allow($item['name'], $permission);
             }
         } catch (Exception $ex) {
             echo $ex->getMessage();
             exit;
         }
     }
 }
Exemple #5
0
 function permisos()
 {
     $auth = Zend_Auth::getInstance();
     $controller = $this->_request->getControllerName();
     if ($auth->hasIdentity()) {
         $user = $auth->getIdentity();
         $modelAcl = new Application_Model_Acl();
         $aclsRole = $modelAcl->getAclByRole($user->idrol);
         foreach ($aclsRole as $permission) {
             $actions[] = explode('::', $permission);
         }
         $this->view->menu = $this->getMenuAdmin($actions);
     } else {
         if ($controller != 'index') {
             $this->_redirect('/');
         }
     }
 }