Example #1
0
 public function testSetGetActionName()
 {
     $this->_request->setActionName('foo');
     $this->assertEquals('foo', $this->_request->getActionName());
     $this->_request->setActionName('bar');
     $this->assertEquals('bar', $this->_request->getActionName());
 }
 /**
  * @param Zend_Controller_Request_Http $request
  */
 public function preDispatch($request)
 {
     // dont filter anything if a resident is logged in
     $session = new Zend_Session_Namespace();
     if ($session->currentResidentId) {
         $session->currentResident = Table_Residents::getInstance()->find($session->currentResidentId)->current();
         return;
     }
     // allow index and session controller to all
     if ($request->getControllerName() == 'index' || $request->getControllerName() == 'session') {
         return;
     }
     // Authenticate direct requests for non-html stuff
     if ($request->getParam('format') !== "html") {
         // The requestor provided a username
         if (isset($_SERVER['PHP_AUTH_USER'])) {
             $resident = Table_Residents::getInstance()->findResidentByEmailAndPasswordhash($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
             if ($resident) {
                 $session->currentResidentId = $resident->getId();
                 $session->currentResident = $resident;
                 return;
             }
         }
         header('WWW-Authenticate: Basic realm="WG-Organizer"');
         header('HTTP/1.0 401 Unauthorized');
         die;
     }
     // else redirect to frontpage
     $request->setControllerName('index');
     $request->setActionName('index');
 }
Example #3
0
 /**
  * @param Zend_Controller_Request_Http $request
  */
 public function preDispatch($request)
 {
     if ($request->getControllerName() == 'setup' || $request->getControllerName() == 'error') {
         // allow all setup actions
         // and all error actions
         return;
     } else {
         // redirect other to setup install
         $request->setControllerName('setup');
         $request->setActionName('install');
     }
 }
Example #4
0
 /**
  */
 public function testPreDispatch()
 {
     $this->acl->addRole('guest');
     $request = new Zend_Controller_Request_Http();
     $request->setModuleName('1');
     $request->setControllerName('2');
     $request->setActionName('3');
     $this->object->preDispatch($request);
     self::assertEquals('default', $request->getModuleName());
     self::assertEquals('error', $request->getControllerName());
     self::assertEquals('denied', $request->getActionName());
 }
 /**
  * Match the request
  *
  * @param Zend_Controller_Request_Http $request
  * @return boolean
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     //checking before even try to find out that current module
     //should use this router
     if (!$this->_beforeModuleMatch()) {
         return false;
     }
     $front = $this->getFront();
     $path = trim($request->getPathInfo(), '/');
     $p = explode('/', $path);
     if (count($p) == 0 || !$this->_pluarizeName($p[0])) {
         return false;
     } else {
         $module = $this->_pluarizeName($p[0]);
         $modules = $this->getModuleByFrontName($module);
         if ($modules === false) {
             return false;
         }
         // checks after we found out that this router should be used for current module
         if (!$this->_afterModuleMatch()) {
             return false;
         }
         // set values only after all the checks are done
         $request->setModuleName($module);
         $request->setControllerName('index');
         $action = $this->_getActionFromPathInfo($p);
         $request->setActionName($action);
         $realModule = 'Zefir_Dealers';
         $request->setControllerModule($realModule);
         $request->setRouteName('dealers');
         // dispatch action
         $request->setDispatched(true);
         /**
          * Set params for the request
          */
         if ($action == 'view') {
             $request->setParam('dealer_code', $p[1]);
         } else {
             // set parameters from pathinfo
             for ($i = 3, $l = sizeof($p); $i < $l; $i += 2) {
                 $request->setParam($p[$i], isset($p[$i + 1]) ? urldecode($p[$i + 1]) : '');
             }
         }
         // instantiate controller class and dispatch action
         $controllerClassName = $this->_validateControllerClassName($realModule, 'index');
         $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
         $controllerInstance->dispatch($action);
         return true;
     }
 }
