コード例 #1
0
ファイル: Standard.php プロジェクト: aimeos/ai-client-html
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     $context = $this->getContext();
     $userId = $context->getUserId();
     $ids = (array) $view->param('wat_id', array());
     if ($userId != null && !empty($ids)) {
         $typeId = $this->getTypeItem('customer/lists/type', 'product', 'watch')->getId();
         $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists');
         $items = $this->getListItems($manager, $ids, $typeId, $userId);
         switch ($view->param('wat_action')) {
             case 'add':
                 /** client/html/account/watch/standard/maxitems
                  * Maximum number of products that can be watched in parallel
                  *
                  * This option limits the number of products that can be watched
                  * after the users added the products to their watch list.
                  * It must be a positive integer value greater than 0.
                  *
                  * Note: It's recommended to set this value not too high as this
                  * leads to a high memory consumption when the e-mails are generated
                  * to notify the customers. The memory used will up to 100*maxitems
                  * of the footprint of one product item including the associated
                  * texts, prices and media.
                  *
                  * @param integer Number of products
                  * @since 2014.09
                  * @category User
                  * @category Developer
                  */
                 $max = $context->getConfig()->get('client/html/account/watch/standard/maxitems', 100);
                 $cnt = count($ids);
                 if ($this->checkLimit($manager, $typeId, $userId, $max, $cnt) === false) {
                     $error = sprintf($context->getI18n()->dt('client', 'You can only watch up to %1$s products'), $max);
                     $view->watchErrorList = $view->get('watchErrorList', array()) + array($error);
                     break;
                 }
                 $this->addItems($manager, $items, $ids, $typeId, $userId);
                 break;
             case 'edit':
                 $config = array('timeframe' => $view->param('wat_timeframe', 7), 'pricevalue' => $view->param('wat_pricevalue', '0.00'), 'price' => $view->param('wat_price', 0), 'stock' => $view->param('wat_stock', 0), 'currency' => $context->getLocale()->getCurrencyId());
                 $this->editItems($manager, $items, $ids, $config);
                 break;
             case 'delete':
                 $this->deleteItems($manager, $items, $ids);
                 break;
         }
     }
     parent::process();
 }
コード例 #2
0
ファイル: Standard.php プロジェクト: boettner-it/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $refresh = false;
     $view = $this->getView();
     $context = $this->getContext();
     $session = $context->getSession();
     $pinned = $session->get('aimeos/catalog/session/pinned/list', array());
     switch ($view->param('pin_action')) {
         case 'add':
             foreach ((array) $view->param('pin_id', array()) as $id) {
                 $pinned[$id] = $id;
             }
             /** client/html/catalog/session/pinned/standard/maxitems
              * Maximum number of products displayed in the "pinned" section
              *
              * This option limits the number of products that are shown in the
              * "pinned" section after the users added the product to their list
              * of pinned products. It must be a positive integer value greater
              * than 0.
              *
              * Note: The higher the value is the more data has to be transfered
              * to the client each time the user loads a page with the list of
              * pinned products.
              *
              * @param integer Number of products
              * @since 2014.09
              * @category User
              * @category Developer
              */
             $max = $context->getConfig()->get('client/html/catalog/session/pinned/standard/maxitems', 50);
             $pinned = array_slice($pinned, -$max, $max, true);
             $refresh = true;
             break;
         case 'delete':
             foreach ((array) $view->param('pin_id', array()) as $id) {
                 unset($pinned[$id]);
             }
             $refresh = true;
             break;
     }
     if ($refresh) {
         $session->set('aimeos/catalog/session/pinned/list', $pinned);
         foreach ($session->get('aimeos/catalog/session/pinned/cache', array()) as $key => $value) {
             $session->set($key, null);
         }
     }
     parent::process();
 }
