本文整理汇总了PHP中Zend_Controller_Request_Abstract::getActionName方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Abstract::getActionName方法的具体用法?PHP Zend_Controller_Request_Abstract::getActionName怎么用?PHP Zend_Controller_Request_Abstract::getActionName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Abstract
的用法示例。
在下文中一共展示了Zend_Controller_Request_Abstract::getActionName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$this->_initAcl();
if ($this->_auth->hasIdentity()) {
$ident = $this->_auth->getIdentity();
$date = new Zend_Date();
$ident->last_login = $date->get(DATABASE_DATE_FORMAT);
$ident->save();
}
if ($request->getControllerName() != 'admin' && $request->getModuleName() != 'admin') {
return;
}
// if this is not admin skip the rest
if (!$this->_auth->hasIdentity() && !($request->getControllerName() == 'auth' && $request->getActionName() == 'login' && $request->getModuleName() == 'admin')) {
$redirect = new Zend_Controller_Action_Helper_Redirector();
$redirect->gotoSimple('login', 'auth', 'admin');
}
if ($request->getModuleName() == 'user' && $request->getControllerName() == 'admin' && $request->getActionName() == 'profile') {
return;
}
// the profile is a free resource
$resource = $request->getModuleName() . '_' . $request->getControllerName();
$hasResource = $this->_acl->has($resource);
if ($hasResource && !$this->_acl->isAllowed('fansubcms_user_custom_role_logged_in_user', $resource, $request->getActionName())) {
throw new FansubCMS_Exception_Denied('The user is not allowd to do this');
}
}
示例2: 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');
}
}
}
}
示例3: _checkSkipAcl
protected function _checkSkipAcl(Zend_Controller_Request_Abstract $request, $type)
{
// verificação de requisicao - Caso ajax, verifica se a action é delete, senao, SKIP nele.
if ($request->isXmlHttpRequest() && !in_array($request->getActionName(), $this->_arrAjaxNotSkip)) {
return TRUE;
}
$configs = Zend_Registry::get('configs');
$skip = $configs['security']['skip'][$type];
$result = FALSE;
$result = in_array($request->getActionName(), $skip);
foreach ($skip as $routers) {
$route = explode('/', $routers);
switch (count($route)) {
case 1:
// action
$result = in_array($request->getActionName(), $skip);
break;
case 2:
// controller/action
$result = in_array($request->getControllerName() . '/' . $request->getActionName(), $skip);
break;
case 3:
// module/controller/action
$result = in_array($request->getModuleName() . '/' . $request->getControllerName() . '/' . $request->getActionName(), $skip);
break;
}
if ($result) {
return TRUE;
}
}
return $result;
}
示例4: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$storage = new Zend_Auth_Storage_Session();
$data = $storage->read();
$role = $data['emprole'];
if ($role == 1) {
$role = 'admin';
}
$request->getModuleName();
$request->getControllerName();
$request->getActionName();
$module = $request->getModuleName();
$resource = $request->getControllerName();
$privilege = $request->getActionName();
$this->id_param = $request->getParam('id');
$allowed = false;
$acl = $this->_getAcl();
$moduleResource = "{$module}:{$resource}";
if ($resource == 'profile') {
$role = 'viewer';
}
if ($resource == 'services') {
$role = 'services';
}
if ($role != '') {
if ($acl->has($moduleResource)) {
$allowed = $acl->isAllowed($role, $moduleResource, $privilege);
}
if (!$allowed) {
$request->setControllerName('error');
$request->setActionName('error');
}
}
}
示例5: preDispatch
/**
* checks if actual role has access for this request
*
* @param \Zend_Controller_Request_Abstract $request
*/
public function preDispatch(\Zend_Controller_Request_Abstract $request)
{
$accessManager = AccessManager::singleton();
if ($this->isGroupCheckEnabled()) {
$resource = strtolower($request->getControllerName());
$privilege = strtolower($request->getActionName());
if (!$accessManager->isAllowed($resource, $privilege)) {
if ($accessManager->hasIdentityRoleGuest($accessManager->getIdentityAsArray(), true)) {
\Cms\ExceptionStack::addException(new \Cms\Exception(5));
} else {
\Cms\ExceptionStack::addException(new \Cms\Exception(4, __METHOD__, __LINE__, array('resource' => $resource, 'privilege' => $request->getActionName())));
}
}
}
/**
* Sind Fehler aufgetreten, so muss hier explizit auf den Error-Controller
* verwiesen werden.
* Da wir im preDespatch sind greift unsere normale Weiterleitung auf den
* Error-Controller bei nicht gefangenen Exception noch nicht.
*/
if (count(\Cms\ExceptionStack::getExceptions()) > 0) {
$request->setControllerName('Error');
$request->setActionName('error');
}
}
示例6: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$controller = "";
$action = "";
$module = "";
/* if($request->getControllerName() == "index" ){
$controller = $request->getControllerName();
$action = $request->getActionName();
$module = $request->getModuleName();
}
else if ( !$this->_auth->hasIdentity() ) {
}*/
if (!$this->_isAuthorized($request->getControllerName(), $request->getActionName())) {
if (!$this->_auth->hasIdentity()) {
if (!in_array($request->getControllerName(), $this->_moRedirect) && !Application_Model_Redirect::hasRequestUri()) {
Application_Model_Redirect::saveRequestUri("/" . $request->getControllerName() . "/" . $request->getActionName());
}
$controller = $this->_notLoggedRoute['controller'];
$action = $this->_notLoggedRoute['action'];
$module = $this->_notLoggedRoute['module'];
} else {
$controller = $this->_forbiddenRoute['controller'];
$action = $this->_forbiddenRoute['action'];
$module = $this->_forbiddenRoute['module'];
}
} else {
$controller = $request->getControllerName();
$action = $request->getActionName();
$module = $request->getModuleName();
}
$request->setControllerName($controller);
$request->setActionName($action);
$request->setModuleName($module);
}
示例7: 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');
}
}
示例8: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$loginController = 'authentication';
$loginAction = 'login';
$auth = Zend_Auth::getInstance();
// If user is not logged in and is not requesting login page
// - redirect to login page.
if (!$auth->hasIdentity() && $request->getControllerName() != $loginController && $request->getActionName() != $loginAction) {
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
$redirector->gotoSimpleAndExit($loginAction, $loginController);
}
// User is logged in or on login page.
if ($auth->hasIdentity()) {
// Is logged in
// Let's check the credential
$acl = new Tynex_Models_TynexAcl();
$identity = $auth->getIdentity();
// role is a column in the user table (database)
$isAllowed = $acl->isAllowed($identity->role, $request->getControllerName(), $request->getActionName());
if (!$isAllowed) {
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
$redirector->gotoUrlAndExit('/');
}
}
}
示例9: 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);
}
示例10: 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');
}
}
}
示例11: getModulesIdsByRequest
public static function getModulesIdsByRequest(Zend_Controller_Request_Abstract $request)
{
$map = self::getMapModules();
if (isset($map[$request->getModuleName()][$request->getControllerName()][$request->getActionName()])) {
return $map[$request->getModuleName()][$request->getControllerName()][$request->getActionName()];
} else {
return false;
}
}
示例12: routeShutdown
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
try {
$this->_statusRules($request->getModuleName(), $request->getControllerName(), $request->getActionName(), $request->getParam('resourceStack'));
$this->_aclRules($request->getModuleName(), $request->getControllerName(), $request->getActionName(), $request->getParam('resourceStack'), $request->getQuery());
$this->_workflowRules($request->getModuleName(), $request->getControllerName(), $request->getActionName(), $request->getParam('resourceStack'));
} catch (Saf_Controller_Front_Plugin_RouteRules_Exception $e) {
Saf_Debug::out('Enforcing Routing Rule: ' . $e->getMessage());
$request->setModuleName($e->getModuleName());
$request->setControllerName($e->getControllerName());
$request->setActionName($e->getActionName());
$request->setParam('resourceStack', $e->getResourceStack());
}
}
示例13: routeShutdown
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
$layout = Zend_Layout::getMvcInstance();
$layoutConfig = Zend_Json::decode(file_get_contents(APPLICATION_PATH . '/configs/layout.json'), true);
$layoutName = 'layout';
if (isset($layoutConfig[$request->getControllerName()])) {
if (is_array($layoutConfig[$request->getControllerName()]) && isset($layoutConfig[$request->getControllerName()][$request->getActionName()])) {
$layoutName = $layoutConfig[$request->getControllerName()][$request->getActionName()];
} else {
$layoutName = $layoutConfig[$request->getControllerName()];
}
}
$layout->setLayout('layouts/' . $layoutName);
parent::routeShutdown($request);
}
示例14: dispatchLoopStartup
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
if ($request->getModuleName() == 'admin') {
if (!$this->_auth->hasIdentity()) {
if ($request->getControllerName() == 'index' && $request->getActionName() == 'login') {
return true;
}
$this->getResponse()->setRedirect(Zend_Controller_Front::getInstance()->getBaseUrl() . '/' . 'admin/index/login');
} else {
if ($request->getControllerName() == 'index' && $request->getActionName() == 'login') {
$this->getResponse()->setRedirect(Zend_Controller_Front::getInstance()->getBaseUrl() . '/' . 'admin/index');
}
}
}
}
示例15: routeShutdown
/**
* routeShutdown
* 在 路由器 完成请求的路由后被调用
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
/**
* 检测请求的Content-type类型
*/
$pathinfo = $request->getPathInfo();
if (!empty($pathinfo)) {
if ($extension = pathinfo($pathinfo, PATHINFO_EXTENSION)) {
if (preg_match('/^[-a-z0-9]+$/i', $extension)) {
$request->setParam(static::KEY_EXT, strtolower($extension));
}
}
}
/**
* 检测是否支持json响应
*/
if ($request->getParam(static::KEY_EXT) == '') {
$accept = $request->getServer('HTTP_ACCEPT');
if (!empty($accept)) {
if (strpos($accept, 'json') !== false) {
$request->setParam(static::KEY_EXT, 'json');
}
}
}
/**
* 格式化请求目标信息,不允许[-a-zA-Z0-9]以外的字符
*/
$pattern = '/[^-a-zA-Z0-9].*/';
$request->setModuleName(preg_replace($pattern, '', $request->getModuleName()));
$request->setControllerName(preg_replace($pattern, '', $request->getControllerName()));
$request->setActionName(preg_replace($pattern, '', $request->getActionName()));
}