Example #6
0
 /**
  * Validate and Match Cms Page and modify request
  *
  * @param Zend_Controller_Request_Http $request
  * @return bool
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     if (Mage::app()->getStore()->isAdmin()) {
         return false;
     }
     $sellerAtttributeName = Mage::getConfig()->getNode('default/seller_page/attribute_name');
     $seoDisplay = Mage::getConfig()->getNode('default/seller_page/seo_display');
     if (empty($sellerAtttributeName)) {
         //Seller attribute not configured
         return false;
     }
     $pageId = $request->getPathInfo();
     $param = explode('/', $pageId);
     $seller = '';
     if (count($param) > 1 and strtolower($param[1]) == $seoDisplay and !empty($param[2])) {
         //Identify Seller
         $sellerPage = $param[2];
         if (strpos($sellerPage, '.') !== false) {
             $sellerPage = urldecode(substr($sellerPage, 0, -5));
             if ($sellerPage) {
                 $seller = str_replace('-', ' ', $sellerPage);
             } else {
                 return false;
             }
         } else {
             $seller = $sellerPage;
         }
     } else {
         return false;
     }
     if ($seller) {
         Mage::register('seller_company', $seller);
         $realModule = 'Cybage_Marketplace';
         $request->setModuleName('marketplace');
         $request->setRouteName('marketplace');
         $request->setControllerName('seller');
         $request->setActionName('sellerinfo');
         $request->setControllerModule($realModule);
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim($request->getRequestString(), '/'));
         $file = Mage::getModuleDir('controllers', $realModule) . DS . 'SellerController.php';
         include $file;
         //compatibility with 1.3
         $class = $realModule . '_SellerController';
         $controllerInstance = new $class($request, $this->getFront()->getResponse());
         $request->setDispatched(true);
         $controllerInstance->dispatch('sellerinfo');
     }
     return true;
 }
Example #7
0
 protected function forwardShopby()
 {
     $reservedKey = Mage::getStoreConfig('amshopby/seo/key');
     $realModule = 'Amasty_Shopby';
     $this->request->setPathInfo($reservedKey);
     $this->request->setModuleName('amshopby');
     $this->request->setRouteName('amshopby');
     $this->request->setControllerName('index');
     $this->request->setActionName('index');
     $this->request->setControllerModule($realModule);
     $file = Mage::getModuleDir('controllers', $realModule) . DS . 'IndexController.php';
     include $file;
     //compatibility with 1.3
     $class = $realModule . '_IndexController';
     $controllerInstance = new $class($this->request, $this->getFront()->getResponse());
     $this->request->setDispatched(true);
     $controllerInstance->dispatch('index');
 }
 public function testAuthorization()
 {
     $app = za();
     za()->setUser(new GuestUser());
     $pluginConf = $app->getConfig('plugins');
     $conf = array('default' => array('user' => array('edit' => 'User,Admin', 'list' => 'Admin')), 'login_controller' => 'testcontroller', 'login_action' => 'testaction');
     $plugin = new AuthorizationPlugin($conf);
     $action = new Zend_Controller_Request_Http();
     $action->setControllerName("user");
     $action->setActionName('edit');
     $action->setModuleName('default');
     $plugin->preDispatch($action);
     // Make sure it's redirected to the user / login controller
     $this->assertEqual($action->getControllerName(), 'testcontroller');
     $this->assertEqual($action->getActionName(), 'testaction');
     // Now test that a user with role User is fine
     $user = new User();
     za()->setUser($user);
     $user->role = 'User';
     $action->setControllerName("user");
     $action->setActionName('edit');
     $plugin->preDispatch($action);
     $this->assertEqual($action->getControllerName(), 'user');
     $this->assertEqual($action->getActionName(), 'edit');
     // Make sure they can't LIST
     $action->setControllerName('user');
     $action->setActionName('list');
     $plugin->preDispatch($action);
     $this->assertEqual($action->getControllerName(), 'testcontroller');
     $this->assertEqual($action->getActionName(), 'testaction');
     // Now make them an admin, make sure they can do both the above
     $user->role = 'Admin';
     $action->setControllerName("user");
     $action->setActionName('edit');
     $plugin->preDispatch($action);
     $this->assertEqual($action->getControllerName(), 'user');
     $this->assertEqual($action->getActionName(), 'edit');
     // Make sure they can't LIST
     $action->setControllerName('user');
     $action->setActionName('list');
     $plugin->preDispatch($action);
     $this->assertEqual($action->getControllerName(), 'user');
     $this->assertEqual($action->getActionName(), 'list');
 }
 /**
  * @param Zend_Controller_Request_Http $request
  */
 public function preDispatch($request)
 {
     // dont filter anything if a resident is logged in
     $session = new Zend_Session_Namespace();
     // Sets the resident id so the next if loads the user ;)
     if ($request->getParam('appauth_key')) {
         $session->currentResidentId = Table_Residents::getInstance()->findByAppAuthKey($request->getParam('appauth_key'));
     }
     if ($session->currentResidentId) {
         $session->currentResident = Table_Residents::getInstance()->find($session->currentResidentId)->current();
         return;
     }
     // allow index and session controller to all
     if ($request->getControllerName() == 'index' || $request->getControllerName() == 'session') {
         return;
     }
     // else redirect to frontpage
     $request->setControllerName('index');
     $request->setActionName('index');
 }
 /**
  * Test that classes are found in modules, using a prefix
  */
 public function testNamespacedModules()
 {
     $this->_dispatcher->setControllerDirectory(array('default' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files', 'admin' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files/Admin'));
     $request = new Zend_Controller_Request_Http();
     $request->setControllerName('foo');
     $request->setActionName('bar');
     $request->setParam('module', 'admin');
     $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1));
     $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files/Admin', $this->_dispatcher->getDispatchDirectory());
     $response = new Zend_Controller_Response_Cli();
     $this->_dispatcher->dispatch($request, $response);
     $body = $this->_dispatcher->getResponse()->getBody();
     $this->assertContains("Admin_Foo::bar action called", $body, $body);
 }
Example #11
0
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::app()->isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $frontName = Mage::getStoreConfig('blog/info/url_key');
     $pathInfo = Mage::app()->getRequest()->getPathInfo();
     if (in_array($pathInfo, array("/{$frontName}/", "/{$frontName}"))) {
         $request->setModuleName('blog');
         $request->setControllerName('index');
         $request->setActionName('index');
         return true;
     }
     $uri = str_replace("/{$frontName}/", "", strstr($pathInfo, "/{$frontName}/"));
     if (!Mage::registry('request_path')) {
         Mage::register('request_path', $uri);
     }
     $request->setAlias(self::REWRITE_REQUEST_PATH_ALIAS, "{$frontName}/" . $uri);
     if (trim($uri, "/") == "taglist") {
         $request->setControllerName('tag');
         $request->setActionName('taglist');
         return true;
     }
     if ($uri) {
         $requestInfo = trim($uri);
         $tmp = explode("_", $requestInfo);
         if ($tmp[0] == "adminhtml") {
             return true;
         }
         $urlData = $this->analyticUrl($requestInfo);
         $request->setModuleName('blog');
         if ($postId = $urlData->getPostId()) {
             $request->setControllerName('post');
             $request->setActionName('view');
             $request->setParam('id', $postId);
             $contentUrl = explode("/", $uri);
             if (count($contentUrl) > 1) {
                 unset($contentUrl[count($contentUrl) - 1]);
                 Mage::app()->getRequest()->setParam('cat_id', $this->analyticUrl(implode('/', $contentUrl) . '.html')->getCategoryId());
             }
             return true;
         } elseif ($tagId = $urlData->getTagId()) {
             $request->setControllerName('tag');
             $request->setActionName('view');
             $request->setParam('tag_id', $tagId);
             return true;
         } elseif ($catId = $urlData->getCategoryId()) {
             $request->setControllerName('category');
             $request->setActionName('view');
             $request->setParam('id', $catId);
             return true;
         } else {
             $tmp = explode('/', $uri);
             if (count($tmp) > 2 && count($tmp) % 2 == 1) {
                 return false;
             }
             $pathController = dirname(__FILE__) . DS . '..' . DS . 'controllers' . DS . ucfirst($tmp[0]) . 'Controller.php';
             if (!file_exists($pathController)) {
                 return false;
             }
             require_once $pathController;
             $request->setControllerName($tmp[0]);
             $className = 'EM_Blog_' . ucfirst($tmp[0]) . 'Controller';
             if (count($tmp) > 2) {
                 if (!method_exists($className, $tmp[1] . 'Action')) {
                     return false;
                 }
                 $request->setActionName($tmp[1]);
                 for ($i = 2; $i < count($tmp); $i++) {
                     if (!empty($tmp[$i + 1])) {
                         $request->setParam($tmp[$i], $tmp[$i + 1]);
                     }
                 }
             } else {
                 if (count($tmp) == 2) {
                     if (!method_exists($className, $tmp[1] . 'Action')) {
                         return false;
                     }
                     $request->setActionName($tmp[1]);
                 } else {
                     $request->setActionName('index');
                 }
             }
             return true;
         }
     }
     return false;
 }
