当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Controller_Request_Abstract::setModuleName方法代码示例

本文整理汇总了PHP中Zend_Controller_Request_Abstract::setModuleName方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Abstract::setModuleName方法的具体用法?PHP Zend_Controller_Request_Abstract::setModuleName怎么用?PHP Zend_Controller_Request_Abstract::setModuleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Controller_Request_Abstract的用法示例。


在下文中一共展示了Zend_Controller_Request_Abstract::setModuleName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preDispatch

 /**
  * Called before an action is dispatched by Zend_Controller_Dispatcher.
  *
  * This callback allows for proxy or filter behavior.  By altering the
  * request and resetting its dispatched flag (via
  * {@link Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
  * the current action may be skipped.
  *
  * @param  Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $oAuth = Zend_Auth::getInstance();
     $oAcl = $this->getAcl();
     // Default role
     $sRole = 'all';
     if ($oAuth->hasIdentity()) {
         $oIdentity = $oAuth->getIdentity();
         $sRole = isset($oIdentity->sRole) ? $oIdentity->sRole : 'identify';
     }
     $sModule = $request->module;
     $sController = $request->controller;
     $sAction = $request->action;
     $sResource = $sController . ':' . $sAction;
     if ($oAcl->has($sResource)) {
         if (!$oAcl->isAllowed('all', $sResource)) {
             // Access is not allowed
             if (!$oAcl->isAllowed($sRole, $sResource)) {
                 //$flashMessenger = new Zend_Controller_Action_Helper_FlashMessenger();
                 //$flashMessenger->addMessage('Acesso negado');
                 $request->setModuleName('default');
                 $request->setControllerName('index');
                 $request->setActionName('index');
             }
         }
     } else {
         $flashMessenger = new Zend_Controller_Action_Helper_FlashMessenger();
         $flashMessenger->addMessage('Acesso negado');
         $request->setModuleName('default');
         $request->setControllerName('index');
         $request->setActionName('index');
     }
 }
开发者ID:julioprotzek,项目名称:eventos,代码行数:44,代码来源:Acl.php

示例2: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $table = $request->getParam('table');
     $acl = $this->_getAcl();
     $identity = Zend_Auth::getInstance()->getIdentity();
     $role = 'Todos';
     $resource = strtolower($request->getModuleName());
     $controller = $request->getControllerName();
     $privilege = $controller . self::RESOURCE_SEPARATOR . $request->getActionName();
     if (isset($identity->role)) {
         $role = $identity->role;
     }
     if (!$acl->isAllowed($role, $resource, $privilege)) {
         if ($controller == 'scaffold' && $table) {
             $privilege = $table . self::RESOURCE_SEPARATOR . $request->getActionName();
             if ($acl->isAllowed($role, $resource, $privilege)) {
                 return true;
             }
         }
         if (isset($identity->role)) {
             $request->setModuleName('default')->setControllerName('error')->setActionName('access');
             return false;
         }
         $request->setModuleName('auth')->setControllerName('index')->setActionName('index');
     }
 }
开发者ID:abdala,项目名称:la,代码行数:26,代码来源:Acl.php

示例3: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $module = $request->getModuleName();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $resource = "{$module}:{$controller}";
     $privilege = $action;
     // If not dispatchable, no need to check the ACL
     $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher();
     if (!$dispatcher->isDispatchable($this->getRequest())) {
         return;
     }
     // If the resource does not exist, revert to the root
     if (!$this->_acl->has($resource)) {
         $resource = 'root';
     }
     if (!$this->_acl->isAllowed($this->_role, $resource, $action)) {
         // If access is not allowed and we are a guest, we forward to the auth controller
         if ($this->_role == 'guest' && Zend_Registry::isRegistered('uri')) {
             $request->setModuleName('admin')->setControllerName('auth')->setActionName('index')->setParams(array('target' => Zend_Registry::get('uri')))->setDispatched(false);
         } else {
             // Otherwise we forward to the error controller
             $request->setModuleName('public')->setControllerName('error')->setActionName('denied')->setParams(array('message' => "Access denied for {$this->_role} to resource {$resource} with privilege {$privilege}."))->setDispatched(false);
         }
     }
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:26,代码来源:Acl.php

示例4: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $aNamespace = new Zend_Session_Namespace('userNs');
     if ($aNamespace->perfil != "") {
         $role = $aNamespace->perfil;
     } else {
         $role = 'guest';
     }
     $controller = strtolower($request->getControllerName());
     $action = strtolower($request->getActionName());
     $module = strtolower($request->getModuleName());
     $resource = $module . ':' . str_replace('-', '', $controller) . '.' . $action;
     //        $resource   = $module.':'.$controller.'.'.$action;
     if (!$this->_acl->isAllowed($role, $resource, $action)) {
         if ($this->_auth->hasIdentity()) {
             $request->setModuleName('default');
             $request->setControllerName('error');
             $request->setActionName('nopermission');
         } else {
             $this->_flashMessenger->addMessage(array('status' => 'error', 'message' => 'Favor logar novamente.'));
             $request->setModuleName('default');
             $request->setControllerName('login');
             $request->setActionName('index');
         }
     }
 }
开发者ID:marcelocaixeta,项目名称:zf1,代码行数:26,代码来源:Acl.php

示例5: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     /**
      * Pegando o helper Redirector
      */
     $this->_redirect = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
     /*
      * Instanciando as variáveis de sessão do zend_auth
      */
     $authNamespace = new Zend_Session_Namespace('Zend_Auth');
     /**
      * Copiando em variáves o modulo, controlle e action
      */
     $module = strtolower($request->getModuleName());
     $controller = strtolower($request->getControllerName());
     $action = strtolower($request->getActionName());
     /**
      * Se o usuário estiver autenticado
      */
     if (Zend_Auth::getInstance()->hasIdentity()) {
         if (isset($authNamespace->timeout) && time() > $authNamespace->timeout) {
             /**
              * limpa a identidade do usuário que está um longo período sem acessar o controller
              */
             $request->setModuleName('default');
             $request->setControllerName('login');
             $request->setActionName('logout');
             $authNamespace->erro = 'Sua sessão expirou, favor logar novamente';
         } else {
             /**
              *  Usuário está ativo - atualizamos o time da sessão.
              */
             $authNamespace->timeout = strtotime(self::$_ZEND_SESSION_NAMESPACE_EXPIRATION_SECONDS . " seconds");
             /**
              * Renovando o timeout das variáves de sessão
              */
             $namesspaces = Zend_Session::getIterator();
             $namesspacesArrayCopy = $namesspaces->getArrayCopy();
             foreach ($namesspacesArrayCopy as $namesspace) {
                 $namesspace_each = new Zend_Session_Namespace($namesspace);
                 //$namesspace_each->setExpirationSeconds(self::$_ZEND_SESSION_NAMESPACE_EXPIRATION_SECONDS);
                 $namesspace_each->timeout = strtotime(self::$_ZEND_SESSION_NAMESPACE_EXPIRATION_SECONDS . " seconds");
                 $temp = $namesspace_each->timeout;
             }
         }
     }
     /** Se o usuário não possuir identidade ou a identidade foi removida devido ao timeout,
      * redirecionamos ele para a tela de login.
      */
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         if (!($module == 'default' && $controller == 'login' && $action == 'index') && !($module == 'default' && $controller == 'login' && $action == 'ajaxbanco')) {
             $request->setModuleName('default');
             $request->setControllerName('login');
             $request->setActionName('index');
             $request->setParam('sessao', 'expirada');
         }
         return;
     }
 }
