Exemple #1
0
 /**
  * This method controls the default routing. Don't be called when the
  * Enlight_Controller_Router_Route event canceled the default routing.
  * The default routing uses the dispatcher of the front controller to route
  * the request to the corresponding controller method.
  *
  * @param Enlight_Controller_Request_RequestHttp $request
  * @return array
  */
 public function routeDefault(Enlight_Controller_Request_Request $request)
 {
     $path = trim($request->getPathInfo(), $this->separator);
     if (empty($path)) {
         return array();
     }
     $dispatcher = $this->front->Dispatcher();
     $query = array();
     $params = array();
     foreach (explode($this->separator, $path) as $routePart) {
         $routePart = urldecode($routePart);
         if (empty($query[$request->getModuleKey()]) && $dispatcher->isValidModule($routePart)) {
             $query[$request->getModuleKey()] = $routePart;
         } elseif (empty($query[$request->getControllerKey()])) {
             $query[$request->getControllerKey()] = $routePart;
         } elseif (empty($query[$request->getActionKey()])) {
             $query[$request->getActionKey()] = $routePart;
         } else {
             $params[] = $routePart;
         }
     }
     if ($params) {
         $chunks = array_chunk($params, 2, false);
         foreach ($chunks as $chunk) {
             if (isset($chunk[1])) {
                 $query[$chunk[0]] = $chunk[1];
             } else {
                 $query[$chunk[0]] = '';
             }
         }
     }
     return $query;
 }
 /**
  * @inheritdoc
  */
 public function savePaymentData($userId, \Enlight_Controller_Request_Request $request)
 {
     $lastPayment = $this->getCurrentPaymentDataAsArray($userId);
     $paymentMean = Shopware()->Models()->getRepository('\\Shopware\\Models\\Payment\\Payment')->getPaymentsQuery(array('name' => 'debit'))->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY);
     $data = array('account_number' => $request->getParam("sDebitAccount"), 'bank_code' => $request->getParam("sDebitBankcode"), 'bankname' => $request->getParam("sDebitBankName"), 'account_holder' => $request->getParam("sDebitBankHolder"));
     if (!$lastPayment) {
         $date = new \DateTime();
         $data['created_at'] = $date->format('Y-m-d');
         $data['payment_mean_id'] = $paymentMean['id'];
         $data['user_id'] = $userId;
         Shopware()->Db()->insert("s_core_payment_data", $data);
     } else {
         $where = array('payment_mean_id = ?' => $paymentMean['id'], 'user_id = ?' => $userId);
         Shopware()->Db()->update("s_core_payment_data", $data, $where);
     }
     /**
      * This section is legacy code form the old core debit.php class
      * It's still used to avoid BC break, but should be considered deprecated
      * and it will be removed in future releases
      *
      * It updates the s_user_debit (deprecated) table with the submited data
      */
     $data = array($request->getParam("sDebitAccount"), $request->getParam("sDebitBankcode"), $request->getParam("sDebitBankName"), $request->getParam("sDebitBankHolder"), $userId);
     if ($this->getData($userId)) {
         $sql = "UPDATE s_user_debit SET account=?, bankcode=?, bankname=?, bankholder=?\n                WHERE userID = ?";
     } else {
         $sql = "INSERT INTO s_user_debit (account, bankcode, bankname, bankholder, userID)\n                VALUES (?,?,?,?,?)";
     }
     Shopware()->Db()->query($sql, $data);
 }