Example #12
0
<?php

define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../'));
define('APPLICATION_ENV', 'development');
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../vendor/ZendFramework/library'), get_include_path())));
require_once 'Zend/Application.php';
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap();
// the needed resources
$frontController = $application->getBootstrap()->getResource('FrontController');
$view = $application->getBootstrap()->getResource('View');
// init request
$request = new Zend_Controller_Request_Http();
$request->setControllerName('partner-usage');
$request->setActionName('export-csv');
$fromDate = new Zend_Date();
$fromDate->setHour(0);
$fromDate->setMinute(0);
$fromDate->setSecond(0);
$fromDate->setDay(1);
$fromDate->addMonth(-1);
$request->setParam('from_date', $fromDate->getTimestamp());
// beginning of last month
$toDate = new Zend_Date($fromDate);
$toDate->addMonth(1);
$toDate->addSecond(-1);
$request->setParam('to_date', $toDate->getTimestamp());
// end of last month
// init response
$response = new Zend_Controller_Response_Cli();
// dispatch
Example #13
0
 public function testModuleSubdirControllerFound()
 {
     Zend_Controller_Front::getInstance()->addControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'controllers', 'foo');
     $request = new Zend_Controller_Request_Http();
     $request->setModuleName('foo');
     $request->setControllerName('admin_index');
     $request->setActionName('index');
     $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1));
     $response = new Zend_Controller_Response_Cli();
     $this->_dispatcher->dispatch($request, $response);
     $body = $this->_dispatcher->getResponse()->getBody();
     $this->assertContains("Foo_Admin_IndexController::indexAction() called", $body, $body);
 }
Example #14
0
 /**
  * Method gets called when the PreDispatcher's dispatchLoopStartup
  * method gets called.
  * This method is API only.
  *
  * @param Zend_Controller_Request_Abstract $request
  *
  * @packageprotected
  */
 public function notifyDispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     if ($this->_preProcessRequest($request)) {
         return;
     }
     if ($this->_isExtMultiRequest) {
         return;
     }
     $config =& $this->_config;
     $extDirectData = $request->getParam($config['extParameter'], null);
     if ($extDirectData && is_string($extDirectData)) {
         $decoded = Zend_Json::decode($extDirectData);
         if (!Conjoon_Util_Array::isAssociative($decoded)) {
             $this->_isExtMultiRequest = true;
             $this->_isExtRequest = true;
             for ($i = count($decoded) - 1; $i >= 0; $i--) {
                 $controller = strtolower(preg_replace('/([a-z])([A-Z])/', "\$1.\$2", $decoded[$i]['action']));
                 $action = strtolower(preg_replace('/([a-z])([A-Z])/', "\$1.\$2", $decoded[$i]['method']));
                 $req = new Zend_Controller_Request_Http();
                 $req->setActionName($action)->setControllerName($controller)->setModuleName($request->module);
                 $this->_requestStack[] = $req;
                 $this->_requestInfo[] = array('action' => $action, 'controller' => $controller, 'module' => $request->module);
                 $decoded[$i][$config['indexKey']] = count($this->_requestStack) - 1;
                 foreach ($config['additionalParams'] as $pKey => $pValue) {
                     $req->setParam($pKey, $pValue);
                 }
                 $this->_applyParams($req, $decoded[$i]);
             }
             foreach ($config['additionalParams'] as $pKey => $pValue) {
                 $request->setParam($pKey, $pValue);
             }
             if ($config['module']) {
                 $request->setModuleName($config['module']);
             }
             if ($config['controller']) {
                 $request->setControllerName($config['controller']);
             }
             if ($config['action']) {
                 $request->setActionName($config['action']);
             }
             $this->_copyParams();
             $this->_copyHelper();
             $this->_copyPlugins();
         } else {
             $this->_isExtRequest = true;
             $this->_applyParams($request, $decoded);
         }
     }
     $this->_processed = true;
 }