コード例 #3
0
ファイル: Standard.php プロジェクト: boettner-it/aimeos-core
 /**
  * Processes the input, e.g. store given order.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     if (!in_array($view->param('c_step'), array('order', 'process'))) {
         return;
     }
     $context = $this->getContext();
     $session = $context->getSession();
     $orderid = $session->get('aimeos/orderid');
     $config = array('absoluteUri' => true, 'namespace' => false);
     try {
         $orderItem = \Aimeos\MShop\Factory::createManager($context, 'order')->getItem($orderid);
         if (($code = $this->getOrderServiceCode($orderItem->getBaseId())) !== null) {
             $serviceItem = $this->getServiceItem($code);
             $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service');
             $provider = $serviceManager->getProvider($serviceItem);
             $params = array('code' => $serviceItem->getCode(), 'orderid' => $orderid);
             $urls = array('payment.url-self' => $this->getUrlSelf($view, $params + array('c_step' => 'process'), array()), 'payment.url-success' => $this->getUrlConfirm($view, $params, $config), 'payment.url-update' => $this->getUrlUpdate($view, $params, $config), 'client.ipaddress' => $view->request()->getClientAddress());
             $provider->injectGlobalConfigBE($urls);
             if (($form = $provider->process($orderItem, $view->param())) === null) {
                 $msg = sprintf('Invalid process response from service provider with code "%1$s"', $serviceItem->getCode());
                 throw new \Aimeos\Client\Html\Exception($msg);
             }
             $view->standardUrlNext = $form->getUrl();
             $view->standardMethod = $form->getMethod();
             $view->standardProcessParams = $form->getValues();
             $view->standardUrlExternal = $form->getExternal();
         } else {
             $view->standardUrlNext = $this->getUrlConfirm($view, array(), array());
             $view->standardMethod = 'GET';
         }
         parent::process();
     } catch (\Aimeos\Client\Html\Exception $e) {
         $error = array($context->getI18n()->dt('client/html', $e->getMessage()));
         $view->standardErrorList = $view->get('standardErrorList', array()) + $error;
     } catch (\Aimeos\Controller\Frontend\Exception $e) {
         $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage()));
         $view->standardErrorList = $view->get('standardErrorList', array()) + $error;
     } catch (\Aimeos\MShop\Exception $e) {
         $error = array($context->getI18n()->dt('mshop', $e->getMessage()));
         $view->standardErrorList = $view->get('standardErrorList', array()) + $error;
     } catch (\Exception $e) {
         $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString());
         $error = array($context->getI18n()->dt('client/html', 'A non-recoverable error occured'));
         $view->standardErrorList = $view->get('standardErrorList', array()) + $error;
     }
     $view->standardUrlPayment = $this->getUrlSelf($view, array('c_step' => 'payment'), array());
 }
コード例 #4
0
ファイル: Standard.php プロジェクト: boettner-it/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $context = $this->getContext();
     $view = $this->getView();
     try {
         parent::process();
     } catch (\Aimeos\MShop\Exception $e) {
         $error = array($context->getI18n()->dt('mshop', $e->getMessage()));
         $view->filterErrorList = $view->get('filterErrorList', array()) + $error;
     } catch (\Aimeos\Controller\Frontend\Exception $e) {
         $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage()));
         $view->filterErrorList = $view->get('filterErrorList', array()) + $error;
     } catch (\Aimeos\Client\Html\Exception $e) {
         $error = array($context->getI18n()->dt('client/html', $e->getMessage()));
         $view->filterErrorList = $view->get('filterErrorList', array()) + $error;
     } catch (\Exception $e) {
         $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString());
         $error = array($context->getI18n()->dt('client/html', 'A non-recoverable error occured'));
         $view->filterErrorList = $view->get('filterErrorList', array()) + $error;
     }
 }
コード例 #5
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Stores the given or fetched billing address in the basket.
  */
 public function process()
 {
     $view = $this->getView();
     try {
         // only start if there's something to do
         if ($view->param('ca_billingoption', null) === null) {
             return;
         }
         $context = $this->getContext();
         $basketCtrl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
         /** client/html/checkout/standard/address/billing/disable-new
          * Disables the option to enter a new billing address for an order
          *
          * Besides the main billing address, customers can usually enter a new
          * billing address as well. To suppress displaying the form fields for
          * a billing address, you can set this configuration option to "1".
          *
          * Until 2015-02, the configuration option was available as
          * "client/html/common/address/billing/disable-new" starting from 2014-03.
          *
          * @param boolean A value of "1" to disable, "0" enables the billing address form
          * @since 2015.02
          * @category User
          * @category Developer
          * @see client/html/checkout/standard/address/billing/salutations
          * @see client/html/checkout/standard/address/billing/mandatory
          * @see client/html/checkout/standard/address/billing/optional
          * @see client/html/checkout/standard/address/billing/hidden
          */
         $disable = $view->config('client/html/checkout/standard/address/billing/disable-new', false);
         $type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
         if (($option = $view->param('ca_billingoption', 'null')) === 'null' && $disable === false) {
             $params = $view->param('ca_billing', array());
             $invalid = $this->checkFields($params);
             if (count($invalid) > 0) {
                 $view->billingError = $invalid;
                 throw new \Aimeos\Client\Html\Exception(sprintf('At least one billing address part is missing or invalid'));
             }
             $basketCtrl->setAddress($type, $params);
         } else {
             $customerManager = \Aimeos\MShop\Factory::createManager($context, 'customer');
             $search = $customerManager->createSearch(true);
             $expr = array($search->compare('==', 'customer.id', $option), $search->getConditions());
             $search->setConditions($search->combine('&&', $expr));
             $items = $customerManager->searchItems($search);
             if (($item = reset($items)) === false || $option != $context->getUserId()) {
                 throw new \Aimeos\Client\Html\Exception(sprintf('Customer with ID "%1$s" not found', $option));
             }
             $invalid = array();
             $addr = $item->getPaymentAddress();
             $params = $view->param('ca_billing_' . $option, array());
             if (!empty($params)) {
                 $list = array();
                 $invalid = $this->checkFields($params);
                 foreach ($params as $key => $value) {
                     $list[str_replace('order.base', 'customer', $key)] = $value;
                 }
                 $addr->fromArray($list);
                 $item->setPaymentAddress($addr);
                 $customerManager->saveItem($item);
             }
             if (count($invalid) > 0) {
                 $view->billingError = $invalid;
                 throw new \Aimeos\Client\Html\Exception(sprintf('At least one billing address part is missing or invalid'));
             }
             $basketCtrl->setAddress($type, $addr);
         }
         parent::process();
     } catch (\Aimeos\Controller\Frontend\Exception $e) {
         $view->billingError = $e->getErrorList();
         throw $e;
     }
 }
