コード例 #1
0
ファイル: CheckAuth.php プロジェクト: psoas/ch3-dev-preview
 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.');
     }
 }
コード例 #2
0
ファイル: Acl.php プロジェクト: dragonlet/clearhealth
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
         self::$_instance->_initialize();
     }
     return self::$_instance;
 }
コード例 #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);
 }
コード例 #4
0
ファイル: App.php プロジェクト: psoas/ch3-dev-preview
 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;
 }
コード例 #5
0
ファイル: TestCase.php プロジェクト: dragonlet/clearhealth
 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);
 }