Example #15
0
 public static function matchUrl(Zend_Controller_Request_Http $request)
 {
     if (AW_Kbase_Helper_Data::isModuleOutputDisabled() || !AW_Kbase_Helper_Data::getFrontendEnabled()) {
         return false;
     }
     $urlKey = self::getModuleUrlKey();
     $pathInfo = $request->getPathInfo();
     $requestUri = $request->getRequestUri();
     if ($request->getParam('___from_store')) {
         $_fromStore = Mage::app()->getSafeStore($request->getParam('___from_store'));
         if ($_fromStore->getData()) {
             $_oldUrlKey = self::getModuleUrlKeyFromConfig($_fromStore);
             if (strpos($pathInfo, '/' . $_oldUrlKey) === 0 && $_oldUrlKey != $urlKey) {
                 $_newUrl = self::secureUrl(Mage::getBaseUrl() . $urlKey . '/');
                 $response = Mage::app()->getResponse();
                 $response->setRedirect($_newUrl);
                 $response->sendHeaders();
                 $request->setDispatched(true);
                 return true;
             }
         }
     }
     if (0 !== strpos($pathInfo, '/' . $urlKey . '/')) {
         // if path does not begin with /kbase/
         return false;
     }
     $pathInfo = substr($pathInfo, strlen($urlKey) + 2);
     $request->setModuleName('kbase')->setControllerName('article');
     if (!strlen($pathInfo)) {
         $request->setActionName('index');
         return AW_Kbase_Helper_Data::getFrontendEnabled() && self::cacheRewrite($request->getPathInfo(), 'kbase/article/index');
     }
     $urlKeySuffix = self::getUrlKeySuffix();
     $isArticle = false;
     if (!$urlKeySuffix) {
         $_path = explode('/', $pathInfo);
         $_aUrl = false;
         if (count($_path) == 1) {
             $_aUrl = $_path[0];
         }
         if (count($_path) == 2) {
             $_aUrl = $_path[1];
         }
         if ($_aUrl) {
             $_aUrl = urldecode($_aUrl);
             $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_aUrl);
             if (!$_aId) {
                 $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_aUrl, true);
             }
             if ($_aId) {
                 $isArticle = true;
             }
         }
     }
     /**
      * Checking is customer comes from other store view
      * having various article suffix id in comparison
      * with current
      */
     if ($request->getParam('___from_store') && !$isArticle) {
         if (!isset($_fromStore)) {
             $_fromStore = Mage::app()->getSafeStore($request->getParam('___from_store'));
         }
         if ($_fromStore->getData()) {
             $_oldUrlSuffix = self::getUrlKeySuffixFromConfig($_fromStore);
             if ($urlKeySuffix != $_oldUrlSuffix) {
                 $_path = explode('/', $pathInfo);
                 $_aUrl = false;
                 if (count($_path) == 1) {
                     $_aUrl = $_path[0];
                 }
                 if (count($_path) == 2) {
                     $_aUrl = $_path[1];
                 }
                 if ($_aUrl) {
                     $_articleUrlKey = substr($_aUrl, 0, strpos($_aUrl, $_oldUrlSuffix));
                     $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_articleUrlKey);
                     if (!$_aId) {
                         $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_articleUrlKey, true);
                     }
                     if ($_aId) {
                         $_storeIds = Mage::getModel('kbase/article')->getResource()->getArticleStoreIds($_aId);
                         if (in_array(Mage::app()->getStore()->getId(), $_storeIds)) {
                             $_newUrl = self::secureUrl(Mage::getBaseUrl() . $urlKey . '/' . $_articleUrlKey . $urlKeySuffix);
                             $response = Mage::app()->getResponse();
                             $response->setRedirect($_newUrl);
                             $response->sendHeaders();
                             $request->setDispatched(true);
                             return true;
                         }
                     }
                 }
             }
         }
     }
     if ($urlKeySuffix && '/' != $urlKeySuffix && $urlKeySuffix == substr($pathInfo, -strlen($urlKeySuffix)) || $isArticle) {
         $pathInfo = substr($pathInfo, 0, strlen($pathInfo) - strlen($urlKeySuffix));
         $path = explode('/', $pathInfo);
         if (count($path) == 1) {
             $request->setActionName('article');
             self::$_queryParams[self::URL_PARAM_NAME_ARTICLE] = $path[0];
             return self::cacheRewrite($request->getPathInfo(), 'kbase/article/article/' . self::URL_PARAM_NAME_ARTICLE . '/' . $path[0]);
         } elseif (count($path) == 2) {
             $request->setActionName('article');
             self::$_queryParams[self::URL_PARAM_NAME_CATEGORY] = $path[0];
             self::$_queryParams[self::URL_PARAM_NAME_ARTICLE] = $path[1];
             return self::cacheRewrite($request->getPathInfo(), 'kbase/article/article/' . self::URL_PARAM_NAME_CATEGORY . '/' . $path[0] . '/' . self::URL_PARAM_NAME_ARTICLE . '/' . $path[1]);
         }
         return false;
     }
     // since further there will be listing pages only, we should check the condition here
     if (!Mage::getStoreConfig('kbase/general/frontent_enabled')) {
         return false;
     }
     // init parameters with optional ones
     self::$_queryParams = array(self::URL_PARAM_NAME_LIMIT => false, self::URL_PARAM_NAME_PAGE => false, self::URL_PARAM_NAME_SORT => false, self::URL_PARAM_NAME_SORT_DIR => false, self::URL_PARAM_NAME_QUERY => false);
     $pathInfo = substr($pathInfo, 0, strlen($pathInfo) - 1);
     $path = explode('/', $pathInfo);
     for ($i = count($path) - 1; $i > 0; $i -= 2) {
         $paramName = $path[$i - 1];
         if (array_key_exists($paramName, self::$_queryParams)) {
             //                for(; $path[$i] != $decoded = urldecode($path[$i]); $path[$i] = $decoded);
             //                self::$_queryParams[$paramName] = $path[$i];
             self::$_queryParams[$paramName] = urldecode($path[$i]);
             unset($path[$i]);
             unset($path[$i - 1]);
         }
     }
     foreach (self::$_queryParams as $paramName => $value) {
         if ($value = self::getQueryParam($requestUri, $paramName)) {
             self::$_queryParams[$paramName] = urldecode($value);
             $requestUri = self::unsetQueryParam($requestUri, $paramName);
         }
     }
     if (1 == count($path)) {
         if ('search' == $path[0]) {
             // if there were known parameters passed as query params
             if ($requestUri != $request->getRequestUri()) {
                 foreach (self::$_queryParams as $name => $value) {
                     if ($value) {
                         self::$_queryParams[$name] = self::encodeSpecialChars($value);
                     }
                 }
                 Mage::app()->getFrontController()->getResponse()->setRedirect(self::getUrl(self::URL_TYPE_SEARCH, self::$_queryParams))->sendResponse();
                 exit;
             }
             $request->setActionName('search');
             return true;
         }
         $request->setActionName('category');
         self::$_queryParams[self::URL_PARAM_NAME_CATEGORY] = $path[0];
         return true;
     } elseif (2 == count($path) && 'tag' == $path[0] && $path[1]) {
         $request->setActionName('tag');
         self::$_queryParams[self::URL_PARAM_NAME_TAG] = $path[1];
         return true;
     }
     return false;
 }
