本文整理汇总了PHP中Zend_Controller_Request_Abstract::setActionName方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Abstract::setActionName方法的具体用法?PHP Zend_Controller_Request_Abstract::setActionName怎么用?PHP Zend_Controller_Request_Abstract::setActionName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Abstract
的用法示例。
在下文中一共展示了Zend_Controller_Request_Abstract::setActionName方法的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');
}
}
示例2: 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');
}
}
}
示例3: 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;
}
}
示例4: preDispatch
/**
* checks whether a user needs a login and is loggedin
* otherwise redirect to login page
*
* @return void
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
// allways allow silent update (for easy cronjob)
if ($request->getControllerName() == 'update' && $request->getActionName() == 'silent') {
return;
}
// show login
if ($request->getParam('login', false) !== false) {
$request->setControllerName('index');
$request->setActionName('login');
return;
}
// logout?
if ($request->getParam('logout', false) !== false) {
Zend_Registry::get('session')->__unset('authenticated');
$request->setControllerName('index');
$request->setActionName('login');
return;
}
// disallow readonly mode if user has option public not set
if (Zend_Registry::get('session')->authenticated === 'readonly' && Zend_Registry::get('session')->public != 1) {
Zend_Registry::get('session')->authenticated = false;
}
// check whether user loggedin or public access allowed
if (Zend_Registry::get('session')->authenticated !== true && Zend_Registry::get('session')->authenticated !== 'readonly') {
// no login required?
$users = new application_models_users();
if (!$users->getUsername()) {
Zend_Registry::get('session')->authenticated = true;
// public access allowed? start public mode
} elseif (Zend_Registry::get('session')->public == 1) {
Zend_Registry::get('session')->authenticated = 'readonly';
// unallowed access -> show login window
} else {
$request->setControllerName('index');
$request->setActionName('login');
return;
}
}
// load default values 4 readonly mode
if (Zend_Registry::get('session')->authenticated === 'readonly') {
$priorityStart = Zend_Registry::get('session')->priorityStart;
$priorityEnd = Zend_Registry::get('session')->priorityEnd;
// reset session with default config from config.ini
Zend_Registry::get('bootstrap')->resetSession(false);
// set priority slider
Zend_Registry::get('session')->currentPriorityStart = $priorityStart;
Zend_Registry::get('session')->currentPriorityEnd = $priorityEnd;
Zend_Registry::get('session')->priorityStart = $priorityStart;
Zend_Registry::get('session')->priorityEnd = $priorityEnd;
}
// don't allow any changings in readonly mode
if (Zend_Registry::get('session')->authenticated !== true) {
if ($request->getControllerName() != 'error' && $request->getControllerName() != 'index' && $request->getControllerName() != 'patch' && !($request->getControllerName() == 'item' && $request->getActionName() == 'list') && !($request->getControllerName() == 'item' && $request->getActionName() == 'listmore') && !($request->getControllerName() == 'update' && $request->getActionName() == 'silent')) {
die('access denied');
}
}
}
示例5: 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);
}
}
示例6: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
if (PHP_SAPI == 'cli') {
return;
}
$acl = new Zend_Acl();
// add the roles
$acl->addRole(new Zend_Acl_Role('guest'));
$acl->addRole(new Zend_Acl_Role('user'), 'guest');
$acl->addRole(new Zend_Acl_Role('admin'), 'user');
// add the resources
$acl->addResource(new Zend_Acl_Resource('index'));
$acl->addResource(new Zend_Acl_Resource('error'));
$acl->addResource(new Zend_Acl_Resource('user'));
$acl->addResource(new Zend_Acl_Resource('profile'));
$acl->addResource(new Zend_Acl_Resource('post'));
$acl->addResource(new Zend_Acl_Resource('*'));
// set up the access rules
$acl->allow(null, array('index', 'error'));
// a guest can only sign up content and login
$acl->allow('guest', 'user', array('login', 'register', 'unique', 'search'));
// user
$acl->allow('user', 'user', array('edit', 'logout'));
$acl->allow('user', 'profile', array('edit', 'profile', 'getxml', 'viewxml', 'more'));
$acl->allow('user', 'post', array('new', 'postxml', 'getposts', 'like', 'share', 'comment', 'home', 'edit', 'allcomment', 'notification', 'report'));
$acl->allow('admin', null);
// Fetch the current user
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$id = get_user_id();
$role = "user";
if ($id == 2) {
$role = "admin";
}
} else {
$role = 'guest';
}
// Authorization
$controller = $request->controller;
$action = $request->action;
try {
if (!$acl->isAllowed($role, $controller, $action)) {
if ($role == 'guest') {
$redirector = new Zend_Controller_Action_Helper_Redirector();
$redirector->gotoSimple('login', 'user');
} else {
// User with role $role is not authorized for $controller/$action"
$request->setControllerName('error');
$request->setActionName('notauthorized');
}
}
} catch (Exception $e) {
$request->setControllerName('error');
$request->setActionName('notfound');
}
}
示例7: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
// set up acl
$acl = new Zend_Acl();
// add the roles
$acl->addRole(new Zend_Acl_Role('guest'));
$acl->addRole(new Zend_Acl_Role('consumer'), 'guest');
$acl->addRole(new Zend_Acl_Role('administrator'), 'consumer');
$acl->addRole(new Zend_Acl_Role('client'));
// add the resources
$acl->add(new Zend_Acl_Resource('index'));
$acl->add(new Zend_Acl_Resource('error'));
$acl->add(new Zend_Acl_Resource('admin'));
$acl->add(new Zend_Acl_Resource('campaign'));
$acl->add(new Zend_Acl_Resource('campaigninvitation'));
$acl->add(new Zend_Acl_Resource('campaignparticipation'));
$acl->add(new Zend_Acl_Resource('client'));
$acl->add(new Zend_Acl_Resource('consumer'));
$acl->add(new Zend_Acl_Resource('conversation'));
$acl->add(new Zend_Acl_Resource('dashboard'));
$acl->add(new Zend_Acl_Resource('forgetpassword'));
$acl->add(new Zend_Acl_Resource('gift'));
$acl->add(new Zend_Acl_Resource('history'));
$acl->add(new Zend_Acl_Resource('home'));
$acl->add(new Zend_Acl_Resource('login'));
// set up the access rules
$acl->allow(null, array('index', 'error'));
// a guest can only login
$acl->allow('guest', 'index', array('index', 'loginfailed'));
$acl->allow('guest', 'login', array('login'));
$acl->allow('guest', 'forgetpassword', array('index', 'sendsms', 'sendemail'));
// consumer
$acl->allow('consumer', 'gift', array('list', 'addtocart', 'cart', 'listorder'));
// administrators can do anything
$acl->allow('administrator', null);
// fetch the current user
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$authNamespace = new Zend_Session_Namespace('Zend_Auth');
$role = $authNamespace->role;
} else {
$role = 'guest';
}
$controller = $request->controller;
$action = $request->action;
if (!$acl->isAllowed($role, $controller, $action)) {
if ($role == 'guest') {
$request->setControllerName('index');
$request->setActionName('index');
} else {
$request->setControllerName('error');
$request->setActionName('noauth');
}
}
}
示例8: _forwardLogin
protected function _forwardLogin(Zend_Controller_Request_Abstract $request)
{
$request->setModuleName('kwf_controller_action_user');
$request->setControllerName('login');
$request->setDispatched(false);
if (substr($request->getActionName(), 0, 4) == 'json') {
$request->setActionName('json-login');
} else {
$params = array('location' => $request->getBaseUrl() . '/' . ltrim($request->getPathInfo(), '/'));
$request->setParams($params);
$request->setActionName('index');
}
}
示例9: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
// set up acl
$acl = new Zend_Acl();
// add the roles
$acl->addRole(new Zend_Acl_Role('guest'));
$acl->addRole(new Zend_Acl_Role('user'), 'guest');
$acl->addRole(new Zend_Acl_Role('administrator'), 'user');
// add the resources
$acl->add(new Zend_Acl_Resource('index'));
$acl->add(new Zend_Acl_Resource('error'));
$acl->add(new Zend_Acl_Resource('page'));
$acl->add(new Zend_Acl_Resource('menu'));
$acl->add(new Zend_Acl_Resource('menuitem'));
$acl->add(new Zend_Acl_Resource('user'));
$acl->add(new Zend_Acl_Resource('search'));
$acl->add(new Zend_Acl_Resource('feed'));
// set up the access rules
$acl->allow(null, array('index', 'error'));
// a guest can only read content and login
$acl->allow('guest', 'page', array('index', 'open'));
$acl->allow('guest', 'menu', array('render'));
$acl->allow('guest', 'user', array('login'));
$acl->allow('guest', 'search', array('index', 'search'));
$acl->allow('guest', 'feed');
// cms users can also work with content
$acl->allow('user', 'page', array('list', 'create', 'edit', 'delete'));
// administrators can do anything
$acl->allow('administrator', null);
// fetch the current user
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$identity = $auth->getIdentity();
$role = strtolower($identity->role);
} else {
$role = 'guest';
}
$controller = $request->controller;
$action = $request->action;
if (!$acl->isAllowed($role, $controller, $action)) {
if ($role == 'guest') {
$request->setControllerName('user');
$request->setActionName('login');
} else {
$request->setControllerName('error');
$request->setActionName('noauth');
}
}
}
示例10: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
if ($this->_auth->hasIdentity()) {
$role = $this->_auth->getIdentity()->getUser()->role;
} else {
$role = 'guest';
}
$controller = $request->controller;
$action = $request->action;
$module = $request->module;
$resource = $controller;
if (!$this->_acl->has($resource)) {
$resource = null;
}
if (!$this->_acl->isAllowed($role, $resource, $action)) {
if (!$this->_auth->hasIdentity()) {
$module = self::NO_AUTH_MODULE;
$controller = self::NO_AUTH_CONTROLLER;
$action = self::NO_AUTH_ACTION;
} else {
$module = self::NO_ACL_MODULE;
$controller = self::NO_ACL_CONTROLLER;
$action = self::NO_ACL_ACTION;
}
}
$request->setModuleName($module);
$request->setControllerName($controller);
$request->setActionName($action);
}
示例11: preDispatch
/**
* this function routes all requests that come in to the default module to the index controller / index action
*
* @param zend_controller_request $request
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
if ($request->module == 'public' && $request->controller != 'plugin') {
$request->setControllerName('index');
$request->setActionName('index');
}
}
示例12: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
if ('company' == $request->getControllerName()) {
$tsn = $request->tsn ? $request->tsn : $_COOKIE['tsn'];
if ($tsn) {
$token = Token::create($tsn);
$token->update_sync_time();
} else {
$token = Token::create_abstract('123');
}
if ($token->is_logined() == true) {
if ($token->is_expire()) {
$token->destroy();
include_once LIB_PATH . '/view_helper/BuildUrl.php';
$url_builder = new Zend_View_Helper_BuildUrl();
$referer = SearchFilter::slashes($url_builder->buildUrl($request->getActionName(), $request->getControllerName(), $request->getModuleName()));
$login_url = $url_builder->buildUrl('login', 'auth', 'index', array('redirect' => $referer));
$redirector = new Zend_Controller_Action_Helper_Redirector();
$redirector->gotoUrl($login_url);
return;
}
$token->register();
} else {
if ('auth' != $request->getActionName()) {
$token->destroy();
$request->setModuleName('index');
$request->setControllerName('auth');
$request->setActionName('login');
}
}
}
}
示例13: preDispatch
/**
* ACL Access Check in preDispatch method
*
* @param Zend_Controller_Request_Abstract $request
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
if (!$this->_auth->hasIdentity()) {
$request->setModuleName('admin');
$request->setControllerName('auth');
$request->setActionName('login');
return;
}
// What is user(role) loged in
$role = $this->_auth->getIdentity()->role_id;
// What is the current Resource
$resource_table = new Admin_Model_Resources();
$resource_name = $request->getModuleName() . ':' . $request->getControllerName();
$resource = $resource_table->getByName(strtolower($resource_name));
$resource_id = isset($resource->id) ? $resource->id : null;
// Get current privilage ( == action )
$action = strtolower($request->getActionName());
if (!$this->_acl->hasRole($role)) {
throw new Exception("Role not found in Database.", 404);
} elseif (!$this->_acl->hasResource($resource_id)) {
throw new Exception("Resource not found in Database.", 404);
} elseif (!$this->_acl->isAllowed($role, $resource_id, $action)) {
throw new Exception("You dont have permission for this page.", 404);
}
}
示例14: route
public function route(Zend_Controller_Request_Abstract $dispatcher)
{
try {
$getopt = new Zend_Console_Getopt(array('verbose|v' => 'Print verbose output', 'file|f=s' => 'File to upload'));
$getopt->parse;
$arguments = $getopt->getRemainingArgs();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
if ($arguments) {
$command = array_shift($arguments);
$action = array_shift($arguments);
if (!preg_match('~\\W~', $command)) {
$dispatcher->setControllerName($command);
$dispatcher->setActionName($action);
$dispatcher->setParams($arguments);
if (isset($getopt->v)) {
$dispatcher->setParam('verbose', true);
}
if (isset($getopt->f)) {
$dispatcher->setParam('file', $getopt->f);
}
return $dispatcher;
}
echo "Invalid command.\n", exit;
}
echo "No command given.\n", exit;
}
示例15: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$auth = Zend_Auth::getInstance();
$acl = Zend_Registry::get('acl');
//перевірка на ролі
if ($auth->hasIdentity()) {
$role = $auth->getIdentity()->role;
} else {
$role = 'guest';
}
//якщо ролі не існує
if (!$acl->hasRole($role)) {
$role = 'guest';
}
$controller = $request->controller;
$action = $request->action;
//якщо контролера не існує
if (!$acl->has($controller)) {
$controller = null;
}
//якщо юзер не має доступу
if (!$acl->isAllowed($role, $controller, $action)) {
$request->setControllerName($this->_controller['controller']);
$request->setActionName($this->_controller['action']);
}
}