コード例 #6
0
ファイル: Standard.php プロジェクト: boettner-it/aimeos-core
 /**
  * Processes the input, e.g. store given order.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     try {
         // only start if there's something to do
         if (($option = $view->param('cs_order', null)) === null || $view->get('standardStepActive') !== null) {
             return;
         }
         $context = $this->getContext();
         $orderBaseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
         $basket = $orderBaseManager->getSession();
         $basket->setCustomerId($context->getUserId());
         $basket->finish();
         $cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'order');
         $orderItem = $cntl->store($basket);
         $cntl->block($orderItem);
         $context->getSession()->set('aimeos/orderid', $orderItem->getId());
         $view->orderItem = $orderItem;
         $view->orderBasket = $basket;
         parent::process();
         // save again after sub-clients modified it's state
         \Aimeos\MShop\Factory::createManager($context, 'order')->saveItem($orderItem);
     } catch (\Exception $e) {
         $view->standardStepActive = 'order';
         throw $e;
     }
 }
コード例 #7
0
ファイル: Standard.php プロジェクト: aimeos/ai-client-html
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     $context = $this->getContext();
     $userId = $context->getUserId();
     $ids = (array) $view->param('fav_id', array());
     try {
         if ($userId != null && !empty($ids)) {
             switch ($view->param('fav_action')) {
                 case 'add':
                     $this->addFavorites($ids, $userId);
                     break;
                 case 'delete':
                     $this->deleteFavorites($ids, $userId);
                     break;
             }
         }
         parent::process();
     } catch (\Aimeos\MShop\Exception $e) {
         $error = array($context->getI18n()->dt('mshop', $e->getMessage()));
         $view->favoriteErrorList = $view->get('favoriteErrorList', array()) + $error;
     } catch (\Aimeos\Controller\Frontend\Exception $e) {
         $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage()));
         $view->favoriteErrorList = $view->get('favoriteErrorList', array()) + $error;
     } catch (\Aimeos\Client\Html\Exception $e) {
         $error = array($context->getI18n()->dt('client', $e->getMessage()));
         $view->favoriteErrorList = $view->get('favoriteErrorList', array()) + $error;
     } catch (\Exception $e) {
         $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString());
         $error = array($context->getI18n()->dt('client', 'A non-recoverable error occured'));
         $view->favoriteErrorList = $view->get('favoriteErrorList', array()) + $error;
     }
 }
コード例 #8
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     $context = $this->getContext();
     $ids = $view->param('wat_id', array());
     if ($context->getUserId() != null && !empty($ids)) {
         $typeItem = $this->getTypeItem('customer/lists/type', 'product', 'watch');
         $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists');
         $search = $manager->createSearch();
         $expr = array($search->compare('==', 'customer.lists.parentid', $context->getUserId()), $search->compare('==', 'customer.lists.refid', $ids), $search->compare('==', 'customer.lists.domain', 'product'), $search->compare('==', 'customer.lists.typeid', $typeItem->getId()));
         $search->setConditions($search->combine('&&', $expr));
         $items = array();
         foreach ($manager->searchItems($search) as $item) {
             $items[$item->getRefId()] = $item;
         }
         switch ($view->param('wat_action')) {
             case 'add':
                 $search = $manager->createSearch();
                 $expr = array($search->compare('==', 'customer.lists.parentid', $context->getUserId()), $search->compare('==', 'customer.lists.typeid', $typeItem->getId()), $search->compare('==', 'customer.lists.domain', 'product'));
                 $search->setConditions($search->combine('&&', $expr));
                 $search->setSlice(0, 0);
                 $total = 0;
                 $manager->searchItems($search, array(), $total);
                 /** client/html/account/watch/standard/maxitems
                  * Maximum number of products that can be watched in parallel
                  *
                  * This option limits the number of products that can be watched
                  * after the users added the products to their watch list.
                  * It must be a positive integer value greater than 0.
                  *
                  * Note: It's recommended to set this value not too high as this
                  * leads to a high memory consumption when the e-mails are generated
                  * to notify the customers. The memory used will up to 100*maxitems
                  * of the footprint of one product item including the associated
                  * texts, prices and media.
                  *
                  * @param integer Number of products
                  * @since 2014.09
                  * @category User
                  * @category Developer
                  */
                 $max = $context->getConfig()->get('client/html/account/watch/standard/maxitems', 100);
                 $item = $manager->createItem();
                 $item->setParentId($context->getUserId());
                 $item->setTypeId($typeItem->getId());
                 $item->setDomain('product');
                 $item->setStatus(1);
                 foreach ((array) $view->param('wat_id', array()) as $id) {
                     if ($total >= $max) {
                         $error = array(sprintf($context->getI18n()->dt('client', 'You can only watch up to %1$s products'), $max));
                         $view->watchErrorList = $view->get('watchErrorList', array()) + $error;
                         break;
                     }
                     if (!isset($items[$id])) {
                         $item->setId(null);
                         $item->setRefId($id);
                         $manager->saveItem($item);
                         $manager->moveItem($item->getId());
                         $total++;
                     }
                 }
                 break;
             case 'edit':
                 foreach ((array) $view->param('wat_id', array()) as $id) {
                     if (isset($items[$id])) {
                         $item = $items[$id];
                         $config = array('timeframe' => $view->param('wat_timeframe', 7), 'pricevalue' => $view->param('wat_pricevalue', '0.00'), 'price' => $view->param('wat_price', 0), 'stock' => $view->param('wat_stock', 0), 'currency' => $context->getLocale()->getCurrencyId());
                         $time = time() + ($config['timeframe'] + 1) * 86400;
                         $item->setDateEnd(date('Y-m-d 00:00:00', $time));
                         $item->setConfig($config);
                         $manager->saveItem($item);
                     }
                 }
                 break;
             case 'delete':
                 $listIds = array();
                 foreach ((array) $view->param('wat_id', array()) as $id) {
                     if (isset($items[$id])) {
                         $listIds[] = $items[$id]->getId();
                     }
                 }
                 $manager->deleteItems($listIds);
                 break;
         }
     }
     parent::process();
 }