Example #16
0
 public function testSanelyDiscardOutputBufferOnException()
 {
     $request = new Zend_Controller_Request_Http();
     $request->setControllerName('ob');
     $request->setActionName('exception');
     $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1));
     $response = new Zend_Controller_Response_Cli();
     try {
         $this->_dispatcher->dispatch($request, $response);
         $this->fail('Exception should have been rethrown');
     } catch (Exception $e) {
     }
     $body = $this->_dispatcher->getResponse()->getBody();
     $this->assertNotContains("In exception action", $body, $body);
     $this->assertNotContains("Foo", $body, $body);
 }
 public function testNamespacedControllerWithCamelCaseAction()
 {
     $this->_dispatcher->setControllerDirectory(array(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'));
     $request = new Zend_Controller_Request_Http();
     $request->setModuleName('admin');
     $request->setControllerName('foo-bar');
     $request->setActionName('baz.bat');
     $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1));
     $response = new Zend_Controller_Response_Cli();
     $this->_dispatcher->dispatch($request, $response);
     $body = $this->_dispatcher->getResponse()->getBody();
     $this->assertContains("Admin_FooBar::bazBat action called", $body, $body);
 }
Example #18
0
 /**
  * Validate and Match shop view and modify request
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     $front = $this->getFront();
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $routerConfig = Mage::getStoreConfig('shopbybrand/general/router');
     $_end = Mage::getStoreConfig(Magestore_Shopbybrand_Helper_Data::XML_FRONTEND_LINK);
     $_path = urldecode(trim($request->getPathInfo(), '/'));
     if (strpos($_path, $_end)) {
         $_link_params = explode('/', str_replace($_end, '/', $_path), -1);
     } else {
         $_link_params = explode('/', $_path . '/', -1);
     }
     $_count_params = count($_link_params);
     $found = false;
     if (isset($_link_params[0])) {
         $router = $_link_params[0];
         if ($router == $routerConfig) {
             $request->setRouteName('shopbybrand')->setControllerModule('Magestore_Shopbybrand')->setModuleName('brand');
             $module = 'shopbybrand';
             if (isset($_link_params[1]) && $_link_params[1]) {
                 $request->setControllerName($_link_params[1]);
             }
             if (isset($_link_params[2]) && $_link_params[2]) {
                 $request->setActionName($_link_params[2]);
             }
             // get controller name
             if ($request->getControllerName()) {
                 $controller = $request->getControllerName();
             } else {
                 if (!empty($_link_params[1])) {
                     $controller = $_link_params[1];
                 } else {
                     $controller = $front->getDefault('controller');
                     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim($request->getOriginalPathInfo(), '/'));
                 }
             }
             // get action name
             if (empty($action)) {
                 if ($request->getActionName()) {
                     $action = $request->getActionName();
                 } else {
                     $action = !empty($_link_params[2]) ? $_link_params[2] : $front->getDefault('action');
                 }
             }
             //checking if this place should be secure
             $this->_checkShouldBeSecure($request, '/' . $module . '/' . $controller . '/' . $action);
             $controllerClassName = $this->_validateControllerClassName('Magestore_Shopbybrand', $controller);
             if (!$controllerClassName) {
                 return false;
             }
             $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
             if (!$controllerInstance->hasAction($action)) {
                 return false;
             }
             $found = true;
         }
     }
     if (!$found) {
         if ($this->_noRouteShouldBeApplied()) {
             $controller = 'index';
             $action = 'noroute';
             $controllerClassName = $this->_validateControllerClassName($realModule, $controller);
             if (!$controllerClassName) {
                 return false;
             }
             // instantiate controller class
             $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
             if (!$controllerInstance->hasAction($action)) {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
 /**
  * Tests if a task can be successfully dispatched.
  *
  * @see Zend_Controller_Front_Mock
  */
 public function testCanDispatchTask()
 {
     $controller = Zend_Controller_Front::getInstance();
     $controller->setControllerDirectory(dirname(__FILE__) . '/controllers');
     $controller->returnResponse(true);
     $controller->throwExceptions(true);
     $request = new Zend_Controller_Request_Http();
     $request->setControllerName('index');
     $request->setActionName('index');
     $scheduler = new Zend_Scheduler();
     $task = new Zend_Scheduler_Task();
     $task->setFrontController($controller);
     $task->setRequest($request);
     $scheduler->addTask('test', $task);
     $responses = $scheduler->run();
     $this->assertTrue(isset($responses['test']), 'Received empty response');
 }
