Example #1
0
 /**
  * This methods sets the nocache-cookie if actions in the shop are triggerd
  */
 public function setNoCacheCookie()
 {
     $controllerName = strtolower($this->request->getModuleName()) . '/' . strtolower($this->request->getControllerName());
     if (isset($this->autoNoCacheControllers[$controllerName])) {
         $noCacheTag = $this->autoNoCacheControllers[$controllerName];
         $this->setNoCacheTag($noCacheTag);
     }
     if (Shopware()->Shop()->get('defaultcustomergroup') != Shopware()->System()->sUSERGROUP) {
         $this->setNoCacheTag('price');
     }
     if ($controllerName == 'frontend/checkout' || $controllerName == 'frontend/note') {
         if (empty(Shopware()->Session()->sBasketQuantity) && empty(Shopware()->Session()->sNotesQuantity)) {
             // remove checkout-cookie
             $this->setNoCacheTag('checkout', true);
         }
     }
     if ($controllerName == 'frontend/compare' && $this->request->getActionName() == 'delete_all') {
         // remove compare cookie
         $this->setNoCacheTag('compare', true);
     }
     if (!empty(Shopware()->Session()->sNotesQuantity)) {
         // set checkout-cookie
         $this->setNoCacheTag('checkout');
     }
     if ($this->request->getModuleName() == 'frontend' && !empty(Shopware()->Session()->Admin)) {
         // set admin-cookie if admin session is present
         $this->setNoCacheTag('admin');
     }
     if ($controllerName == 'frontend/account') {
         if (in_array($this->request->getActionName(), array('ajax_logout', 'logout'))) {
             $this->setNoCacheTag('');
         }
     }
 }
Example #2
0
 /**
  * This pre-dispatch event-hook checks backend permissions
  *
  * @param \Enlight_Event_EventArgs $args
  * @throws Enlight_Controller_Exception
  * @return void
  */
 public function onPreDispatchBackend(Enlight_Event_EventArgs $args)
 {
     $this->action = $args->getSubject();
     $this->request = $this->action->Request();
     $this->aclResource = strtolower($this->request->getControllerName());
     if ($this->request->getModuleName() != 'backend' || in_array($this->aclResource, array('error'))) {
         return;
     }
     if ($this->shouldAuth()) {
         if ($this->checkAuth() === null) {
             if ($this->request->isXmlHttpRequest()) {
                 throw new Enlight_Controller_Exception('Unauthorized', 401);
             } else {
                 $this->action->redirect('backend/');
             }
         }
     } else {
         $this->initLocale();
     }
 }
Example #3
0
    /**
     * @param Enlight_Controller_Request_RequestHttp $request
     */
    public function refreshBasket($request)
    {
        $currentController = $request->getParam('requestController', $request->getControllerName());
        $sessionId = (string) Enlight_Components_Session::getId();

        if (!empty($currentController) && !empty($sessionId)) {
            $userId = (int) Shopware()->Session()->sUserId;
            $userAgent = (string) $request->getServer("HTTP_USER_AGENT");
            $sql = "
                UPDATE s_order_basket
                SET lastviewport = ?,
                    useragent = ?,
                    userID = ?
                WHERE sessionID=?
            ";
            Shopware()->Db()->query($sql, array(
                $currentController, $userAgent,
                $userId, $sessionId
            ));
        }
    }
Example #4
0
 /**
  * @see \Enlight_Controller_Router::setGlobalParam
  * @param  EnlightRequest $request
  * @return array
  */
 public static function getGlobalParamsFromRequest(EnlightRequest $request)
 {
     $globalParams = [];
     if ($request->getModuleName()) {
         $globalParams['module'] = $request->getModuleName();
         if ($request->getControllerName() !== null) {
             $globalParams['controller'] = $request->getControllerName();
             if ($request->getActionName() !== null) {
                 $globalParams['action'] = $request->getActionName();
             }
         }
     }
     return $globalParams;
 }
Example #5
0
 /**
  * @param Enlight_Controller_Request_RequestHttp $request
  */
 protected function initServiceMode($request)
 {
     $config = $this->Application()->Config();
     if (!empty($config->setOffline) && strpos($config->offlineIp, $request->getClientIp()) === false) {
         if ($request->getControllerName() != 'error') {
             $request->setControllerName('error')->setActionName('service')->setDispatched(false);
         }
     }
 }
 public function setBaseInfo(\Enlight_Controller_Request_RequestHttp $request)
 {
     $this->data['controller'] = $request->getControllerName();
     $this->data['getData'] = $request->getQuery();
     $this->data['postData'] = $request->getPost();
 }