Example #1
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $auth = Zend_Auth::getInstance();
     $publicPages = array();
     $publicPages['controllers'] = array('login');
     $publicPages['actions'] = array();
     $controllerName = $request->getControllerName();
     if ($auth->hasIdentity() || in_array($controllerName, $publicPages['controllers'])) {
         return true;
     }
     throw new WebVista_App_AuthException('You must be authenticated to access the system.');
     $roleId = $auth->getIdentity()->roleId;
     $acl = WebVista_Acl::getInstance();
     if (!$acl->hasRole($roleId)) {
         $error = "Sorry, the requested user role '" . $roleId . "' does not exist";
     }
     if (!$acl->has($request->getModuleName() . '_' . $request->getControllerName())) {
         $error = "Sorry, the requested controller '" . $request->getControllerName() . "' does not exist as an ACL resource";
     }
     if (!$acl->isAllowed($roleId, $request->getModuleName() . '_' . $request->getControllerName(), $request->getActionName())) {
         $error = "Sorry, the page you requested does not exist or you do not have access";
     }
     if (isset($error)) {
         throw new WebVista_App_AuthException('You must be authenticated to access the system.');
     }
 }
Example #2
0
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
         self::$_instance->_initialize();
     }
     return self::$_instance;
 }
Example #3
0
 public function reloadPermissionsAction()
 {
     $acl = WebVista_Acl::getInstance();
     // populate acl from db
     $acl->populate();
     // save to memcache
     $this->_memcache->set('acl', $acl);
     Zend_Registry::set('acl', $acl);
     $items = $acl->getLists();
     $this->_memcache->set($this->_aclMemKey, $items);
     ACLAPI::saveACLItems($items);
     $data = array();
     $data['msg'] = __('Permissions reload successfully.');
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
Example #4
0
 protected function _setupAcl()
 {
     //$aclBuilder = new WebVista_AclBuilder();
     $memcache = Zend_Registry::get('memcache');
     $key = 'acl';
     $acl = $memcache->get($key);
     if ($acl === false) {
         $acl = WebVista_Acl::getInstance();
         // populate acl from db
         $acl->populate();
         // save to memcache
         $memcache->set($key, $acl);
     }
     Zend_Registry::set('acl', $acl);
     return $this;
 }
Example #5
0
 private function _setUpACL()
 {
     $memcache = Zend_Registry::get('memcache');
     $key = 'acl';
     $acl = $memcache->get($key);
     if ($acl === false) {
         $acl = WebVista_Acl::getInstance();
         // populate acl from db
         $acl->populate();
         // save to memcache
         $memcache->set($key, $acl);
     }
     Zend_Registry::set('acl', $acl);
 }