Example #20
0
 public function match(Zend_Controller_Request_Http $request)
 {
     $this->fetchDefault();
     $front = $this->getFront();
     $p = explode('/', trim($request->getPathInfo(), '/'));
     // get module name
     if ($request->getModuleName()) {
         $module = $request->getModuleName();
     } else {
         $p = explode('/', trim($request->getPathInfo(), '/'));
         $module = !empty($p[0]) ? $p[0] : $this->getFront()->getDefault('module');
     }
     if (!$module) {
         return false;
     }
     $realModule = $this->getModuleByFrontName($module);
     if (!$realModule) {
         if ($moduleFrontName = array_search($module, $this->_modules)) {
             $realModule = $module;
             $module = $moduleFrontName;
         } else {
             return false;
         }
     }
     if (!Mage::app()->isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     if (Mage::app()->isInstalled() && !$request->isPost()) {
         $shouldBeSecure = substr(Mage::getStoreConfig('web/unsecure/base_url'), 0, 5) === 'https' || Mage::getStoreConfigFlag('web/secure/use_in_adminhtml') && substr(Mage::getStoreConfig('web/secure/base_url'), 0, 5) === 'https';
         if ($shouldBeSecure && !Mage::app()->getStore()->isCurrentlySecure()) {
             $url = Mage::getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
             Mage::app()->getFrontController()->getResponse()->setRedirect($url)->sendResponse();
             exit;
         }
     }
     // get controller name
     if ($request->getControllerName()) {
         $controller = $request->getControllerName();
     } else {
         $controller = !empty($p[1]) ? $p[1] : $front->getDefault('controller');
     }
     $controllerFileName = $this->getControllerFileName($realModule, $controller);
     if (!$controllerFileName || !is_readable($controllerFileName)) {
         $controller = 'index';
         $action = 'noroute';
         $controllerFileName = $this->getControllerFileName($realModule, $controller);
     }
     $controllerClassName = $this->getControllerClassName($realModule, $controller);
     if (!$controllerClassName) {
         $controller = 'index';
         $action = 'noroute';
         $controllerFileName = $this->getControllerFileName($realModule, $controller);
     }
     // get action name
     if (empty($action)) {
         if ($request->getActionName()) {
             $action = $request->getActionName();
         } else {
             $action = !empty($p[2]) ? $p[2] : $front->getDefault('action');
         }
     }
     // include controller file if needed
     if (!class_exists($controllerClassName, false)) {
         include $controllerFileName;
         if (!class_exists($controllerClassName)) {
             throw Mage::exception('Mage_Core', Mage::helper('core')->__('Controller file was loaded but class does not exist'));
         }
     }
     // instantiate controller class
     $controllerInstance = new $controllerClassName($request, $front->getResponse());
     if (!$controllerInstance->hasAction($action)) {
         return false;
     }
     // set values only after all the checks are done
     $request->setModuleName($module);
     $request->setControllerName($controller);
     $request->setActionName($action);
     // set parameters from pathinfo
     for ($i = 3, $l = sizeof($p); $i < $l; $i += 2) {
         $request->setParam($p[$i], isset($p[$i + 1]) ? $p[$i + 1] : '');
     }
     // dispatch action
     $request->setDispatched(true);
     $controllerInstance->dispatch($action);
     return true;
     #$request->isDispatched();
 }
use Pimcore\Model\Object;
use Pimcore\Model\Document;
// determines if we're in Pimcore\Console mode
$pimcoreConsole = defined('PIMCORE_CONSOLE') && true === PIMCORE_CONSOLE;
$workingDirectory = getcwd();
chdir(__DIR__);
include_once "../config/startup.php";
chdir($workingDirectory);
// CLI \Zend_Controller_Front Setup, this is required to make it possible to make use of all rendering features
// this includes $this->action() in templates, ...
$front = \Zend_Controller_Front::getInstance();
Pimcore::initControllerFront($front);
$request = new \Zend_Controller_Request_Http();
$request->setModuleName(PIMCORE_FRONTEND_MODULE);
$request->setControllerName("default");
$request->setActionName("default");
$front->setRequest($request);
$front->setResponse(new \Zend_Controller_Response_Cli());
// generic pimcore setup
\Pimcore::setSystemRequirements();
\Pimcore::initAutoloader();
\Pimcore::initConfiguration();
\Pimcore::setupFramework();
\Pimcore::initLogger();
\Pimcore::initModules();
\Pimcore::initPlugins();
//Activate Inheritance for cli-scripts
\Pimcore::unsetAdminMode();
Document::setHideUnpublished(true);
Object\AbstractObject::setHideUnpublished(true);
Object\AbstractObject::setGetInheritedValues(true);
Example #22
0
 /**
  * @see ZF-2693
  */
 public function testForcingCamelCasedActionsNotRequestedWithWordSeparatorsShouldRaiseNotices()
 {
     $this->_dispatcher->setParam('useCaseSensitiveActions', true);
     $request = new Zend_Controller_Request_Http();
     $request->setModuleName('admin');
     $request->setControllerName('foo-bar');
     $request->setActionName('bazBat');
     $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1));
     $response = new Zend_Controller_Response_Cli();
     set_error_handler(array($this, 'handleErrors'));
     try {
         $this->_dispatcher->dispatch($request, $response);
         $body = $this->_dispatcher->getResponse()->getBody();
         restore_error_handler();
         $this->assertTrue(isset($this->error));
         $this->assertContains('deprecated', $this->error);
     } catch (Zend_Controller_Exception $e) {
         restore_error_handler();
         $this->fail('camelCased actions should succeed when forced');
     }
 }
 /**
  * Test valid action on valid controller; test pre/postDispatch
  */
 public function testDispatch4()
 {
     $request = new Zend_Controller_Request_Http();
     $request->setControllerName('foo');
     $request->setActionName('bar');
     $response = new Zend_Controller_Response_Cli();
     $this->_dispatcher->dispatch($request, $response);
     $body = $this->_dispatcher->getResponse()->getBody();
     $this->assertContains('Bar action called', $body);
     $this->assertContains('preDispatch called', $body);
     $this->assertContains('postDispatch called', $body);
 }
 /**
  * create scheduler task
  * 
  * @return Tinebase_Scheduler_Task
  */
 protected function _createTask()
 {
     $request = new Zend_Controller_Request_Http();
     $request->setControllerName('Tinebase_Alarm');
     $request->setActionName('sendPendingAlarms');
     $request->setParam('eventName', 'Tinebase_Event_Async_Minutely');
     $task = new Tinebase_Scheduler_Task();
     $task->setMonths("Jan-Dec");
     $task->setWeekdays("Sun-Sat");
     $task->setDays("1-31");
     $task->setHours("0-23");
     $task->setMinutes("0/1");
     $task->setRequest($request);
     return $task;
 }
Example #25
0
 /**
  * Test that extra arguments get passed
  */
 public function testDispatch5()
 {
     $request = new Zend_Controller_Request_Http();
     $request->setControllerName('index');
     $request->setActionName('args');
     $this->_controller->setResponse(new Zend_Controller_Response_Cli());
     $this->_controller->addParam('foo');
     $this->_controller->addParam('bar');
     $response = $this->_controller->dispatch($request);
     $body = $response->getBody();
     $this->assertContains('foo; bar', $body);
 }