开发者ID:marcelocaixeta,项目名称:zf1,代码行数:59,代码来源:Timeout.php

示例6: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     try {
         $module = $request->getModuleName();
         if ($module == 'admin') {
             $moduleList = new Zend_Session_Namespace('moduleList');
             $userInfo = new Zend_Session_Namespace('userInfo');
             $module = $moduleList->module;
             $allowed_module = $userInfo->module_list;
             //generating all resources
             $acl = new Zend_Acl();
             //generating user permission
             $acl->addRole(new Zend_Acl_Role('admin'));
             $acl->addRole(new Zend_Acl_Role('anonymous'));
             $acl->add(new Zend_Acl_Resource('index'));
             $acl->add(new Zend_Acl_Resource('ajax'));
             $acl->allow('admin', 'index');
             $acl->allow('admin', 'ajax');
             if (!empty($module)) {
                 foreach ($module as $value) {
                     if (!$acl->has($value['controller'])) {
                         $acl->add(new Zend_Acl_Resource($value['controller']));
                     }
                     if (in_array($value['id'], $allowed_module)) {
                         if ($value['action'] != null) {
                             $acl->allow('admin', $value['controller'], $value['action']);
                         } else {
                             $acl->allow('admin', $value['controller']);
                         }
                     }
                 }
             }
             //allowing anonymous user to get into the login page
             $acl->allow('anonymous', 'index', 'index');
             $acl->allow('anonymous', 'index', 'login');
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $role = 'admin';
             } else {
                 $role = 'anonymous';
             }
             $controller = $request->controller;
             $action = $request->action;
             if (!$acl->isAllowed($role, $controller, $action)) {
                 $request->setModuleName('admin');
                 $request->setControllerName('error');
                 $request->setActionName('acl');
                 $request->setParam('type', 1);
             }
         }
     } catch (Zend_Acl_Exception $e) {
         $request->setModuleName('admin');
         $request->setControllerName('error');
         $request->setActionName('acl');
         $request->setParam('type', 2);
     }
 }
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:57,代码来源:AccessPlugin.php