Exemple #3
0
 /**
  * Listener method for the Enlight_Controller_Front_DispatchLoopStartup event.
  *
  * @param \Enlight_Controller_EventArgs $args
  */
 public function onDispatchLoopStartup(Enlight_Controller_EventArgs $args)
 {
     $this->request = $args->getSubject()->Request();
     $this->response = $args->getSubject()->Response();
     if ($this->request->getModuleName() != 'api') {
         return;
     }
     $this->isApiCall = true;
     $router = new \ShopwarePlugins\RestApi\Components\Router();
     $router->assembleRoute($this->request, $this->response);
 }
 /**
  * @param \Enlight_Controller_Request_Request $request
  * @return bool
  */
 public function isRequestAllowed(\Enlight_Controller_Request_Request $request)
 {
     $clientIp = $request->getClientIp();
     $allowedIp = $this->config->get('AllowIP');
     if (empty($allowedIp)) {
         return true;
     }
     if (empty($clientIp)) {
         return false;
     }
     return strpos($allowedIp, $clientIp) !== false;
 }
 /**
  * @param Request $request
  */
 public function onStripeToken($request)
 {
     $token = $request->getPost('stripeToken');
     $db = $this->bootstrap->get('db');
     if ($request->getPost('stripeCreateAccount')) {
         $sql = 'SELECT firstname, lastname, customernumber FROM s_user_billingaddress WHERE userID = ?';
         $customer = $db->fetchRow($sql, array($this->session->sUserId));
         $customer = \Stripe\Customer::create(array("source" => $token, "email" => $this->session->sUserMail, "description" => implode(' ', $customer)));
         $customerId = $customer->id;
         unset($this->session->stripeToken);
     } else {
         $this->session->stripeToken = $token;
         $customerId = null;
     }
     $db->update('s_user_attributes', array('viison_stripe_customer_id' => $customerId), array('userID =' . (int) $this->session->sUserId));
 }
Exemple #6
0
 /**
  * Filters and transforms the session options array
  * so it complies with the format expected by Enlight_Components_Session
  *
  * @param array $options
  * @return array
  */
 private function prepareSessionOptions($options)
 {
     if (!isset($options['cookie_path']) && $this->request !== null) {
         $options['cookie_path'] = rtrim($this->request->getBaseUrl(), '/') . '/backend/';
     }
     if (empty($options['gc_maxlifetime'])) {
         $backendTimeout = $this->Config()->get('backendTimeout', 60 * 90);
         $options['gc_maxlifetime'] = (int) $backendTimeout;
     }
     unset($options['referer_check']);
     unset($options['client_check']);
     return $options;
 }
 /**
  * @param \Enlight_Controller_Request_Request $request
  */
 public function __construct(\Enlight_Controller_Request_Request $request)
 {
     $params = $request->getParams();
     $ids = array();
     foreach ($params as $paramName => $paramValue) {
         if (strpos($paramName, self::PARAM_NAME) !== 0) {
             continue;
         }
         $parts = explode('_', $paramName);
         if (count($parts) !== 3) {
             $ids = explode('|', $paramValue);
             break;
         }
         $ids[$parts[2]] = explode('|', $paramValue);
     }
     if (!$ids) {
         return;
     }
     if (!$request->has(self::PARAM_NAME)) {
         $this->isGrouped = true;
     }
     $this->requestedVariantIds = $ids;
 }
Exemple #8
0
 /**
  * Secure cron actions according to system settings
  *
  * @param Enlight_Controller_Request_Request $request
  * @return bool If cron action is authorized
  */
 public function authorizeCronAction($request)
 {
     // If called using CLI, always execute the cron tasks
     if (php_sapi_name() == 'cli') {
         return true;
     }
     // At least one of the security policies is enabled.
     // If at least one of them validates, cron tasks will be executed
     $cronSecureAllowedKey = Shopware()->Config()->get('cronSecureAllowedKey');
     $cronSecureAllowedIp = Shopware()->Config()->get('cronSecureAllowedIp');
     $cronSecureByAccount = Shopware()->Config()->get('cronSecureByAccount');
     // No security policy specified, accept all requests
     if (empty($cronSecureAllowedKey) && empty($cronSecureAllowedIp) && !$cronSecureByAccount) {
         return true;
     }
     // Validate key
     if (!empty($cronSecureAllowedKey)) {
         $urlKey = $request->getParam('key');
         if (strcmp($cronSecureAllowedKey, $urlKey) == 0) {
             return true;
         }
     }
     // Validate ip
     if (!empty($cronSecureAllowedIp)) {
         $requestIp = $request->getServer('REMOTE_ADDR');
         if (in_array($requestIp, explode(';', $cronSecureAllowedIp))) {
             return true;
         }
     }
     // Validate user auth
     if ($cronSecureByAccount) {
         if (Shopware()->Auth()->hasIdentity() === true) {
             return true;
         }
     }
     return false;
 }
 /**
  * @param Request $request
  * @param ShopContextInterface $context
  * @return Criteria
  */
 private function getSearchCriteria(Request $request, ShopContextInterface $context)
 {
     if (!$request->has('sSort')) {
         $request->setParam('sSort', StoreFrontCriteriaFactory::SORTING_SEARCH_RANKING);
     }
     $criteria = $this->createCriteriaFromRequest($request, $context);
     if (!$criteria->hasCondition('category')) {
         $categoryId = $context->getShop()->getCategory()->getId();
         $criteria->addBaseCondition(new CategoryCondition([$categoryId]));
     }
     return $criteria;
 }