コード例 #9
0
ファイル: Standard.php プロジェクト: boettner-it/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     $context = $this->getContext();
     try {
         $provider = $this->getServiceProvider($view->param('code'));
         $config = array('absoluteUri' => true, 'namespace' => false);
         $params = array('code' => $view->param('code'), 'orderid' => $view->param('orderid'));
         $urls = array('payment.url-success' => $this->getUrlConfirm($view, $params, $config), 'payment.url-update' => $this->getUrlUpdate($view, $params, $config));
         $urls['payment.url-self'] = $urls['payment.url-update'];
         $provider->injectGlobalConfigBE($urls);
         $response = null;
         $headers = array();
         try {
             $body = $view->request()->getBody();
             if (($orderItem = $provider->updateSync($view->param(), $body, $response, $headers)) !== null) {
                 \Aimeos\Controller\Frontend\Factory::createController($context, 'order')->update($orderItem);
                 // stock, coupons
             }
             $view->updateMessage = $response;
         } catch (\Aimeos\MShop\Service\Exception $e) {
             $view->updateMessage = $e->getMessage();
         }
         if (!empty($headers)) {
             $view->updateHttpHeaders = $headers;
         }
         parent::process();
     } catch (\Exception $e) {
         /** client/html/checkout/standard/update/http-error
          * HTTP header sent for failed attempts to update the order status
          *
          * This HTTP header is returned to the remote system if the status
          * update failed due to an error in the application. This header is
          * not sent if e.g. a payment was refused by the payment gateway!
          * It should be one of the 5xx HTTP headers.
          *
          * @param array List of valid HTTP headers
          * @since 2015.07
          * @category Developer
          * @see client/html/checkout/standard/update/http-success
          */
         $default = array('HTTP/1.1 500 Error updating order status');
         $headerList = $context->getConfig()->get('client/html/checkout/standard/update/http-error', $default);
         $view->updateHttpHeaders = $headerList;
         $view->updateMessage = $e->getMessage();
         $body = $view->request()->getBody();
         $params = print_r($view->param(), true);
         $msg = "Updating order status failed: %1\$s\n%2\$s\n%3\$s";
         $context->getLogger()->log(sprintf($msg, $e->getMessage(), $params, $body));
     }
 }
コード例 #10
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     $context = $this->getContext();
     $session = $context->getSession();
     $orderid = $session->get('aimeos/orderid');
     try {
         if (($orderItem = $this->updatePayment($view, $orderid)) === null) {
             $orderManager = \Aimeos\MShop\Factory::createManager($context, 'order');
             $orderItem = $orderManager->getItem($orderid);
         }
         $view->confirmOrderItem = $orderItem;
         parent::process();
         if ($orderItem->getPaymentStatus() > \Aimeos\MShop\Order\Item\Base::PAY_REFUSED) {
             foreach ($session->get('aimeos/basket/cache', array()) as $key => $value) {
                 $session->set($key, null);
             }
             \Aimeos\Controller\Frontend\Factory::createController($context, 'basket')->clear();
         }
         // Update stock, coupons, etc.
         \Aimeos\Controller\Frontend\Factory::createController($context, 'order')->update($orderItem);
     } catch (\Aimeos\Client\Html\Exception $e) {
         $error = array($context->getI18n()->dt('client', $e->getMessage()));
         $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error;
     } catch (\Aimeos\Controller\Frontend\Exception $e) {
         $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage()));
         $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error;
     } catch (\Aimeos\MShop\Exception $e) {
         $error = array($context->getI18n()->dt('mshop', $e->getMessage()));
         $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error;
     } catch (\Exception $e) {
         $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString());
         $error = array($context->getI18n()->dt('client', 'A non-recoverable error occured'));
         $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error;
     }
 }