Example #26
0
 public function testModuleControllerInSubdirWithCamelCaseAction()
 {
     $request = new Zend_Controller_Request_Http();
     $request->setModuleName('admin');
     $request->setControllerName('foo-bar');
     $request->setActionName('baz.bat');
     $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1));
     $response = new Zend_Controller_Response_Cli();
     $this->_dispatcher->dispatch($request, $response);
     $body = $this->_dispatcher->getResponse()->getBody();
     $this->assertContains("Admin_FooBar::bazBat action called", $body, $body);
 }
Example #27
0
 public function testDisableOutputBuffering()
 {
     if (!defined('TESTS_ZEND_CONTROLLER_DISPATCHER_OB') || !TESTS_ZEND_CONTROLLER_DISPATCHER_OB) {
         $this->markTestSkipped('Skipping output buffer disabling in Zend_Controller_Dispatcher_Standard');
     }
     $request = new Zend_Controller_Request_Http();
     $request->setControllerName('ob');
     $request->setActionName('index');
     $this->_dispatcher->setParam('disableOutputBuffering', true);
     $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1));
     $response = new Zend_Controller_Response_Cli();
     $this->_dispatcher->dispatch($request, $response);
     $body = $this->_dispatcher->getResponse()->getBody();
     $this->assertEquals('', $body, $body);
 }
Example #28
0
 public function match(Zend_Controller_Request_Http $request)
 {
     if (Mage::app()->getStore()->isAdmin()) {
         return false;
     }
     $pageId = $request->getPathInfo();
     // remove suffix if any
     $suffix = Mage::getStoreConfig('catalog/seo/category_url_suffix');
     if ($suffix && '/' != $suffix) {
         $pageId = str_replace($suffix, '', $pageId);
     }
     //add trailing slash
     $pageId = trim($pageId, '/') . '/';
     $reservedKey = Mage::getStoreConfig('amshopby/seo/key') . '/';
     //check if we have reserved word in the url
     if (false === strpos($pageId, '/' . $reservedKey)) {
         if (substr($pageId, 0, strlen($reservedKey)) != $reservedKey) {
             return false;
         }
     } else {
         $reservedKey = '/' . $reservedKey;
     }
     // get layered navigation params as string
     list($cat, $params) = explode($reservedKey, $pageId, 2);
     $params = trim($params, '/');
     if ($params) {
         $params = explode('/', $params);
     }
     // remember for futire use in the helper
     if ($params) {
         Mage::register('amshopby_current_params', $params);
     }
     $cat = trim($cat, '/');
     if ($cat) {
         // normal category
         // if somebody has old urls in the cache.
         if (!Mage::getStoreConfig('amshopby/seo/urls')) {
             return false;
         }
         Varien_Autoload::registerScope('catalog');
         $cat = $cat . $suffix;
         $urlRewrite = Mage::getModel('core/url_rewrite')->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($cat);
         if (!$urlRewrite->getId()) {
             $store = $request->getParam('___from_store');
             $store = Mage::app()->getStore($store)->getId();
             if (!$store) {
                 return false;
             }
             $urlRewrite = Mage::getModel('core/url_rewrite')->setStoreId($store)->loadByRequestPath($cat);
         }
         if (!$urlRewrite->getId()) {
             return false;
         }
         $request->setPathInfo($cat);
         $request->setModuleName('catalog');
         $request->setControllerName('category');
         $request->setActionName('view');
         $request->setParam('id', $urlRewrite->getCategoryId());
         $urlRewrite->rewrite($request);
     } else {
         // root category
         $realModule = 'Amasty_Shopby';
         $request->setPathInfo(trim($reservedKey, '/'));
         $request->setModuleName('amshopby');
         $request->setRouteName('amshopby');
         $request->setControllerName('index');
         $request->setActionName('index');
         $request->setControllerModule($realModule);
         $file = Mage::getModuleDir('controllers', $realModule) . DS . 'IndexController.php';
         include $file;
         //compatibility with 1.3
         $class = $realModule . '_IndexController';
         $controllerInstance = new $class($request, $this->getFront()->getResponse());
         $request->setDispatched(true);
         $controllerInstance->dispatch('index');
     }
     return true;
 }
 public function match(Zend_Controller_Request_Http $request)
 {
     if (Mage::app()->getStore()->isAdmin()) {
         return false;
     }
     $pageId = $request->getPathInfo();
     // remove suffix if any
     $suffix = Mage::helper('amshopby/url')->getUrlSuffix();
     if ($suffix && '/' != $suffix) {
         $pageId = str_replace($suffix, '', $pageId);
     }
     //add trailing slash
     $pageId = trim($pageId, '/') . '/';
     $reservedKey = Mage::getStoreConfig('amshopby/seo/key') . '/';
     //  canon/
     //  electronics - false
     //  electronics/shopby/canon/
     //  electronics/shopby/red/
     //  electronics/shopby/
     //  shopby/
     //  shopby/red/
     //  shopby/canon/ - false
     //  shopby/manufacturer-canon/ - false
     //  manufacturer-canon/ - true
     // starts from shopby
     $isAllProductsPage = substr($pageId, 0, strlen($reservedKey)) == $reservedKey;
     // has shopby in the middle
     $isCategoryPage = false !== strpos($pageId, '/' . $reservedKey);
     if (!Mage::getStoreConfig('amshopby/seo/urls')) {
         // If path info have something after reserved key
         if (($isAllProductsPage || $isCategoryPage) && substr($pageId, -strlen($reservedKey), strlen($reservedKey)) != $reservedKey) {
             return false;
         }
     }
     if ($isAllProductsPage) {
         // no support for old style urls
         if ($this->hasBrandIn(self::MIDDLE, $pageId)) {
             return false;
         }
     }
     if (!$isAllProductsPage && !$isCategoryPage) {
         if (!$this->hasBrandIn(self::BEGINNING, $pageId)) {
             return false;
         }
         //it is brand page and we modify the url to be in the old style
         $pageId = $reservedKey . $pageId;
     }
     // get layered navigation params as string
     list($cat, $params) = explode($reservedKey, $pageId, 2);
     $params = trim($params, '/');
     if ($params) {
         $params = explode('/', $params);
     }
     // remember for futire use in the helper
     if ($params) {
         Mage::register('amshopby_current_params', $params);
     }
     $cat = trim($cat, '/');
     if ($cat) {
         // normal category
         // if somebody has old urls in the cache.
         if (!Mage::getStoreConfig('amshopby/seo/urls')) {
             return false;
         }
         // we do not use Mage::getVersion() here as it is not defined in the old versions.
         $isVersionEE13 = 'true' == (string) Mage::getConfig()->getNode('modules/Enterprise_UrlRewrite/active');
         if ($isVersionEE13) {
             $urlRewrite = Mage::getModel('enterprise_urlrewrite/url_rewrite');
             /* @var $urlRewrite Enterprise_UrlRewrite_Model_Url_Rewrite */
             if (version_compare(Mage::getVersion(), '1.13.0.2', '>=')) {
                 $catReqPath = array('request' => $cat . $suffix, 'whole' => $cat);
             } else {
                 $catReqPath = array($cat);
             }
             $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
         } else {
             $urlRewrite = Mage::getModel('core/url_rewrite');
             /* @var $urlRewrite Mage_Core_Model_Url_Rewrite */
             $cat = $cat . $suffix;
             $catReqPath = $cat;
             $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
         }
         // todo check in ee13
         if (!$urlRewrite->getId()) {
             $store = $request->getParam('___from_store');
             $store = Mage::app()->getStore($store)->getId();
             if (!$store) {
                 return false;
             }
             $urlRewrite->setData(array())->setStoreId($store)->loadByRequestPath($catReqPath);
             if (!$urlRewrite->getId()) {
                 return false;
             }
         }
         $request->setPathInfo($cat);
         $request->setModuleName('catalog');
         $request->setControllerName('category');
         $request->setActionName('view');
         if ($isVersionEE13) {
             $categoryId = str_replace('catalog/category/view/id/', '', $urlRewrite->getTargetPath());
             $request->setParam('id', $categoryId);
         } else {
             $request->setParam('id', $urlRewrite->getCategoryId());
             $urlRewrite->rewrite($request);
         }
     } else {
         // root category
         $realModule = 'Amasty_Shopby';
         $request->setPathInfo(trim($reservedKey, '/'));
         $request->setModuleName('amshopby');
         $request->setRouteName('amshopby');
         $request->setControllerName('index');
         $request->setActionName('index');
         $request->setControllerModule($realModule);
         $file = Mage::getModuleDir('controllers', $realModule) . DS . 'IndexController.php';
         include $file;
         //compatibility with 1.3
         $class = $realModule . '_IndexController';
         $controllerInstance = new $class($request, $this->getFront()->getResponse());
         $request->setDispatched(true);
         $controllerInstance->dispatch('index');
     }
     return true;
 }