Exemple #10
0
 /**
  * The handle error function checks for an exception and
  * allows the error handler controller the option to forward
  *
  * @param Enlight_Controller_Front $front
  * @param Enlight_Controller_Request_Request $request
  * @return mixed
  * @throws mixed
  */
 protected function handleError($front, Enlight_Controller_Request_Request $request)
 {
     if ($front->getParam('noErrorHandler')) {
         return;
     }
     $response = $front->Response();
     if ($this->_isInsideErrorHandlerLoop) {
         $exceptions = $response->getException();
         if (count($exceptions) > $this->_exceptionCountAtFirstEncounter) {
             // Exception thrown by error handler; tell the front controller to throw it
             $front->throwExceptions(true);
             throw array_pop($exceptions);
         }
     }
     // check for an exception AND allow the error handler controller the option to forward
     if ($response->isException() && !$this->_isInsideErrorHandlerLoop) {
         $this->_isInsideErrorHandlerLoop = true;
         // Get exception information
         $error = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
         $exceptions = $response->getException();
         $exception = $exceptions[0];
         $error->exception = $exception;
         // Keep a copy of the original request
         $error->request = clone $request;
         // get a count of the number of exceptions encountered
         $this->_exceptionCountAtFirstEncounter = count($exceptions);
         // Forward to the error handler
         $request->setParam('error_handler', $error)->setControllerName('error')->setActionName('error')->setDispatched(false);
     }
 }
 /**
  * Returns default image columns name
  *
  * @return array
  */
 public function getDefaultColumns()
 {
     $path = $this->request->getScheme() . '://' . $this->request->getHttpHost() . $this->request->getBasePath() . '/media/image/';
     $columns = ['mv.number as ordernumber', "CONCAT('{$path}', aimage.path, '.', aimage.extension) as image", 'aimage.main as main', 'aimage.description as description', 'aimage.position as position', 'aimage.width as width', 'aimage.height as height', "GroupConcat( im.id, '|', mr.optionId, '|' , co.name, '|', cg.name\n            ORDER by im.id\n            SEPARATOR ';' ) as relations", ' \'1\' as thumbnail'];
     return $columns;
 }
 /**
  * @param Request $request
  * @return bool
  */
 public function acceptsRequest(Request $request)
 {
     $firePhpVersion = $request->getHeader('X-FirePHP-Version');
     $userAgent = preg_match('{\\bFirePHP/\\d+\\.\\d+\\b}', $request->getHeader('User-Agent'));
     return $firePhpVersion || $userAgent;
 }
 /**
  * @param \Enlight_Controller_Request_Request $request
  * @return array
  */
 private function getCategoryConfig(\Enlight_Controller_Request_Request $request)
 {
     return array('sSort' => $request->getParam('sSort', 0), 'sPage' => $request->getParam('sPage', 1), 'sTemplate' => $request->getParam('sTemplate', null), 'sPerPage' => $request->getParam('sPerPage', (int) $this->get('config')->get('articlesPerPage')), 'sSupplier' => $request->getParam('sSupplier', null), 'priceMin' => $request->getParam('priceMin', null), 'priceMax' => $request->getParam('priceMax', null), 'shippingFree' => $request->getParam('shippingFree', false), 'sFilterProperties' => $request->getParam('sFilterProperties', array()), 'immediateDelivery' => $request->getParam('immediateDelivery', false));
 }