示例7: preDispatch

 /**
  *(non-PHPdoc)
  *
  * @see Zend_Controller_Plugin_Abstract::preDispatch()
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     /**
      * Recupera a identidade do usuario logado
      *
      * @var Array
      */
     $role = $this->auth->getIdentity();
     /**
      * Recursos que se deseja acesso
      *
      * @var String
      */
     $resource = $this->getRequest()->getModuleName();
     /**
      * Ação permitida dentro de um resource
      *
      * @var String
      */
     $action = $this->getRequest()->getModuleName() != 'admin' && $this->getRequest()->getModuleName() != 'sac' ? null : $this->getRequest()->getControllerName();
     // Verificação condicional para os controllers e actions de upload
     if (!($request->getActionName() == 'upload' || $request->getControllerName() == 'upload')) {
         // Verifica se ha lixo na autenticacao
         if (!is_array($role)) {
             // Parametros
             $params = array();
             // Destroi qualquer instancia de autenticacao
             $this->auth->clearIdentity();
             // Altera a rota de destino
             $request->setModuleName('admin')->setControllerName('login')->setActionName('index');
             return;
         }
         // Verifica se o recurso existe e se o usuario logado tem acesso
         if (!$this->acl->has($resource) || !$this->acl->isAllowed($role['usuario'], $resource, $action)) {
             // Parametros
             $params = array();
             // Redireciona para o controller de login
             if ($role['usuario'] != 'visitante') {
                 $params['erro'] = 'Você não possui permissão de acesso a este recurso.';
                 $request->setModuleName('admin')->setControllerName('index')->setActionName('index')->setParams($params);
             } else {
                 if ($this->getRequest()->getModuleName() == "sac") {
                     $request->setModuleName('sac')->setControllerName('login')->setActionName('index')->setParams($params);
                 } else {
                     $request->setModuleName('admin')->setControllerName('login')->setActionName('index')->setParams($params);
                 }
             }
             return;
         }
     }
 }
开发者ID:vilmarsitio,项目名称:registrodeprecos,代码行数:56,代码来源:Autenticacao.php

示例8: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if (!in_array($request->getModuleName(), array('qg', 'painel'))) {
         return;
     }
     $controller = "";
     $action = "";
     $module = "";
     if (!$this->_auth->hasIdentity()) {
         $controller = $this->_notLoggedRoute['controller'];
         $action = $this->_notLoggedRoute['action'];
         $module = $request->getModuleName();
     } else {
         if (!$this->_isAuthorized($request->getModuleName(), $request->getControllerName(), $request->getActionName())) {
             $controller = $this->_forbiddenRoute['controller'];
             $action = $this->_forbiddenRoute['action'];
             $module = $request->getModuleName();
         } else {
             $controller = $request->getControllerName();
             $action = $request->getActionName();
             $module = $request->getModuleName();
         }
     }
     $request->setControllerName($controller);
     $request->setActionName($action);
     $request->setModuleName($module);
 }
开发者ID:mayconheerdt,项目名称:zfSkeleton,代码行数:27,代码来源:Auth.php

示例9: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if ($this->_auth->hasIdentity()) {
         $role = $this->_auth->role;
     } else {
         $role = 'guest';
     }
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $module = $request->getModuleName();
     if (!$this->_acl->has($module)) {
         $module = null;
     }
     if (!$this->acl->isAllowed($role, $module)) {
         if (!$this->auth->hasIdentity()) {
             $controller = $this->_noauth['controller'];
             $action = $this->_noauth['action'];
         } else {
             $controller = $this->_noacl['controller'];
             $action = $this->_noacl['action'];
         }
     }
     $request->setModuleName($module);
     $request->setControllerName($controller);
     $request->setActionName($action);
 }
开发者ID:pietka,项目名称:fedit,代码行数:26,代码来源:Auth.php

示例10: dispatchLoopStartup

 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         $request->setModuleName('User')->setControllerName('auth')->setActionName('login')->setDispatched(true);
     }
 }
开发者ID:rcomone,项目名称:bugtrack,代码行数:7,代码来源:Auth.php

示例11: route

 public function route(Zend_Controller_Request_Abstract $dispatcher)
 {
     $dispatcher->setModuleName('worker');
     $dispatcher->setControllerName('index');
     $dispatcher->setActionName('index');
     return $dispatcher;
 }
开发者ID:nguyenduong127,项目名称:Project-dll.vn-,代码行数:7,代码来源:Worker.php

