/** * 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(''); } } }
/** * @return null|Shopware_Components_Auth * @throws Enlight_Controller_Exception */ public function checkAuth() { /** @var $auth Shopware_Components_Auth */ $auth = Shopware()->Auth(); if ($auth->hasIdentity()) { $auth->refresh(); } $this->initLocale($auth); if ($auth->hasIdentity()) { $identity = $auth->getIdentity(); $this->acl = Shopware()->Acl(); $this->aclRole = $identity->role; if (!$this->acl->has($this->aclResource)) { return $auth; } $actionName = $this->request->getActionName(); if ($this->action instanceof Shopware_Controllers_Backend_ExtJs) { $rules = $this->action->getAclRules(); } if (isset($rules[$actionName])) { $test = $rules[$actionName]; } else { $test = array('privilege' => 'read'); } if (!$this->isAllowed($test)) { throw new Enlight_Controller_Exception($test['errorMessage'] ?: 'Permission denied', 401); } else { return $auth; } } return null; }
/** * @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; }
/** * This function controls the buyer protection item in the basket. * * @param \Enlight_Controller_Action $controller * @param \Enlight_Controller_Request_RequestHttp $request * @param $basketAmount * @return void */ private function controlBasketTsArticle($controller, $request, $basketAmount) { //get total basket amount $amount = $this->getAmount($controller->getShippingCosts(), $basketAmount); $basketArticle = $this->isTsArticleInBasket(); //Always use the brutto-value if ($controller->View()->sAmountWithTax) { $amount = $controller->View()->sAmountWithTax; } if (empty($basketArticle)) { return; } $sql = "SELECT COUNT(id)\n\t\t\t\tFROM s_order_basket\n\t\t\t\tWHERE sessionID = ?\n\t\t\t\t\tAND modus = 0"; $articleAmount = $this->db->fetchOne($sql, array($this->sessionId)); if ($articleAmount > 1) { if ($amount > 0) { //get trusted shop article data $toAddArticle = $this->getTsArticleByAmount($amount); if ($toAddArticle['tsProductID'] == $basketArticle['ordernumber']) { return; } } } $sql = "DELETE FROM s_order_basket\n\t\t\t\tWHERE id = ?\n\t\t\t\t\tAND sessionID = ?"; $this->db->query($sql, array($basketArticle['id'], $this->sessionId)); $controller->View()->sTsArticleRemoved = true; $controller->forward($request->getActionName()); }