Exemple #14
0
 /**
  * Returns a listing of products. Used for the backward compatibility category listings.
  * This function calls the new shopware core and converts the result to the old listing structure.
  *
  * @param $categoryId
  * @param StoreFrontBundle\Struct\ProductContextInterface $context
  * @param Enlight_Controller_Request_Request $request
  * @param SearchBundle\Criteria $criteria
  * @return array
  */
 private function getListing($categoryId, StoreFrontBundle\Struct\ProductContextInterface $context, Enlight_Controller_Request_Request $request, SearchBundle\Criteria $criteria)
 {
     $searchResult = $this->searchService->search($criteria, $context);
     $articles = array();
     /**@var $product StoreFrontBundle\Struct\ListProduct */
     foreach ($searchResult->getProducts() as $product) {
         $article = $this->legacyStructConverter->convertListProductStruct($product);
         if (!empty($categoryId) && $categoryId != $context->getShop()->getCategory()->getId()) {
             $article["linkDetails"] .= "&sCategory={$categoryId}";
         }
         if (isset($article['sVoteAverange']) && !empty($article['sVoteAverange'])) {
             // the listing pages use a 0 - 5 based average
             $article['sVoteAverange']['averange'] = $article['sVoteAverange']['averange'] / 2;
         }
         if ($this->config->get('useShortDescriptionInListing') && strlen($article['description']) > 5) {
             $article["description_long"] = $article['description'];
         }
         $article['description_long'] = $this->sOptimizeText($article['description_long']);
         $articles[$article['ordernumber']] = $article;
     }
     $pageSizes = explode("|", $this->config->get('numberArticlesToShow'));
     return array('sArticles' => $articles, 'criteria' => $criteria, 'facets' => $searchResult->getFacets(), 'sPage' => $request->getParam('sPage', 1), 'pageSizes' => $pageSizes, 'sPerPage' => $criteria->getLimit(), 'sNumberArticles' => $searchResult->getTotalCount(), 'shortParameters' => $this->queryAliasMapper->getQueryAliases(), 'sTemplate' => $request->getParam('sTemplate'), 'sSort' => $request->getParam('sSort', $this->config->get('defaultListingSorting')));
 }
 /**
  * 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');
 }
Exemple #16
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());
         }
     }
 }
Exemple #17
0
 /**
  * Returns an array with all current values in _POST
  *
  * @return array
  */
 public function toArray()
 {
     return $this->request->getPost();
 }
Exemple #18
0
 /**
  * @param $basket
  * @param Request $request
  * @return array
  * @throws Exception
  */
 private function getInvalidAgreements($basket, Request $request)
 {
     $errors = [];
     if (!$this->container->get('config')->get('IgnoreAGB') && !$this->Request()->getParam('sAGB')) {
         $errors['agbError'] = true;
     }
     $esdAgreement = $request->getParam('esdAgreementChecked');
     if ($this->container->get('config')->get('showEsdWarning') && $this->basketHasEsdArticles($basket) && empty($esdAgreement)) {
         $errors['esdError'] = true;
     }
     $serviceChecked = $request->getParam('serviceAgreementChecked');
     if ($this->basketHasServiceArticles($basket) && empty($serviceChecked)) {
         $errors['serviceError'] = true;
     }
     return $errors;
 }
 /**
  * Helper function to get all preferred browser languages
  *
  * @param Enlight_Controller_Request_Request $request
  * @return array|mixed
  */
 private function getBrowserLanguages(Enlight_Controller_Request_Request $request)
 {
     $languages = $request->getServer('HTTP_ACCEPT_LANGUAGE');
     $languages = str_replace('-', '_', $languages);
     if (strpos($languages, ',') == true) {
         $languages = explode(',', $languages);
     } else {
         $languages = (array) $languages;
     }
     foreach ($languages as $key => $language) {
         $language = explode(';', $language);
         $languages[$key] = $language[0];
     }
     return (array) $languages;
 }