コード例 #11
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     try {
         parent::process();
         $basketCntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'basket');
         // Test if addresses are available
         $addresses = $basketCntl->get()->getAddresses();
         if (!isset($view->standardStepActive) && count($addresses) === 0) {
             $view->standardStepActive = 'address';
             return false;
         }
     } catch (\Exception $e) {
         $this->getView()->standardStepActive = 'address';
         throw $e;
     }
 }
コード例 #12
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $context = $this->getContext();
     $view = $this->getView();
     try {
         $site = $context->getLocale()->getSite()->getCode();
         $params = $this->getClientParams($view->param());
         $context->getSession()->set('aimeos/catalog/detail/params/last' . $site, $params);
         parent::process();
     } catch (\Aimeos\Client\Html\Exception $e) {
         $error = array($context->getI18n()->dt('client', $e->getMessage()));
         $view->detailErrorList = $view->get('detailErrorList', array()) + $error;
     } catch (\Aimeos\Controller\Frontend\Exception $e) {
         $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage()));
         $view->detailErrorList = $view->get('detailErrorList', array()) + $error;
     } catch (\Aimeos\MShop\Exception $e) {
         $error = array($context->getI18n()->dt('mshop', $e->getMessage()));
         $view->detailErrorList = $view->get('detailErrorList', array()) + $error;
     } catch (\Exception $e) {
         $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString());
         $error = array($context->getI18n()->dt('client', 'A non-recoverable error occured'));
         $view->detailErrorList = $view->get('detailErrorList', array()) + $error;
     }
 }
コード例 #13
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     $context = $this->getContext();
     $ids = $view->param('fav_id', array());
     if ($context->getUserId() != null && !empty($ids)) {
         $typeItem = $this->getTypeItem('customer/lists/type', 'product', 'favorite');
         $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists');
         $search = $manager->createSearch();
         $expr = array($search->compare('==', 'customer.lists.parentid', $context->getUserId()), $search->compare('==', 'customer.lists.refid', $ids), $search->compare('==', 'customer.lists.domain', 'product'), $search->compare('==', 'customer.lists.typeid', $typeItem->getId()));
         $search->setConditions($search->combine('&&', $expr));
         $items = array();
         foreach ($manager->searchItems($search) as $item) {
             $items[$item->getRefId()] = $item;
         }
         switch ($view->param('fav_action')) {
             case 'add':
                 $item = $manager->createItem();
                 $item->setParentId($context->getUserId());
                 $item->setTypeId($typeItem->getId());
                 $item->setDomain('product');
                 $item->setStatus(1);
                 foreach ((array) $view->param('fav_id', array()) as $id) {
                     if (!isset($items[$id])) {
                         $item->setId(null);
                         $item->setRefId($id);
                         $manager->saveItem($item);
                         $manager->moveItem($item->getId());
                     }
                 }
                 break;
             case 'delete':
                 $listIds = array();
                 foreach ((array) $view->param('fav_id', array()) as $id) {
                     if (isset($items[$id])) {
                         $listIds[] = $items[$id]->getId();
                     }
                 }
                 $manager->deleteItems($listIds);
                 break;
         }
     }
     parent::process();
 }
コード例 #14
0
ファイル: Standard.php プロジェクト: boettner-it/aimeos-core
 /**
  * Returns the parameters used by the html client.
  *
  * @param array $params Associative list of all parameters
  * @param array $prefixes List of prefixes the parameters must start with
  * @return array Associative list of parameters used by the html client
  */
 protected function getClientParams(array $params, array $prefixes = array('f', 'l', 'd', 'a'))
 {
     $list = parent::getClientParams($params, array_merge($prefixes, array('d')));
     if (isset($list['d_prodid'])) {
         $context = $this->getContext();
         $site = $context->getLocale()->getSite()->getCode();
         $list += (array) $context->getSession()->get('aimeos/catalog/list/params/last/' . $site, array());
     }
     return $list;
 }
