Пример #1
0
 /**
  * Refresh partner log
  *
  * @param   \Enlight_Controller_Request_Request $request
  * @param   \Enlight_Controller_Response_ResponseHttp $response
  */
 public function refreshPartner($request, $response)
 {
     $partner = $request->getParam('partner', $request->getParam('sPartner'));
     if ($partner !== null) {
         if (strpos($partner, 'sCampaign') === 0) {
             $campaignID = (int) str_replace('sCampaign', '', $partner);
             if (!empty($campaignID)) {
                 Shopware()->Session()->sPartner = 'sCampaign' . $campaignID;
                 $sql = '
                     UPDATE s_campaigns_mailings
                     SET clicked = clicked + 1
                     WHERE id = ?
                 ';
                 Shopware()->Db()->query($sql, array($campaignID));
             }
         } else {
             $sql = 'SELECT * FROM s_emarketing_partner WHERE active=1 AND idcode=?';
             $row = Shopware()->Db()->fetchRow($sql, array($partner));
             if (!empty($row)) {
                 if ($row['cookielifetime']) {
                     $valid = time() + $row['cookielifetime'];
                 } else {
                     $valid = 0;
                 }
                 $response->setCookie('partner', $row['idcode'], $valid, '/');
             }
             Shopware()->Session()->sPartner = $partner;
         }
     } elseif ($request->getCookie('partner') !== null) {
         $sql = 'SELECT idcode FROM s_emarketing_partner WHERE active=1 AND idcode=?';
         $partner = Shopware()->Db()->fetchOne($sql, array($request->getCookie('partner')));
         if (empty($partner)) {
             unset(Shopware()->Session()->sPartner);
         } else {
             Shopware()->Session()->sPartner = $partner;
         }
     }
 }
Пример #2
0
 /**
  * Add context cookie
  *
  * @param Request $request
  * @param Response $response
  */
 private function addContextCookie(Request $request, Response $response)
 {
     /** @var $session Enlight_Components_Session_Namespace */
     $session = $this->get('session');
     if ($session->offsetGet('sCountry')) {
         /** @var ProductContextInterface $productContext */
         $productContext = $this->get('shopware_storefront.context_service')->getProductContext();
         $userContext = sha1(json_encode($productContext->getTaxRules()) . json_encode($productContext->getCurrentCustomerGroup()));
         $response->setCookie('x-cache-context-hash', $userContext, 0, $request->getBasePath() . '/', $request->getHttpHost() == 'localhost' ? null : $request->getHttpHost());
     } else {
         if ($request->getCookie('x-cache-context-hash')) {
             $response->setCookie('x-cache-context-hash', null, strtotime('-1 Year', time()), $request->getBasePath() . '/', $request->getHttpHost() == 'localhost' ? null : $request->getHttpHost());
         }
     }
 }
Пример #3
0
 /**
  * Check the date of the last subscription-check var
  * @param Request $request
  * @return bool
  */
 private function isPluginsSubscriptionCookieValid(Request $request)
 {
     $lastCheck = $request->getCookie('lastCheckSubscriptionDate');
     return $lastCheck != date('dmY');
 }
Пример #4
0
 /**
  * Returns an array with all current values in _COOKIE
  *
  * @return array
  */
 public function toArray()
 {
     return $this->request->getCookie();
 }
Пример #5
0
 /**
  * @param Request $request
  * @return Shop
  */
 protected function getShopByRequest(Request $request)
 {
     $repository = Shopware()->Models()->getRepository('Shopware\\Models\\Shop\\Shop');
     $shop = null;
     if ($request->getPost('__shop') !== null) {
         $shop = $repository->getActiveById($request->getPost('__shop'));
     }
     if ($shop === null && $request->getCookie('shop') !== null) {
         $shop = $repository->getActiveById($request->getCookie('shop'));
     }
     if ($shop === null) {
         $shop = $repository->getActiveByRequest($request);
     }
     if ($shop === null) {
         $shop = $repository->getActiveDefault();
     }
     return $shop;
 }