コード例 #1
0
 /**
  * gotoRoute() is an alias for setGotoRoute()
  */
 public function testGotoRoute()
 {
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $route = new Zend_Controller_Router_Route('blog/archive/:id', array('controller' => 'blog', 'action' => 'view', 'id' => false), array('id' => '\\d+'));
     $router->addRoute('blogArchive', $route);
     $this->redirector->gotoRoute(array('id' => 281), 'blogArchive');
     $this->assertEquals('/blog/archive/281', $this->redirector->getRedirectUrl());
 }
コード例 #2
0
ファイル: Security.php プロジェクト: josmel/adminwap
 public function preDispatchDisabled()
 {
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         $r = $this->getRequest();
         $current = $r->getModuleName() . '.' . $r->getControllerName() . '.' . $r->getActionName();
         if (!in_array($current, $this->allowed)) {
             $r = new Zend_Controller_Action_Helper_Redirector();
             $r->gotoRoute(array(), $this->loginRoute, true);
         }
     }
     parent::preDispatch();
 }
コード例 #3
0
ファイル: Acl.php プロジェクト: komik966/recruitment
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if (Zend_Controller_Front::getInstance()->getDispatcher()->isDispatchable($request)) {
         //Retrieve acl
         $frontendOptions = array('lifetime' => null, 'automatic_serialization' => true);
         $backendOptions = array('cache_dir' => APPLICATION_PATH . '/../cache/');
         $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
         if ($aclFromCache = $cache->load('acl')) {
             $acl = $aclFromCache;
         } else {
             $acl = $this->_buildAcl();
             $cache->save($acl, 'acl');
         }
         //Set acl to registry for menus
         //Zend_Registry::set('gfiAcl', $acl);
         $redirector = new Zend_Controller_Action_Helper_Redirector();
         //Detect role id
         $roleId = My_Acl::detectRoleId();
         //Get resources parts names
         if ($request->getModuleName()) {
             $moduleName = $request->getModuleName();
         } else {
             $moduleName = 'default';
         }
         $controllerName = $request->getControllerName();
         $actionName = $request->getActionName();
         //Redirect logged in user from login and reset password forms
         if ($roleId !== My_Acl::GUEST_ROLE_Id && ($moduleName === 'Users' && $controllerName === 'auth' && $actionName === 'login' || $moduleName === 'Users' && $controllerName === 'auth' && $actionName === 'register')) {
             $redirector->gotoRoute(array(), 'home');
         }
         //Redirect not allowed
         if (!$acl->canAccess($roleId, $moduleName, $controllerName, $actionName)) {
             $request->setModuleName('Users');
             $request->setControllerName('auth');
             $request->setActionName('login');
             $request->setParam('accessDenied', true);
         }
     }
 }