コード例 #15
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Stores the given or fetched billing address in the basket.
  */
 public function process()
 {
     $context = $this->getContext();
     $view = $this->getView();
     try {
         if (($id = $view->param('ca_delivery_delete', null)) !== null) {
             $customerAddressManager = \Aimeos\MShop\Factory::createManager($context, 'customer/address');
             $address = $customerAddressManager->getItem($id);
             if ($address->getParentId() != $context->getUserId()) {
                 throw new \Aimeos\Client\Html\Exception(sprintf('Address with ID "%1$s" not found', $id));
             }
             $customerAddressManager->deleteItem($id);
         }
         // only start if there's something to do
         if ($view->param('ca_deliveryoption', null) === null) {
             return;
         }
         $basketCtrl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
         /** client/html/checkout/standard/address/delivery/disable-new
          * Disables the option to enter a different delivery address for an order
          *
          * Besides the billing address, customers can usually enter a different
          * delivery address as well. To suppress displaying the form fields for
          * a delivery address, you can set this configuration option to "1".
          *
          * Until 2015-02, the configuration option was available as
          * "client/html/common/address/delivery/disable-new" starting from 2014-03.
          *
          * @param boolean A value of "1" to disable, "0" enables the delivery address form
          * @since 2015.02
          * @category User
          * @category Developer
          * @see client/html/checkout/standard/address/delivery/salutations
          * @see client/html/checkout/standard/address/delivery/mandatory
          * @see client/html/checkout/standard/address/delivery/optional
          * @see client/html/checkout/standard/address/delivery/hidden
          */
         $disable = $view->config('client/html/checkout/standard/address/delivery/disable-new', false);
         $type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY;
         if (($option = $view->param('ca_deliveryoption', 'null')) === 'null' && $disable === false) {
             $params = $view->param('ca_delivery', array());
             $invalid = $this->checkFields($params);
             if (count($invalid) > 0) {
                 $view->deliveryError = $invalid;
                 throw new \Aimeos\Client\Html\Exception(sprintf('At least one delivery address part is missing or invalid'));
             }
             $basketCtrl->setAddress($type, $params);
         } else {
             if (($option = $view->param('ca_deliveryoption', 'null')) !== '-1') {
                 $customerAddressManager = \Aimeos\MShop\Factory::createManager($context, 'customer/address');
                 $address = $customerAddressManager->getItem($option);
                 if ($address->getParentId() != $context->getUserId()) {
                     throw new \Aimeos\Client\Html\Exception(sprintf('Address with ID "%1$s" not found', $option));
                 }
                 $invalid = array();
                 $params = $view->param('ca_delivery_' . $option, array());
                 if (!empty($params)) {
                     $list = array();
                     $invalid = $this->checkFields($params);
                     foreach ($params as $key => $value) {
                         $list[str_replace('order.base', 'customer', $key)] = $value;
                     }
                     $address->fromArray($list);
                     $customerAddressManager->saveItem($address);
                 }
                 if (count($invalid) > 0) {
                     $view->deliveryError = $invalid;
                     throw new \Aimeos\Client\Html\Exception(sprintf('At least one delivery address part is missing or invalid'));
                 }
                 $basketCtrl->setAddress($type, $address);
             } else {
                 $basketCtrl->setAddress($type, null);
             }
         }
         parent::process();
     } catch (\Aimeos\Controller\Frontend\Exception $e) {
         $view->deliveryError = $e->getErrorList();
         throw $e;
     }
 }
コード例 #16
0
ファイル: Standard.php プロジェクト: aimeos/ai-client-html
 /**
  * Processes the input, e.g. provides the address form.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     $basket = $view->orderBasket;
     $customerId = $basket->getCustomerId();
     try {
         $addr = $basket->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY);
         if ($customerId != '' && $addr->getAddressId() == '') {
             $addrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address');
             $orderAddrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address');
             $item = $addrManager->createItem();
             $item->setParentId($customerId);
             $item->copyFrom($addr);
             $addrManager->saveItem($item);
             $addr->setAddressId($item->getId());
             $orderAddrManager->saveItem($addr, false);
         }
     } catch (\Exception $e) {
         $msg = sprintf('Unable to save address for customer "%1$s": %2$s', $customerId, $e->getMessage());
         $this->getContext()->getLogger()->log($msg, \Aimeos\MW\Logger\Base::INFO);
     }
     parent::process();
 }
コード例 #17
0
ファイル: Standard.php プロジェクト: boettner-it/aimeos-core
 /**
  * Processes the input, e.g. provides the account form.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     $basket = $view->orderBasket;
     if ($basket->getCustomerId() == '') {
         $email = '<unknown>';
         $context = $this->getContext();
         try {
             $addr = $basket->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
             $email = $addr->getEmail();
             $manager = \Aimeos\MShop\Factory::createManager($context, 'customer');
             $search = $manager->createSearch();
             $search->setConditions($search->compare('==', 'customer.code', $email));
             $search->setSlice(0, 1);
             $result = $manager->searchItems($search);
             if (empty($result)) {
                 $orderBaseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
                 $password = substr(md5(microtime(true) . rand()), -8);
                 $item = $this->addCustomerData($manager->createItem(), $addr, $addr->getEmail(), $password);
                 $manager->saveItem($item);
                 $context->setUserId($item->getId());
                 $basket->setCustomerId($item->getId());
                 $orderBaseManager->saveItem($basket, false);
                 $this->sendEmail($addr, $addr->getEmail(), $password);
             }
         } catch (\Exception $e) {
             $msg = sprintf('Unable to create an account for "%1$s": %2$s', $email, $e->getMessage());
             $context->getLogger()->log($msg, \Aimeos\MW\Logger\Base::INFO);
         }
     }
     parent::process();
 }
コード例 #18
0
ファイル: Standard.php プロジェクト: aimeos/ai-client-html
 /**
  * Stores the given or fetched billing address in the basket.
  */
 public function process()
 {
     $view = $this->getView();
     try {
         // only start if there's something to do
         if ($view->param('ca_billingoption', null) === null) {
             return;
         }
         $this->setAddress($view);
         parent::process();
     } catch (\Aimeos\Controller\Frontend\Exception $e) {
         $view->billingError = $e->getErrorList();
         throw $e;
     }
 }