Exemple #20
0
 /**
  * Returns an array with all current values in _COOKIE
  *
  * @return array
  */
 public function toArray()
 {
     return $this->request->getCookie();
 }
 /**
  * helper method to call the getActiveByRequest Method with different params
  *
  * @param \Enlight_Controller_Request_Request $request
  * @param \Shopware\Models\Shop\Repository $repository
  * @param $url
  * @param $shopName
  * @param bool $secure
  * @internal param $mainShop
  */
 public function callGetActiveShopByRequest(Enlight_Controller_Request_Request $request, \Shopware\Models\Shop\Repository $repository, $url, $shopName, $secure = false)
 {
     $request->setRequestUri($url);
     $request->setSecure($secure);
     $shop = $repository->getActiveByRequest($request);
     $this->assertNotNull($shop);
     $this->assertEquals($shopName, $shop->getName());
 }
 /**
  * The handle error function checks for an exception and
  * allows the error handler controller the option to forward
  *
  * @param Enlight_Controller_Front $front
  * @param Enlight_Controller_Request_Request $request
  * @return mixed
  * @throws mixed
  */
 protected function handleError($front, Enlight_Controller_Request_Request $request)
 {
     if ($front->getParam('noErrorHandler')) {
         return;
     }
     $response = $front->Response();
     if ($this->_isInsideErrorHandlerLoop) {
         $exceptions = $response->getException();
         if (count($exceptions) > $this->_exceptionCountAtFirstEncounter) {
             // Exception thrown by error handler; tell the front controller to throw it
             $front->throwExceptions(true);
             throw array_pop($exceptions);
         }
     }
     // check for an exception AND allow the error handler controller the option to forward
     if ($response->isException() && !$this->_isInsideErrorHandlerLoop) {
         $this->_isInsideErrorHandlerLoop = true;
         // Get exception information
         $error = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
         $exceptions = $response->getException();
         $exception = $exceptions[0];
         $error->exception = $exception;
         switch (true) {
             case $exception instanceof Zend_Controller_Router_Exception:
                 if (404 == $exception->getCode()) {
                     $error->type = self::EXCEPTION_NO_ROUTE;
                 } else {
                     $error->type = self::EXCEPTION_OTHER;
                 }
                 break;
             case $exception instanceof Zend_Controller_Dispatcher_Exception:
                 $error->type = self::EXCEPTION_NO_CONTROLLER;
                 break;
             case $exception instanceof Zend_Controller_Action_Exception:
                 if (404 == $exception->getCode()) {
                     $error->type = self::EXCEPTION_NO_ACTION;
                 } else {
                     $error->type = self::EXCEPTION_OTHER;
                 }
                 break;
             default:
                 $error->type = self::EXCEPTION_OTHER;
                 break;
         }
         // Keep a copy of the original request
         $error->request = clone $request;
         // get a count of the number of exceptions encountered
         $this->_exceptionCountAtFirstEncounter = count($exceptions);
         // Forward to the error handler
         $request->setParam('error_handler', $error)->setControllerName('error')->setActionName('error')->setDispatched(false);
         //->setModuleName($this->getErrorHandlerModule())
         //->setControllerName($this->getErrorHandlerController())
         //->setActionName($this->getErrorHandlerAction())
     }
 }
Exemple #23
0
 /**
  * @param \Enlight_Controller_Request_Request $request
  * @return \Shopware\Models\Shop\Shop
  */
 public function getActiveByRequest($request)
 {
     /** @var $shop \Shopware\Models\Shop\Shop */
     $shop = null;
     $host = $request->getHttpHost();
     if (empty($host)) {
         return $shop;
     }
     $requestPath = $request->getRequestUri();
     $builder = $this->getActiveQueryBuilder();
     $builder->andWhere("shop.host=:host OR (shop.host IS NULL AND main.host=:host)");
     if ($request->isSecure()) {
         $builder->orWhere("shop.secureHost=:host OR (shop.secureHost IS NULL AND main.secureHost=:host)");
     }
     $builder->setParameter('host', $host);
     /** @var $shops \Shopware\Models\Shop\Shop[] */
     $shops = $builder->getQuery()->getResult();
     foreach ($shops as $currentShop) {
         $this->fixActive($currentShop);
     }
     //returns the right shop depending on the url
     $shop = $this->getShopByRequest($shops, $requestPath);
     if ($shop !== null) {
         return $shop;
     }
     $builder = $this->getActiveQueryBuilder();
     $builder->andWhere('shop.hosts LIKE :host1 OR shop.hosts LIKE :host2 OR shop.hosts LIKE :host3')->setParameter('host1', "%\n" . $host . "\n%")->setParameter('host2', $host . "\n%")->setParameter('host3', "%\n" . $host);
     $shop = $builder->getQuery()->getOneOrNullResult();
     if ($shop !== null) {
         $this->fixActive($shop);
     }
     return $shop;
 }
 /**
  * @param Request $request
  * @return bool
  */
 public function acceptsRequest(Request $request)
 {
     return (bool) preg_match('{\\bChrome/\\d+[\\.\\d+]*\\b}', $request->getHeader('User-Agent'));
 }
