本文整理汇总了PHP中Zend_Controller_Request_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Abstract类的具体用法?PHP Zend_Controller_Request_Abstract怎么用?PHP Zend_Controller_Request_Abstract使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Controller_Request_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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;
}
示例2: 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('/');
}
}
}
示例3: routeShutdown
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
Zend_Layout::getMvcInstance()->setLayout($request->getModuleName());
Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/modules/" . $request->getModuleName() . "/layouts/scripts");
$eh = Zend_Controller_Front::getInstance()->getPlugin("Zend_Controller_Plugin_ErrorHandler");
$eh->setErrorHandlerModule($request->getModuleName());
}
示例4: postDispatch
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
$layout = Zend_Layout::getMvcInstance();
// the name "maintenanceMode" is also referred to in the Admin_MaintenanceController,
// so if you change the filename, it needs to be changed there too
$maintenanceModeFileName = 'maintenanceMode';
$register = new Ot_Config_Register();
$identity = Zend_Auth::getInstance()->getIdentity();
$role = empty($identity->role) ? $register->defaultRole->getValue() : $identity->role;
if (isset($identity->masquerading) && $identity->masquerading == true && isset($identity->realAccount) && !is_null($identity->realAccount) && isset($identity->realAccount->role)) {
$role = $identity->realAccount->role;
}
$acl = Zend_Registry::get('acl');
$view = $layout->getView();
$viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer');
if (is_file(APPLICATION_PATH . '/../overrides/' . $maintenanceModeFileName) && (!$request->isXmlHttpRequest() && !$viewRenderer->getNeverRender())) {
if (!$acl->isAllowed($role, 'ot_maintenance', 'index')) {
if (!($request->getModuleName() == 'ot' && $request->getControllerName() == 'login' && $request->getActionName() == 'index')) {
$response = $this->getResponse();
$layout->disableLayout();
$response->setBody($view->maintenanceMode()->publicLayout());
}
} else {
$response = $this->getResponse();
// there's no point in setting text here if it's a redirect
if ($response->isRedirect()) {
$response->setBody('');
} else {
$response->setBody($view->maintenanceMode()->header() . $response->getBody());
}
}
}
}
示例5: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$context = $request->getHeader('X-Zrt-Format');
if ($context) {
$request->setParam('format', $context);
}
}
示例6: 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');
}
}
}
示例7: preDispatch
/**
*
* @param Zend_Controller_Request_Abstract $request
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$options = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getApplication()->getOptions();
$config = new Zend_Config($options);
$acl = new My_Acl($config);
$role = 'guest';
if (Zend_Auth::getInstance()->hasIdentity()) {
$role = 'user';
if (Zend_Auth::getInstance()->hasIdentity()) {
return;
} else {
$login = Zend_Auth::getInstance()->getIdentity();
$user = My_Model::get('Users')->getUserByEmail($login);
if ($user->admin == 1) {
$role = 'admin';
}
}
}
$controller = $request->getControllerName();
$action = $request->getActionName();
$resource = $controller;
$privilege = $action;
if (!$acl->has($resource)) {
$resource = null;
}
if (is_null($privilege)) {
$privilege = 'index';
}
if (!$acl->isAllowed($role, $resource, $privilege)) {
// $flash = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
// $flash->addMessage('Access Denied');
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
$redirector->gotoSimpleAndExit('login', 'admin');
}
}
示例8: apply
/**
* Apply category filter to layer
*
* @param Zend_Controller_Request_Abstract $request
* @param Mage_Core_Block_Abstract $filterBlock
* @return Mage_Catalog_Model_Layer_Filter_Category
*/
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
{
$layer = Mage::helper('conversionpro')->getCurrentLayer();
$filter = (int) $request->getParam($this->getRequestVar());
if (!$filter) {
return $this;
}
$this->_categoryId = Mage::helper('conversionpro')->getCategoryIdByAnswerId($filter);
Mage::register('current_category_filter', $this->getCategory(), true);
$this->_appliedCategory = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($this->_categoryId);
// For some reason, this class runs twice, and not as a singelton, so we have no way of monitoring
// whether the state filter was already added or not by using some class parameter. Instead,
// we're going over all the filters to see if any has 'Category' for the name, and only adding the state
// tag if we can't find one.
$isFilterApplied = false;
$filters = $this->getLayer()->getState()->getFilters();
foreach ($filters as $filter) {
if ($filter->getName() == $this->getName()) {
$isFilterApplied = true;
}
}
//If there's no state tag for the cateogry yet, create it.
if (!$isFilterApplied) {
//If this category exists in Magento, it will execute normally. In any other case, we assume that the chosen
// answer doesn't exist in Magento and apply it as a regular filter. The getCategoryIdByAnswerText() function
// saves the answer's text to $this->_categoryId in these cases, so we can use that as the state tag's
// label.
if ($this->_isValidCategory($this->_appliedCategory)) {
$this->getLayer()->getState()->addFilter($this->_createItem($this->_appliedCategory->getName(), $this->_categoryId));
} else {
$this->getLayer()->getState()->addFilter($this->_createItem($this->_categoryId, $filter));
}
}
return $this;
}
示例9: 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);
}
示例10: 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');
}
}
示例11: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
//clear session from search session
//$this->clearSession();
$session_user = new Zend_Session_Namespace('auth');
$module = $request->getModuleName();
$controller = $request->getControllerName();
$action = $request->getActionName();
$url = $module . "/" . $controller . "/" . $action;
$_url = "";
//have login
if (isset($session_user->arr_acl)) {
$arr_acl = $session_user->arr_acl;
$valid_action = FALSE;
foreach ($arr_acl as $acl) {
if ($module == $acl["module"] && $controller == $acl["controller"]) {
$valid_action = TRUE;
break;
} elseif ($module === "rsvAcl" && $controller === "user" && $action === "change-password") {
//all user level can change password all
$valid_action = TRUE;
break;
} elseif ($module === "rsvAcl" && $session_user->level === "1") {
//user level 1 can access all action in module "rsvAcl"
$valid_action = TRUE;
break;
}
}
//redirect to homepage
if (!$valid_action) {
//just open block below
if ($url !== "default/index/index" && $url !== "default/error/error" && $url !== "default/index/changepassword" && $url !== "default/index/logout") {
$_url = '/';
}
$_have = false;
foreach ($this->_exception_url as $i => $val) {
if ($url === $val) {
$_have = true;
break;
}
}
if (!$_have) {
$_url = '/';
}
} else {
$_url = $this->rewriteUrl($url);
}
} else {
//no login
//redirect to login page
if ($url !== "default/index/index") {
$_url = "/";
}
}
if (!empty($_url)) {
// echo"url here". $_url;exit();
$_url = "/home";
Application_Form_FrmMessage::redirectUrl($_url);
}
}
示例12: apply
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
{
$filter = $request->getParam($this->getRequestVar());
if (is_null($filter)) {
return parent::apply($request, $filterBlock);
}
if (!is_numeric($filter)) {
if (Mage::registry('current_category')) {
$collection = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('parent_id', Mage::registry('current_category')->getId())->addAttributeToFilter('is_active', 1)->addAttributeToSelect('name')->addAttributeToFilter('name', $filter);
$this->_appliedCategory = $collection->getFirstItem();
if (!$this->_appliedCategory->getProductCollection()->count()) {
$this->_appliedCategory = $this->_getCategoryByName($filter);
}
} else {
$this->_appliedCategory = $this->_getCategoryByName($filter);
}
if ($this->_appliedCategory) {
$this->_categoryId = $filter = $this->_appliedCategory->getId();
}
} else {
$this->_categoryId = $filter;
$this->_appliedCategory = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($filter);
}
if ($this->_isValidCategory($this->_appliedCategory)) {
$this->getLayer()->getProductCollection()->addCategoryFilter($this->_appliedCategory);
$this->getLayer()->getState()->addFilter($this->_createItem($this->_appliedCategory->getName(), $filter));
}
return $this;
}
示例13: routeShutdown
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
if (!$this->_domain) {
$error = false;
if ($request->getParam('lang') && !$this->_issession) {
$this->_session->lang = $this->_model->fetchOne('id', array('`stitle` = ?' => $request->getParam('lang')));
if (!$this->_session->lang) {
$error = true;
}
}
$this->_lang = $this->_model->fetchRow(null, '(`id` = ' . (int) $this->_session->lang . ') DESC, (`default` = 1) DESC');
if ($this->_lang) {
$this->_lang = new Zkernel_View_Data($this->_lang);
$this->_lang->session = $this->_issession;
if (!$this->_domain) {
unset($this->_lang->domain);
}
}
$this->_lang->_default = $this->getDefault();
$this->_lang->_ids = $this->_model->fetchIds();
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$router->setGlobalParam('lang', $this->_lang->stitle);
$this->save();
if ($error) {
throw new Zend_Controller_Action_Exception('Not Found', 404);
}
}
if (!$this->_domain && !$this->_issession && substr($_SERVER['REQUEST_URI'], 0, 8) == '/control') {
header('Location: /' . $this->_lang->_default->stitle . $_SERVER['REQUEST_URI'], true, 301);
exit;
}
}
示例14: preDispatch
/**
* Add the appropriate view scripts directories for a given request.
* This is pretty much the glue between the plugin broker and the
* View object, since it uses data from the plugin broker to determine what
* script paths will be available to the view.
*
* @param Zend_Controller_Request_Abstract $request Request object.
* @return void
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
// Getting the module name from the request object is pretty much the main
// reason why this needs to be in a controller plugin and can't be localized
// to the view script.
$moduleName = $request->getModuleName();
$isPluginModule = !in_array($moduleName, array('default', null));
$themeType = is_admin_theme() ? 'admin' : 'public';
$pluginScriptDirs = $this->_pluginMvc->getViewScriptDirs($themeType);
// Remove the current plugin, if any, from the set of "normal" plugin paths
if ($isPluginModule && isset($pluginScriptDirs[$moduleName])) {
$currentPluginScriptDirs = $pluginScriptDirs[$moduleName];
unset($pluginScriptDirs[$moduleName]);
}
// Add all the "normal" plugin paths
foreach ($pluginScriptDirs as $modulePaths) {
$this->_addPathsToView($modulePaths);
}
// Add the theme and core paths
$this->_addThemePaths($themeType);
// Add plugin and theme-override paths for current plugin
if ($isPluginModule) {
if (isset($currentPluginScriptDirs)) {
$this->_addPathsToView($currentPluginScriptDirs);
}
$this->_addOverridePathForPlugin($themeType, $moduleName);
}
}
示例15: preDispatch
/**
* Hlavni logika ACL
*
* @param $request
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$controller = $request->getControllerName();
$action = $request->getActionName();
$module = $request->getModuleName();
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$acl = new Zend_Acl();
$identity = $auth->getIdentity();
$acl->addRole(new Zend_Acl_Role('user'))->addRole(new Zend_Acl_Role('owner'))->addRole(new Zend_Acl_Role('admin'), 'owner');
if ($identity->owner == true) {
$inherit = 'owner';
} elseif ($identity->administrator == true) {
$inherit = 'admin';
} else {
$inherit = 'user';
}
$acl->addRole(new Zend_Acl_Role($identity->email), $inherit);
$projekt = $request->getParam('projekt');
// Zakladni resource
foreach ($this->_resources as $val => $key) {
$acl->add(new Zend_Acl_Resource($key));
}
// Prava pro zakladni resource
$acl->allow('owner');
$acl->deny('admin', 'account');
$acl->allow('user', array('index', 'project', 'assignment', 'calendar', 'people', 'auth', 'redir'));
$acl->deny('user', 'account');
$acl->deny('user', 'project', $this->_create);
$acl->deny('user', 'people', $this->_create);
$acl->deny('user', 'project', $this->_manage);
$acl->deny('user', 'people', $this->_manage);
if ($request->id == $identity->iduser) {
$acl->allow('user', 'people', $this->_manage);
}
// Resource pro projektovou podsekci
$this->_projectAcl($acl, $identity);
Zend_Registry::set('acl', $acl);
if ($identity->administrator == 1) {
$isAllowed = true;
} elseif (in_array($projekt . '|' . $request->getControllerName(), $this->_resources)) {
$isAllowed = $acl->isAllowed($identity->email, $projekt . '|' . $request->getControllerName(), $request->getActionName());
} elseif (in_array($request->getControllerName(), $this->_resources)) {
$isAllowed = $acl->isAllowed($identity->email, $request->getControllerName(), $request->getActionName());
} else {
$isAllowed = false;
}
$error = $request->getParam('error_handler');
if (is_null($error)) {
if (!$isAllowed) {
$module = $this->_noacl['module'];
$controller = $this->_noacl['controller'];
$action = $this->_noacl['action'];
}
}
$request->setModuleName($module);
$request->setControllerName($controller);
$request->setActionName($action);
}
}