コード例 #19
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     if ($view->param('cs_order', null) === null) {
         return;
     }
     try {
         $controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'basket');
         $controller->get()->check(\Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL);
         parent::process();
     } catch (\Exception $e) {
         $view->standardStepActive = 'summary';
         throw $e;
     }
 }
コード例 #20
0
ファイル: Standard.php プロジェクト: aimeos/ai-client-html
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     if (($id = $this->getView()->param('d_prodid')) !== null) {
         $context = $this->getContext();
         $session = $context->getSession();
         $lastSeen = $session->get('aimeos/catalog/session/seen/list', array());
         if (isset($lastSeen[$id])) {
             $html = $lastSeen[$id];
             unset($lastSeen[$id]);
             $lastSeen[$id] = $html;
         } else {
             /** client/html/catalog/session/seen/standard/maxitems
              * Maximum number of products displayed in the "last seen" section
              *
              * This option limits the number of products that are shown in the
              * "last seen" section after the user visited their detail pages. It
              * must be a positive integer value greater than 0.
              *
              * @param integer Number of products
              * @since 2014.03
              * @category User
              * @category Developer
              */
             $max = $this->getContext()->getConfig()->get('client/html/catalog/session/seen/standard/maxitems', 6);
             $lastSeen[$id] = $this->getHtml($id);
             $lastSeen = array_slice($lastSeen, -$max, $max, true);
         }
         $session->set('aimeos/catalog/session/seen/list', $lastSeen);
         foreach ($session->get('aimeos/catalog/session/seen/cache', array()) as $key => $value) {
             $session->set($key, null);
         }
     }
     parent::process();
 }
コード例 #21
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     $context = $this->getContext();
     $config = $context->getConfig();
     $session = $context->getSession();
     $name = $config->get('client/html/locale/select/currency/param-name', 'loc_currencyid');
     if (($currencyId = $view->param($name)) !== null) {
         $session->set('aimeos/locale/currencyId', $currencyId);
     }
     parent::process();
 }
コード例 #22
0
ファイル: Standard.php プロジェクト: aimeos/ai-client-html
 /**
  * Stores the given or fetched billing address in the basket.
  */
 public function process()
 {
     $context = $this->getContext();
     $view = $this->getView();
     try {
         if (($id = $view->param('ca_delivery_delete', null)) !== null) {
             $customerAddressManager = \Aimeos\MShop\Factory::createManager($context, 'customer/address');
             $address = $customerAddressManager->getItem($id);
             if ($address->getParentId() != $context->getUserId()) {
                 throw new \Aimeos\Client\Html\Exception(sprintf('Address with ID "%1$s" not found', $id));
             }
             $customerAddressManager->deleteItem($id);
         }
         // only start if there's something to do
         if ($view->param('ca_deliveryoption', null) === null) {
             return;
         }
         $this->setAddress($view);
         parent::process();
     } catch (\Aimeos\Controller\Frontend\Exception $e) {
         $view->deliveryError = $e->getErrorList();
         throw $e;
     }
 }
コード例 #23
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     try {
         $context = $this->getContext();
         $basketCtrl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
         // only start if there's something to do
         if (($serviceId = $view->param('c_paymentoption', null)) !== null) {
             $serviceCtrl = \Aimeos\Controller\Frontend\Factory::createController($context, 'service');
             $attributes = $view->param('c_payment/' . $serviceId, array());
             $errors = $serviceCtrl->checkServiceAttributes('payment', $serviceId, $attributes);
             foreach ($errors as $key => $msg) {
                 if ($msg === null) {
                     unset($errors[$key]);
                 }
             }
             if (count($errors) === 0) {
                 $basketCtrl->setService('payment', $serviceId, $attributes);
             } else {
                 $view->standardStepActive = 'payment';
             }
             $view->paymentError = $errors;
         }
         parent::process();
         // Test if payment service is available
         $services = $basketCtrl->get()->getServices();
         if (!isset($view->standardStepActive) && !array_key_exists('payment', $services)) {
             $view->standardStepActive = 'payment';
             return false;
         }
     } catch (\Exception $e) {
         $view->standardStepActive = 'payment';
         throw $e;
     }
 }
