public function preDispatch(Zend_Controller_Request_Abstract $request) { $auth = Zend_Auth::getInstance(); $roles = array(Core_Acl::GUEST); if ($auth->hasIdentity()) { $admin = 'admin'; if ($admin == 'admin') { $modelRol = new Application_Model_Role(); $roles = $modelRol->getRolesByUser($auth->getIdentity()->iduser); if (count($roles) == 0) { $roles = array(Core_Acl::GUEST); } } } $this->setAcl(Zend_Registry::get('Zend_Acl')); $request = $this->getRequest(); //Check if the request is valid and controller an action exists. If not redirects to an error page. if (!$this->isValidResource($request)) { if (!$auth->hasIdentity()) { $this->getResponse()->setRedirect('/'); return; } $request->setControllerName('error'); $request->setActionName('error'); throw new Exception("La ruta solicitada no existe."); return; } $continue = false; foreach ($roles as $rol) { $this->setRole($rol); //Check if user is allowed to acces the url and redirect if needed if ($this->hasAccessUrl($request)) { $continue = true; } } if (!$continue) { if (!$auth->hasIdentity()) { $this->getResponse()->setRedirect('/'); return; } $request->setControllerName('error'); $request->setActionName('error'); header("Location: /admin/error/error-privilegio"); exit; // $this->_redirect('/admin/error/error-privilegio'); // throw new Exception("Acceso denegado para el usuario."); // return; } }