Example #30
0
 /**
  * Called before an action is dispatched by Zend_Controller_Dispatcher.
  *
  * This callback allows for proxy or filter behavior.  The
  * $action must be returned for the Zend_Controller_Dispatcher_Token to be dispatched.
  * To abort the dispatch, return FALSE.
  *
  * @param  Zend_Controller_Request_Http $action
  * @return Zend_Controller_Request_Http
  */
 public function preDispatch($action)
 {
     /*@var $action Zend_Controller_Request_Http */
     $controllerName = strtolower($action->getControllerName());
     $actionName = strtolower($action->getActionName());
     $moduleName = strtolower($action->getModuleName());
     // Check for authorization.
     $app = NovemberApplication::getInstance();
     $currentUser = $app->getUser();
     if ($currentUser->getRole() == User::ROLE_LOCKED) {
         $action->setControllerName(ifset($this->config, 'login_controller', 'user'));
         $action->setActionName(ifset($this->config, 'login_action', 'login'));
         return $action;
     }
     // Get the restrictions for the current request (if any)
     $conf = ifset($this->config, $moduleName);
     $roles = '';
     if (is_string($conf)) {
         $roles = $conf;
     } else {
         if (is_array($conf)) {
             // check for a default
             $roles = ifset($conf, 'default_roles', '');
             // If there's something in the controllername entry...
             $controllerConf = ifset($conf, $controllerName, $roles);
             if (is_array($controllerConf)) {
                 $roles = ifset($controllerConf, $actionName, $roles);
             } else {
                 $roles = $controllerConf;
             }
         }
     }
     // Are there required roles to authenticate?
     $loginRequired = false;
     za()->log(__CLASS__ . ':' . __LINE__ . " - Authorizing " . $currentUser->getUsername() . " for roles {$roles}");
     if ($roles != '') {
         $loginRequired = true;
         $roles = explode(',', $roles);
         // If the user has any of the roles, let them in
         foreach ($roles as $role) {
             if ($currentUser->hasRole($role)) {
                 return $action;
             }
         }
     }
     // If we've got this far, then we should ask the DB if the current user has
     // access to the current module and controller
     // We're expecting user_access =>
     // user_role
     // OR array (controller => user_role)
     $userAccess = ifset($conf, 'user_access');
     if ($userAccess != null) {
         $loginRequired = true;
         // if it's a string, just get the access for the module
         $accessService = za()->getService('AccessService');
         // See if they have access to this module
         $access = $accessService->getAccessList($currentUser->getUsername(), $moduleName);
         if (count($access)) {
             // okay, they have access, so we're all cool
             return $action;
         }
     }
     if ($loginRequired) {
         $url = build_url($controllerName, $actionName, $action->getUserParams(), false, $moduleName);
         $_SESSION[NovemberController::RETURN_URL] = $url;
         // $action->setModuleName(ifset($this->config, 'login_module', 'default'));
         $action->setControllerName($this->config['login_controller']);
         $action->setActionName($this->config['login_action']);
     }
     return $action;
 }