コード例 #24
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     // only start if there's something to do
     if (($option = $view->param('cs_option_terms', null)) === null) {
         return;
     }
     if (($option = $view->param('cs_option_terms_value', 0)) != 1) {
         $view->standardStepActive = 'summary';
         $view->termsError = true;
         $error = array($view->translate('client', 'Please accept the terms and conditions'));
         $view->standardErrorList = $error + $view->get('standardErrorList', array());
     }
     parent::process();
 }
コード例 #25
0
ファイル: Standard.php プロジェクト: aimeos/ai-client-html
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     try {
         parent::process();
         $context = $this->getContext();
         if (($param = $view->param('ca_extra')) !== null) {
             $context->getSession()->set('client/html/checkout/standard/address/extra', (array) $param);
         }
         $basketCntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
         // Test if addresses are available
         $addresses = $basketCntl->get()->getAddresses();
         if (!isset($view->standardStepActive) && count($addresses) === 0) {
             $view->standardStepActive = 'address';
             return false;
         }
     } catch (\Exception $e) {
         $this->getView()->standardStepActive = 'address';
         throw $e;
     }
 }
コード例 #26
0
ファイル: Standard.php プロジェクト: mvnp/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     try {
         parent::process();
     } catch (\Exception $e) {
         $this->getContext()->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString());
     }
 }
コード例 #27
0
ファイル: Standard.php プロジェクト: boettner-it/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $view = $this->getView();
     $context = $this->getContext();
     try {
         parent::process();
     } catch (\Aimeos\Client\Html\Exception $e) {
         $error = array($this->getContext()->getI18n()->dt('client/html', $e->getMessage()));
         $view->standardErrorList = $view->get('standardErrorList', array()) + $error;
     } catch (\Aimeos\Controller\Frontend\Exception $e) {
         $error = array($this->getContext()->getI18n()->dt('controller/frontend', $e->getMessage()));
         $view->standardErrorList = $view->get('standardErrorList', array()) + $error;
     } catch (\Aimeos\MShop\Plugin\Provider\Exception $e) {
         $errors = array($this->getContext()->getI18n()->dt('mshop', $e->getMessage()));
         $errors = array_merge($errors, $this->translatePluginErrorCodes($e->getErrorCodes()));
         $view->summaryErrorCodes = $e->getErrorCodes();
         $view->standardErrorList = $view->get('standardErrorList', array()) + $errors;
     } catch (\Aimeos\MShop\Exception $e) {
         $error = array($this->getContext()->getI18n()->dt('mshop', $e->getMessage()));
         $view->standardErrorList = $view->get('standardErrorList', array()) + $error;
     } catch (\Exception $e) {
         $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString());
         $error = array($context->getI18n()->dt('client/html', 'A non-recoverable error occured'));
         $view->standardErrorList = $view->get('standardErrorList', array()) + $error;
     }
 }
コード例 #28
0
ファイル: Standard.php プロジェクト: skyheights/aimeos-core
 /**
  * Processes the input, e.g. store given values.
  * A view must be available and this method doesn't generate any output
  * besides setting view variables.
  */
 public function process()
 {
     $context = $this->getContext();
     try {
         $view = $this->getView();
         $id = $view->param('dl_id');
         $customerId = $context->getUserId();
         if ($this->checkAccess($customerId, $id) === false) {
             return;
         }
         $manager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute');
         $item = $manager->getItem($id);
         if ($this->checkDownload($context->getUserId(), $id) === true) {
             $this->addDownload($item);
         } else {
             $view->response()->withStatus(403);
         }
         parent::process();
     } catch (\Exception $e) {
         $context->getLogger()->log($e->getMessage());
     }
 }
コード例 #29
0
ファイル: Standard.php プロジェクト: aimeos/ai-client-html
 /**
  * Returns the parameters used by the html client.
  *
  * @param array $params Associative list of all parameters
  * @param string[] $prefixes List of prefixes the parameters must start with
  * @return array Associative list of parameters used by the html client
  */
 protected function getClientParams(array $params, array $prefixes = array('f', 'l', 'd', 'a'))
 {
     if (isset($params['d_pos']) && isset($params['d_prodid'])) {
         $context = $this->getContext();
         $site = $context->getLocale()->getSite()->getCode();
         $params += (array) $context->getSession()->get('aimeos/catalog/lists/params/last/' . $site, array());
     }
     return parent::getClientParams($params, $prefixes);
 }
コード例 #30
0
ファイル: Standard.php プロジェクト: boettner-it/aimeos-core
 /**
  * Modifies the cached body content to replace content based on sessions or cookies.
  *
  * @param string $content Cached content
  * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
  * @return string Modified body content
  */
 public function modifyBody($content, $uid)
 {
     $content = parent::modifyBody($content, $uid);
     return $this->replaceSection($content, $this->getView()->csrf()->formfield(), 'catalog.detail.basket.csrf');
 }