Esempio n. 1
0
 public function testGetFullActionName()
 {
     /* empty request */
     $this->assertEquals('__', $this->_model->getFullActionName());
     $this->_model->getRequest()->setRouteName('test')->setControllerName('controller')->setActionName('action');
     $this->assertEquals('test/controller/action', $this->_model->getFullActionName('/'));
 }
Esempio n. 2
0
 /**
  * Match conversion to controller object
  *
  * @param Mage_Core_Controller_Varien_Action $action
  */
 public function match(Mage_Core_Controller_Varien_Action $action)
 {
     $actionName = $action->getFullActionName();
     $match = $this->getAction() == $actionName;
     $this->setIsMatching($match);
     Mage::dispatchEvent('luka_googleaw_match_controller', array('action' => $action, 'conversion' => $this));
     return (bool) $this->getIsMatching();
 }
Esempio n. 3
0
 /**
  * Authorize store access
  *
  * @param Mage_Core_Controller_Varien_Action $action
  */
 protected function _authorizeFrontendAccess($action)
 {
     /* @var $session Mage_Customer_Model_Session */
     $session = Mage::getSingleton('customer/session');
     /* @var $helper Tangkoko_Authorization_Helper_Store */
     $helper = Mage::helper('tangkoko_authorization/store');
     // Check if customer is authorized
     if (!$helper->isAuthorized($session->getCustomer())) {
         $request = $action->getRequest();
         $path = $action->getFullActionName('/');
         $allowedActions = $helper->getPublicActions();
         if ($allowedActions != "" && preg_match($allowedActions, $path)) {
             // Do not redirect on allowed actions
             return;
         } elseif (preg_match('#^cms/#', $path)) {
             // Do not redirect on allowed CMS page
             $identifier = $request->getParam('page_id', $request->getParam('id', Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE)));
             $page = Mage::getModel('cms/page')->load($identifier);
             if (in_array($page->getIdentifier(), $helper->getPublicCmsPages())) {
                 return;
             }
         }
         // Path is not an allowed page or action
         $url = null;
         $parameters = array();
         $message = null;
         $redirectMode = null;
         // Define redirect mode
         if ($session->isLoggedIn()) {
             // Customer is loged in
             $redirectMode = $helper->getUnauthorizedCustomerRedirect();
         } else {
             // Customer is not logged in
             $redirectMode = $helper->getAnonymousCustomerRedirect();
         }
         // Define redirection parameters depending on redirect mode
         if ($redirectMode == Tangkoko_Authorization_Helper_Store::PAGE_REDIRECT) {
             // Page redirection
             $url = $helper->getErrorPage();
         } elseif ($redirectMode == Tangkoko_Authorization_Helper_Store::CUSTOM_REDIRECT) {
             // Url redirection
             $url = $helper->getCustomRedirectUrl();
         } elseif ($redirectMode == Tangkoko_Authorization_Helper_Store::LOGIN_REDIRECT) {
             // Visitor with redirect mode equal to login
             $url = Mage_Customer_Helper_Data::ROUTE_ACCOUNT_LOGIN;
             $parameters = Mage::helper('customer')->getLoginUrlParams();
         }
         // Get redirect message
         $message = $helper->getErrorMessage();
         if (!empty($message)) {
             $errorMessage = new Mage_Core_Model_Message_Error($message);
             $session->addUniqueMessages($errorMessage);
         }
         return Mage::app()->getResponse()->setRedirect(Mage::getUrl($url, $parameters));
     }
 }
 /**
  * @param Open_Gallery_Model_Item $item
  * @param Mage_Core_Controller_Varien_Action $controller
  * @return Open_Gallery_Helper_Item_Interface|void
  */
 public function prepareAndRenderView(Open_Gallery_Model_Item $item, Mage_Core_Controller_Varien_Action $controller)
 {
     $controller->loadLayout(array('default', strtolower($controller->getFullActionName() . '_' . $item->getData('type'))));
     $controller->renderLayout();
     return $this;
 }