Exemple #25
0
 /**
  * @param Request $request
  * @param Shop $shop
  * @return bool
  */
 protected function shouldRedirect(Request $request, Shop $shop)
 {
     return $request->isGet() && $request->getQuery('__shop') !== null && $request->getQuery('__shop') != $shop->getId() || $request->isPost() && $request->getPost('__shop') !== null && $request->getPost('__redirect') !== null;
 }
Exemple #26
0
 /**
  * Returns the full path of the action name.
  * To generate the full action path the module, controller and action name must be set in the given request object.
  * The module, controller and action path is imploded by '_'.
  *
  * @param Enlight_Controller_Request_Request $request
  * @return string
  */
 public function getFullActionName(Enlight_Controller_Request_Request $request)
 {
     $parts = array($this->formatModuleName($request->getModuleName()), $this->formatControllerName($request->getControllerName()), $this->formatActionName($request->getActionName()));
     return implode('_', $parts);
 }
Exemple #27
0
 public function assembleRoute(Request $request, Response $response)
 {
     $path = $request->getPathInfo();
     $path = explode('/', trim($path, '/'));
     $path = array_pad($path, 7, null);
     array_shift($path);
     $tmp = array_shift($path);
     $matches = array();
     if (preg_match('/^v([1-9])$/', $tmp, $matches) === 1) {
         $version = (int) $matches[1];
         $type = array_shift($path);
     } else {
         $version = 1;
         $type = $tmp;
     }
     $id = !empty($path[0]) ? $path[0] : false;
     $subType = !empty($path[1]) ? $path[1] : false;
     $subId = !empty($path[2]) ? $path[2] : false;
     $request->setControllerName($type);
     $request->setParam('id', $id);
     $request->setParam('subId', $subId);
     $request->setParam('version', $version);
     $method = strtoupper($request->getParam('_method', $request->getMethod()));
     $action = 'invalid';
     if ($method === 'GET' && $id === false) {
         $action = 'index';
         $response->setHttpResponseCode(200);
     } elseif ($method === 'GET') {
         $action = 'get';
         $response->setHttpResponseCode(200);
     } elseif ($method === 'PUT' && $id === false) {
         $action = 'batch';
         $response->setHttpResponseCode(200);
     } elseif ($method === 'PUT') {
         $action = 'put';
     } elseif ($method === 'POST') {
         $action = 'post';
         // Set default http status code for successfull request
         $response->setHttpResponseCode(201);
     } elseif ($method === 'DELETE' && $id === false) {
         $action = 'batchDelete';
         $response->setHttpResponseCode(200);
     } elseif ($method === 'DELETE') {
         $response->setHttpResponseCode(200);
         $action = 'delete';
     }
     if ($action == 'invalid') {
         $request->setControllerName('index');
         $request->setActionName($action);
         return;
     }
     if (!$subType) {
         $request->setActionName($action);
         return;
     }
     if ($action == 'get' && $subId === false) {
         $subAction = $subType . 'Index';
     } else {
         $subAction = $subType;
     }
     $action = $action . ucfirst($subAction);
     $request->setActionName($action);
 }
Exemple #28
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;
         }
     }
 }
 /**
  * @inheritdoc
  */
 public function savePaymentData($userId, \Enlight_Controller_Request_Request $request)
 {
     $lastPayment = $this->getCurrentPaymentDataAsArray($userId);
     $paymentMean = Shopware()->Models()->getRepository('\\Shopware\\Models\\Payment\\Payment')->getPaymentsQuery(array('name' => 'Sepa'))->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY);
     $data = array('use_billing_data' => $request->getParam("sSepaUseBillingData") === 'true' ? 1 : 0, 'bankname' => $request->getParam("sSepaBankName"), 'iban' => preg_replace('/\\s+|\\./', '', $request->getParam("sSepaIban")), 'bic' => $request->getParam("sSepaBic"));
     if (!$lastPayment) {
         $date = new \DateTime();
         $data['created_at'] = $date->format('Y-m-d');
         $data['payment_mean_id'] = $paymentMean['id'];
         $data['user_id'] = $userId;
         Shopware()->Db()->insert("s_core_payment_data", $data);
     } else {
         $where = array('payment_mean_id = ?' => $paymentMean['id'], 'user_id = ?' => $userId);
         Shopware()->Db()->update("s_core_payment_data", $data, $where);
     }
 }