示例12: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if ($this->_auth->hasIdentity()) {
         $cnf = Zend_Registry::get('cnf');
         $db = Zend_Db::factory($cnf->db);
         $select = $db->query("\n                SELECT\n                    ut.User_type AS UserType\n                FROM\n                    admin_users_types ut\n                WHERE\n                    ID=" . $this->_auth->getIdentity()->TypeID);
         $tp = $select->fetchAll();
         $role = $tp[0]['UserType'];
     } else {
         $role = "guest";
     }
     $module = $request->module;
     $controller = $request->controller;
     $action = $request->action;
     $resource = $request->module;
     //print "<pre>";var_dump($request);
     if ($this->_acl->has($resource)) {
         $resource = null;
     }
     if (!$this->_acl->isAllowed($role, $module, $controller, $action)) {
         list($module, $controller, $action) = !$this->_auth->hasIdentity() ? array_values($this->_noAuth) : array_values($this->_noAcl);
     }
     $request->setModuleName($module);
     $request->setControllerName($controller);
     $request->setActionName($action);
 }
开发者ID:albertobraschi,项目名称:zstarter,代码行数:26,代码来源:AuthControllerPlugin.php

示例13: route

 /**
  * @param Zend_Controller_Request_Abstract $request
  * @return Zend_Controller_Request_Abstract
  */
 public function route(Zend_Controller_Request_Abstract $request)
 {
     $this->_currentRequest = $request;
     $getOpt = new Zend_Console_Getopt(array());
     $arguments = $getOpt->getRemainingArgs();
     $module = 'index';
     $controller = 'index';
     $action = 'index';
     if ($arguments) {
         $module = array_shift($arguments);
         if ($arguments) {
             $controller = array_shift($arguments);
             if ($arguments) {
                 $action = array_shift($arguments);
                 $patternValidAction = '~^\\w+[\\-\\w\\d]+$~';
                 if (false == preg_match($patternValidAction, $action)) {
                     echo "Invalid action {$action}.\n", exit;
                 }
                 if ($arguments) {
                     foreach ($arguments as $arg) {
                         $parameter = explode('=', $arg, 2);
                         if (false == isset($parameter[1])) {
                             $parameter[1] = true;
                         }
                         $request->setParam($parameter[0], $parameter[1]);
                         unset($parameter);
                     }
                 }
             }
         }
     }
     $request->setModuleName($module)->setControllerName($controller)->setActionName($action);
     return $request;
 }
开发者ID:shahmaulik,项目名称:zfcore,代码行数:38,代码来源:Cli.php

示例14: preDispatch

 /**
  * 在消息派发之前,验证权限。
  * 
  * @see Zend_Controller_Request_Abstract::preDispatch()
  * @param Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if ($this->_request->getActionName() != Zend_Controller_Front::getInstance()->getDefaultAction() && $this->_acl->has($this->_resource()) && !$this->_acl->isAllowed($this->_role(), $this->_resource(), $this->_privileges())) {
         // 如果没有权限则跳转到相关的提示页面
         $request->setModuleName('index')->setControllerName('index')->setActionName('deny');
     }
 }
开发者ID:starflash,项目名称:ZtChart-ZF1-Example,代码行数:14,代码来源:Acl.php

示例15: _changeDispatch

 private function _changeDispatch(Zend_Controller_Request_Abstract &$request, Zend_Controller_Response_Abstract $response)
 {
     $module = $request->getParam($request->getModuleKey());
     $controller = $request->getParam($request->getControllerKey());
     $action = $request->getParam($request->getActionKey());
     $submodule = '';
     $subcontroller = '';
     $subaction = '';
     if ('admin' != $module) {
         $submodule = $module;
         $subcontroller = $controller ? $controller : 'index';
         $subaction = $action ? $action : 'index';
         $controller = 'index';
         $action = 'subroute';
         $module = 'default';
     } else {
         $submodule = $controller;
         $subcontroller = $action ? $action : 'index';
         //долно быть настроено в route
         //$subaction = ( $action ) ? $action : 'index';
         $controller = 'index';
         $action = 'subroute';
     }
     $request->setParam($request->getModuleKey(), $module);
     $request->setModuleName($module);
     $request->setParam($request->getControllerKey(), $controller);
     $request->setControllerName($controller);
     $request->setParam($request->getActionKey(), $action);
     $request->setActionName($action);
     $request->setParam('submodule', $submodule);
     $request->setParam('subcontroller', $subcontroller);
     $request->setParam('subaction', $subaction);
 }
开发者ID:Aktubius,项目名称:zendframeworkmodification,代码行数:33,代码来源:Dispatcher.php


注:本文中的Zend_Controller_Request_Abstract::setModuleName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。