Initial Commit
This commit is contained in:
26
local/modules/Front/Config/config.xml
Normal file
26
local/modules/Front/Config/config.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<config xmlns="http://thelia.net/schema/dic/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
<forms>
|
||||
<!--
|
||||
<form name="MyFormName" class="MyModule\Form\MySuperForm" />
|
||||
-->
|
||||
</forms>
|
||||
|
||||
|
||||
<services>
|
||||
<service id="router.front" class="%router.class%">
|
||||
<argument type="service" id="router.module.xmlLoader"/>
|
||||
<argument>Front/Config/front.xml</argument>
|
||||
<argument type="collection">
|
||||
<argument key="cache_dir">%kernel.cache_dir%</argument>
|
||||
<argument key="debug">%kernel.debug%</argument>
|
||||
</argument>
|
||||
<argument type="service" id="request.context"/>
|
||||
<tag name="router.register" priority="128"/>
|
||||
</service>
|
||||
</services>
|
||||
</config>
|
||||
268
local/modules/Front/Config/front.xml
Normal file
268
local/modules/Front/Config/front.xml
Normal file
@@ -0,0 +1,268 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="ajax.mini-cart" path="/ajax/mini-cart">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">includes/mini-cart</default>
|
||||
</route>
|
||||
|
||||
<route id="ajax.addCartMessage" path="/ajax/addCartMessage">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">includes/addedToCart</default>
|
||||
</route>
|
||||
|
||||
<!-- Register -->
|
||||
<route id="customer.create.view" path="/register" methods="get">
|
||||
<default key="_controller">Front\Controller\CustomerController::viewRegisterAction</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.create.process" path="/register" methods="post">
|
||||
<default key="_controller">Front\Controller\CustomerController::createAction</default>
|
||||
<default key="_view">register</default>
|
||||
</route>
|
||||
|
||||
<!-- Login -->
|
||||
<route id="customer.login.view" path="/login" methods="get">
|
||||
<default key="_controller">Front\Controller\CustomerController::viewLoginAction</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.login.process" path="/login" methods="post">
|
||||
<default key="_controller">Front\Controller\CustomerController::loginAction</default>
|
||||
<default key="_view">login</default>
|
||||
</route>
|
||||
|
||||
<!-- Forgot Password -->
|
||||
<route id="customer.password.retrieve.process" path="/password" methods="post">
|
||||
<default key="_controller">Front\Controller\CustomerController::newPasswordAction</default>
|
||||
<default key="_view">password</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.password.retrieve.sent" path="/password-sent">
|
||||
<default key="_controller">Front\Controller\CustomerController::newPasswordSentAction</default>
|
||||
<default key="_view">password</default>
|
||||
</route>
|
||||
|
||||
<!-- Logout -->
|
||||
<route id="customer.logout.process" path="/logout">
|
||||
<default key="_controller">Front\Controller\CustomerController::logoutAction</default>
|
||||
</route>
|
||||
|
||||
<!-- Account -->
|
||||
|
||||
<route id="customer.home" path="/account" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">account</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.update.view" path="/account/update" methods="get">
|
||||
<default key="_controller">Front\Controller\CustomerController::viewAction</default>
|
||||
<default key="_view">account-update</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.update.process" path="/account/update" methods="post">
|
||||
<default key="_controller">Front\Controller\CustomerController::updateAction</default>
|
||||
<default key="_view">account-update</default>
|
||||
</route>
|
||||
|
||||
|
||||
<route id="customer.password.change.process" path="/account/password" methods="post">
|
||||
<default key="_controller">Front\Controller\CustomerController::updatePasswordAction</default>
|
||||
<default key="_view">account-password</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.password.change.view" path="/account/password" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">account-password</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.order" path="/account/order/{order_id}">
|
||||
<default key="_controller">Front\Controller\OrderController::viewAction</default>
|
||||
<requirement key="order_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="customer.order.pdf.delivery" path="/account/order/pdf/delivery/{order_id}">
|
||||
<default key="_controller">Front\Controller\OrderController::generateDeliveryPdf</default>
|
||||
<requirement key="order_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="customer.order.pdf.invoice" path="/account/order/pdf/invoice/{order_id}">
|
||||
<default key="_controller">Front\Controller\OrderController::generateInvoicePdf</default>
|
||||
<requirement key="order_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="customer.order.product.download" path="/account/download/{order_product_id}">
|
||||
<default key="_controller">Front\Controller\OrderController::downloadVirtualProduct</default>
|
||||
<requirement key="order_product_id">\d+</requirement>
|
||||
</route>
|
||||
<!-- end customer routes -->
|
||||
|
||||
<!-- customer address routes -->
|
||||
<route id="address.create.view" path="/address/create" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">address</default>
|
||||
</route>
|
||||
|
||||
<route id="address.create" path="/address/create" methods="post" >
|
||||
<default key="_controller">Front\Controller\AddressController::createAction</default>
|
||||
<default key="_view">address</default>
|
||||
</route>
|
||||
|
||||
<route id="address.edit" path="/address/update/{address_id}" methods="get">
|
||||
<default key="_controller">Front\Controller\AddressController::updateViewAction</default>
|
||||
<default key="_view">address-update</default>
|
||||
</route>
|
||||
|
||||
<route id="address.update" path="/address/update/{address_id}" methods="post" >
|
||||
<default key="_controller">Front\Controller\AddressController::processUpdateAction</default>
|
||||
<default key="_view">address-update</default>
|
||||
</route>
|
||||
|
||||
<route id="address.delete" path="/address/delete/{address_id}">
|
||||
<default key="_controller">Front\Controller\AddressController::deleteAction</default>
|
||||
<default key="_view">account</default>
|
||||
</route>
|
||||
|
||||
<route id="address.generateModal" path="/address/modal/{address_id}" methods="get">
|
||||
<default key="_controller">Front\Controller\AddressController::generateModalAction</default>
|
||||
<default key="_view">modal-address</default>
|
||||
<requirement key="address_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="address.make.default" path="/address/default/{addressId}" methods="get">
|
||||
<default key="_controller">Front:Address:makeAddressDefault</default>
|
||||
<requirement key="addressId">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<!-- end customer address routes -->
|
||||
|
||||
<!-- cart routes -->
|
||||
<route id="cart.view" path="/cart">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<route id="cart.add.process" path="/cart/add">
|
||||
<default key="_controller">Front\Controller\CartController::addItem</default>
|
||||
</route>
|
||||
|
||||
<route id="cart.delete.process" path="/cart/delete/{cart_item}">
|
||||
<default key="_controller">Front\Controller\CartController::deleteItem</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<route id="cart.update.quantity" path="/cart/update">
|
||||
<default key="_controller">Front\Controller\CartController::changeItem</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<route id="cart.update.country" path="/cart/country">
|
||||
<default key="_controller">Front\Controller\CartController::changeCountry</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
<!-- end cart routes -->
|
||||
|
||||
<!-- order management process -->
|
||||
<route id="order.delivery.process" path="/order/delivery" methods="post">
|
||||
<default key="_controller">Front\Controller\OrderController::deliver</default>
|
||||
<default key="_view">order-delivery</default>
|
||||
</route>
|
||||
|
||||
<route id="order.delivery" path="/order/delivery">
|
||||
<default key="_controller">Front\Controller\OrderController::deliverView</default>
|
||||
<default key="_view">order-delivery</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.delivery.ajax-module-list" path="/order/deliveryModuleList">
|
||||
<default key="_controller">Front\Controller\OrderController::getDeliveryModuleListAjaxAction</default>
|
||||
</route>
|
||||
|
||||
<route id="order.invoice.process" path="/order/invoice" methods="post">
|
||||
<default key="_controller">Front\Controller\OrderController::invoice</default>
|
||||
<default key="_view">order-invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.invoice" path="/order/invoice">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">order-invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.coupon.process" path="/order/coupon" methods="post">
|
||||
<default key="_controller">Front\Controller\CouponController::consumeAction</default>
|
||||
<default key="_view">order-invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.coupon.clear" path="/order/clear-coupons">
|
||||
<default key="_controller">Front\Controller\CouponController::clearAllCouponsAction</default>
|
||||
<default key="_view">order-invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.payment.process" path="/order/pay">
|
||||
<default key="_controller">Front\Controller\OrderController::pay</default>
|
||||
</route>
|
||||
|
||||
<route id="order.placed" path="/order/placed/{order_id}">
|
||||
<default key="_controller">Front\Controller\OrderController::orderPlaced</default>
|
||||
<default key="_view">order-placed</default>
|
||||
</route>
|
||||
|
||||
<route id="order.failed" path="/order/failed/{order_id}/{message}">
|
||||
<default key="_controller">Front\Controller\OrderController::orderFailed</default>
|
||||
<default key="_view">order-failed</default>
|
||||
</route>
|
||||
<!-- end order management process -->
|
||||
|
||||
<!-- contact management -->
|
||||
<route id="contact.send" path="/contact" methods="post">
|
||||
<default key="_controller">Front\Controller\ContactController::sendAction</default>
|
||||
<default key="_view">contact</default>
|
||||
</route>
|
||||
|
||||
<route id="contact.success" path="/contact/success">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">contact-success</default>
|
||||
</route>
|
||||
<!-- end contact management -->
|
||||
|
||||
<!-- newsletter management -->
|
||||
<route id="newsletter.process" path="/newsletter" methods="post">
|
||||
<default key="_controller">Front\Controller\NewsletterController::subscribeAction</default>
|
||||
<default key="_view">newsletter</default>
|
||||
</route>
|
||||
|
||||
<route id="newsletter.unsubscribe" path="/newsletter-unsubscribe" methods="post">
|
||||
<default key="_controller">Front\Controller\NewsletterController::unsubscribeAction</default>
|
||||
<default key="_view">newsletter-unsubscribe</default>
|
||||
</route>
|
||||
|
||||
<!-- end newsletter management -->
|
||||
|
||||
<!-- sitemap generator -->
|
||||
<route id="sitemap.process" path="/sitemap">
|
||||
<default key="_controller">Front\Controller\SitemapController::generateAction</default>
|
||||
</route>
|
||||
<!-- end sitemap generator -->
|
||||
|
||||
<!-- feed generator -->
|
||||
<route id="feed.process" path="/feed/{context}/{lang}/{id}">
|
||||
<default key="_controller">Front\Controller\FeedController::generateAction</default>
|
||||
<default key="context">catalog</default>
|
||||
<default key="lang"></default>
|
||||
<default key="id"></default>
|
||||
</route>
|
||||
<!-- end feed generator -->
|
||||
|
||||
<!-- Route used to check if the rewrite engine is activated -->
|
||||
<route id="empty" path="/empty">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::emptyRoute</default>
|
||||
</route>
|
||||
|
||||
<!-- Default Route -->
|
||||
<route id="default" path="/{_view}">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">index</default>
|
||||
<requirement key="_view">^(?!admin|api)[^/]+</requirement>
|
||||
</route>
|
||||
</routes>
|
||||
20
local/modules/Front/Config/module.xml
Normal file
20
local/modules/Front/Config/module.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module>
|
||||
<fullnamespace>Front\Front</fullnamespace>
|
||||
<descriptive locale="en_US">
|
||||
<title>Front integration</title>
|
||||
<description></description>
|
||||
</descriptive>
|
||||
<descriptive locale="fr_FR">
|
||||
<title>Front office module</title>
|
||||
<description></description>
|
||||
</descriptive>
|
||||
<version>2.3.1</version>
|
||||
<author>
|
||||
<name>Thelia team</name>
|
||||
<email>info@thelia.net</email>
|
||||
</author>
|
||||
<type>classic</type>
|
||||
<thelia>2.2.0</thelia>
|
||||
<stability>alpha</stability>
|
||||
</module>
|
||||
273
local/modules/Front/Controller/AddressController.php
Normal file
273
local/modules/Front/Controller/AddressController.php
Normal file
@@ -0,0 +1,273 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Front\Controller;
|
||||
|
||||
use Front\Front;
|
||||
use Symfony\Component\Form\Form;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Address\AddressEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\Definition\FrontForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
/**
|
||||
* Class AddressController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class AddressController extends BaseFrontController
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller for generate modal containing update form
|
||||
* Check if request is a XmlHttpRequest and address owner is the current customer
|
||||
*
|
||||
* @param $address_id
|
||||
*/
|
||||
public function generateModalAction($address_id)
|
||||
{
|
||||
|
||||
$this->checkAuth();
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create controller.
|
||||
* Check if customer is logged in
|
||||
*
|
||||
* Dispatch TheliaEvents::ADDRESS_CREATE event
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
$this->checkAuth();
|
||||
|
||||
$addressCreate = $this->createForm(FrontForm::ADDRESS_CREATE);
|
||||
|
||||
try {
|
||||
/** @var Customer $customer */
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$form = $this->validateForm($addressCreate, "post");
|
||||
$event = $this->createAddressEvent($form);
|
||||
$event->setCustomer($customer);
|
||||
|
||||
$this->dispatch(TheliaEvents::ADDRESS_CREATE, $event);
|
||||
|
||||
return $this->generateSuccessRedirect($addressCreate);
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $this->getTranslator()->trans("Please check your input: %s", ['%s' => $e->getMessage()], Front::MESSAGE_DOMAIN);
|
||||
} catch (\Exception $e) {
|
||||
$message = $this->getTranslator()->trans("Sorry, an error occured: %s", ['%s' => $e->getMessage()], Front::MESSAGE_DOMAIN);
|
||||
}
|
||||
|
||||
Tlog::getInstance()->error(sprintf("Error during address creation process : %s", $message));
|
||||
|
||||
$addressCreate->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($addressCreate)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
|
||||
// Redirect to error URL if defined
|
||||
if ($addressCreate->hasErrorUrl()) {
|
||||
return $this->generateErrorRedirect($addressCreate);
|
||||
}
|
||||
}
|
||||
|
||||
protected function createAddressEvent(Form $form)
|
||||
{
|
||||
return new AddressCreateOrUpdateEvent(
|
||||
$form->get("label")->getData(),
|
||||
$form->get("title")->getData(),
|
||||
$form->get("firstname")->getData(),
|
||||
$form->get("lastname")->getData(),
|
||||
$form->get("address1")->getData(),
|
||||
$form->get("address2")->getData(),
|
||||
$form->get("address3")->getData(),
|
||||
$form->get("zipcode")->getData(),
|
||||
$form->get("city")->getData(),
|
||||
$form->get("country")->getData(),
|
||||
$form->get("cellphone")->getData(),
|
||||
$form->get("phone")->getData(),
|
||||
$form->get("company")->getData(),
|
||||
$form->get("is_default")->getData(),
|
||||
$form->get("state")->getData()
|
||||
);
|
||||
}
|
||||
|
||||
public function updateViewAction($address_id)
|
||||
{
|
||||
$this->checkAuth();
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$address = AddressQuery::create()->findPk($address_id);
|
||||
|
||||
if (!$address || $customer->getId() != $address->getCustomerId()) {
|
||||
return $this->generateRedirectFromRoute('default');
|
||||
}
|
||||
|
||||
$this->getParserContext()->set("address_id", $address_id);
|
||||
}
|
||||
|
||||
public function processUpdateAction($address_id)
|
||||
{
|
||||
$this->checkAuth();
|
||||
|
||||
$addressUpdate = $this->createForm(FrontForm::ADDRESS_UPDATE);
|
||||
|
||||
try {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$form = $this->validateForm($addressUpdate);
|
||||
|
||||
$address = AddressQuery::create()->findPk($address_id);
|
||||
|
||||
if (null === $address) {
|
||||
return $this->generateRedirectFromRoute('default');
|
||||
}
|
||||
|
||||
if ($address->getCustomer()->getId() != $customer->getId()) {
|
||||
return $this->generateRedirectFromRoute('default');
|
||||
}
|
||||
|
||||
$event = $this->createAddressEvent($form);
|
||||
$event->setAddress($address);
|
||||
|
||||
$this->dispatch(TheliaEvents::ADDRESS_UPDATE, $event);
|
||||
|
||||
return $this->generateSuccessRedirect($addressUpdate);
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $this->getTranslator()->trans("Please check your input: %s", ['%s' => $e->getMessage()], Front::MESSAGE_DOMAIN);
|
||||
} catch (\Exception $e) {
|
||||
$message = $this->getTranslator()->trans("Sorry, an error occured: %s", ['%s' => $e->getMessage()], Front::MESSAGE_DOMAIN);
|
||||
}
|
||||
|
||||
$this->getParserContext()->set("address_id", $address_id);
|
||||
|
||||
Tlog::getInstance()->error(sprintf("Error during address creation process : %s", $message));
|
||||
|
||||
$addressUpdate->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($addressUpdate)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
|
||||
if ($addressUpdate->hasErrorUrl()) {
|
||||
return $this->generateErrorRedirect($addressUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAction($address_id)
|
||||
{
|
||||
$this->checkAuth();
|
||||
$error_message = false;
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$address = AddressQuery::create()->findPk($address_id);
|
||||
|
||||
if (!$address || $customer->getId() != $address->getCustomerId()) {
|
||||
// If Ajax Request
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
return $this->jsonResponse(
|
||||
json_encode(
|
||||
array(
|
||||
"success" => false,
|
||||
"message" => $this->getTranslator()->trans(
|
||||
"Error during address deletion process",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return $this->generateRedirectFromRoute('default');
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::ADDRESS_DELETE, new AddressEvent($address));
|
||||
} catch (\Exception $e) {
|
||||
$error_message = $e->getMessage();
|
||||
}
|
||||
|
||||
Tlog::getInstance()->error(sprintf('Error during address deletion : %s', $error_message));
|
||||
|
||||
// If Ajax Request
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
if ($error_message) {
|
||||
$response = $this->jsonResponse(json_encode(array(
|
||||
"success" => false,
|
||||
"message" => $error_message
|
||||
)));
|
||||
} else {
|
||||
$response = $this->jsonResponse(
|
||||
json_encode([
|
||||
"success" => true,
|
||||
"message" => ""
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
} else {
|
||||
return $this->generateRedirectFromRoute('default', array('view'=>'account'));
|
||||
}
|
||||
}
|
||||
|
||||
public function makeAddressDefaultAction($addressId)
|
||||
{
|
||||
$this->checkAuth();
|
||||
|
||||
$address = AddressQuery::create()
|
||||
->filterByCustomerId($this->getSecurityContext()->getCustomerUser()->getId())
|
||||
->findPk($addressId)
|
||||
;
|
||||
|
||||
if (null === $address) {
|
||||
$this->pageNotFound();
|
||||
}
|
||||
|
||||
try {
|
||||
$event = new AddressEvent($address);
|
||||
$this->dispatch(TheliaEvents::ADDRESS_DEFAULT, $event);
|
||||
} catch (\Exception $e) {
|
||||
$this->getParserContext()
|
||||
->setGeneralError($e->getMessage())
|
||||
;
|
||||
|
||||
return $this->render("account");
|
||||
}
|
||||
|
||||
return $this->generateRedirectFromRoute('default', array('view'=>'account'));
|
||||
}
|
||||
}
|
||||
229
local/modules/Front/Controller/CartController.php
Normal file
229
local/modules/Front/Controller/CartController.php
Normal file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Front\Controller;
|
||||
|
||||
use Front\Front;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Core\Event\Cart\CartEvent;
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\CartAdd;
|
||||
use Thelia\Form\Definition\FrontForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\OrderPostage;
|
||||
use Thelia\Module\Exception\DeliveryException;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
class CartController extends BaseFrontController
|
||||
{
|
||||
public function addItem()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$cartAdd = $this->getAddCartForm($request);
|
||||
$message = null;
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($cartAdd);
|
||||
|
||||
$cartEvent = $this->getCartEvent();
|
||||
|
||||
$cartEvent->bindForm($form);
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_ADDITEM, $cartEvent);
|
||||
|
||||
$this->afterModifyCart();
|
||||
|
||||
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
$this->changeViewForAjax();
|
||||
} elseif (null !== $response = $this->generateSuccessRedirect($cartAdd)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
} catch (PropelException $e) {
|
||||
Tlog::getInstance()->error(sprintf("Failed to add item to cart with message : %s", $e->getMessage()));
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Failed to add this article to your cart, please try again",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
|
||||
if ($message) {
|
||||
$cartAdd->setErrorMessage($message);
|
||||
$this->getParserContext()->addForm($cartAdd);
|
||||
}
|
||||
}
|
||||
|
||||
public function changeItem()
|
||||
{
|
||||
$cartEvent = $this->getCartEvent();
|
||||
$cartEvent->setCartItemId($this->getRequest()->get("cart_item"));
|
||||
$cartEvent->setQuantity($this->getRequest()->get("quantity"));
|
||||
|
||||
try {
|
||||
$this->getTokenProvider()->checkToken(
|
||||
$this->getRequest()->query->get('_token')
|
||||
);
|
||||
|
||||
$this->dispatch(TheliaEvents::CART_UPDATEITEM, $cartEvent);
|
||||
|
||||
$this->afterModifyCart();
|
||||
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
$this->changeViewForAjax();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Tlog::getInstance()->error(sprintf("Failed to change cart item quantity: %s", $e->getMessage()));
|
||||
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteItem()
|
||||
{
|
||||
$cartEvent = $this->getCartEvent();
|
||||
$cartEvent->setCartItemId($this->getRequest()->get("cart_item"));
|
||||
|
||||
try {
|
||||
$this->getTokenProvider()->checkToken(
|
||||
$this->getRequest()->query->get('_token')
|
||||
);
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_DELETEITEM, $cartEvent);
|
||||
|
||||
$this->afterModifyCart();
|
||||
} catch (\Exception $e) {
|
||||
Tlog::getInstance()->error(sprintf("error during deleting cartItem with message : %s", $e->getMessage()));
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
}
|
||||
|
||||
$this->changeViewForAjax();
|
||||
}
|
||||
|
||||
protected function changeViewForAjax()
|
||||
{
|
||||
// If Ajax Request
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
$request = $this->getRequest();
|
||||
|
||||
$view = $request->get('ajax-view', "includes/mini-cart");
|
||||
|
||||
$request->attributes->set('_view', $view);
|
||||
}
|
||||
}
|
||||
|
||||
public function changeCountry()
|
||||
{
|
||||
$redirectUrl = URL::getInstance()->absoluteUrl("/cart");
|
||||
$deliveryId = $this->getRequest()->get("country");
|
||||
$cookieName = ConfigQuery::read('front_cart_country_cookie_name', 'fcccn');
|
||||
$cookieExpires = ConfigQuery::read('front_cart_country_cookie_expires', 2592000);
|
||||
$cookieExpires = intval($cookieExpires) ?: 2592000;
|
||||
|
||||
$cookie = new Cookie($cookieName, $deliveryId, time() + $cookieExpires, '/');
|
||||
|
||||
$response = $this->generateRedirect($redirectUrl);
|
||||
$response->headers->setCookie($cookie);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Core\Event\Cart\CartEvent
|
||||
*/
|
||||
protected function getCartEvent()
|
||||
{
|
||||
$cart = $this->getSession()->getSessionCart($this->getDispatcher());
|
||||
|
||||
return new CartEvent($cart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the good way to construct the cart form
|
||||
*
|
||||
* @param Request $request
|
||||
* @return CartAdd
|
||||
*/
|
||||
private function getAddCartForm(Request $request)
|
||||
{
|
||||
if ($request->isMethod("post")) {
|
||||
$cartAdd = $this->createForm(FrontForm::CART_ADD);
|
||||
} else {
|
||||
$cartAdd = $this->createForm(
|
||||
FrontForm::CART_ADD,
|
||||
"form",
|
||||
array(),
|
||||
array(
|
||||
'csrf_protection' => false,
|
||||
),
|
||||
$this->container
|
||||
);
|
||||
}
|
||||
|
||||
return $cartAdd;
|
||||
}
|
||||
|
||||
protected function afterModifyCart()
|
||||
{
|
||||
/* recalculate postage amount */
|
||||
$order = $this->getSession()->getOrder();
|
||||
if (null !== $order) {
|
||||
$deliveryModule = $order->getModuleRelatedByDeliveryModuleId();
|
||||
$deliveryAddress = AddressQuery::create()->findPk($order->getChoosenDeliveryAddress());
|
||||
|
||||
if (null !== $deliveryModule && null !== $deliveryAddress) {
|
||||
$moduleInstance = $deliveryModule->getDeliveryModuleInstance($this->container);
|
||||
|
||||
$orderEvent = new OrderEvent($order);
|
||||
|
||||
try {
|
||||
$postage = OrderPostage::loadFromPostage(
|
||||
$moduleInstance->getPostage($deliveryAddress->getCountry())
|
||||
);
|
||||
|
||||
$orderEvent->setPostage($postage->getAmount());
|
||||
$orderEvent->setPostageTax($postage->getAmountTax());
|
||||
$orderEvent->setPostageTaxRuleTitle($postage->getTaxRuleTitle());
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_POSTAGE, $orderEvent);
|
||||
} catch (DeliveryException $ex) {
|
||||
// The postage has been chosen, but changes in the cart causes an exception.
|
||||
// Reset the postage data in the order
|
||||
$orderEvent->setDeliveryModule(0);
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
83
local/modules/Front/Controller/ContactController.php
Normal file
83
local/modules/Front/Controller/ContactController.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Front\Controller;
|
||||
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Form\ContactForm;
|
||||
use Thelia\Form\Definition\FrontForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
* Class ContactController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class ContactController extends BaseFrontController
|
||||
{
|
||||
/**
|
||||
* send contact message
|
||||
*/
|
||||
public function sendAction()
|
||||
{
|
||||
$contactForm = $this->createForm(FrontForm::CONTACT);
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($contactForm);
|
||||
|
||||
$message = \Swift_Message::newInstance($form->get('subject')->getData())
|
||||
->addFrom(ConfigQuery::getStoreEmail(), $form->get('name')->getData())
|
||||
->addReplyTo($form->get('email')->getData(), $form->get('name')->getData())
|
||||
->addTo(ConfigQuery::getStoreEmail(), ConfigQuery::getStoreName())
|
||||
->setBody($form->get('message')->getData())
|
||||
;
|
||||
|
||||
$this->getMailer()->send($message);
|
||||
|
||||
if ($contactForm->hasSuccessUrl()) {
|
||||
return $this->generateSuccessRedirect($contactForm);
|
||||
}
|
||||
|
||||
return $this->generateRedirectFromRoute('contact.success');
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$error_message = $e->getMessage();
|
||||
}
|
||||
|
||||
Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message));
|
||||
|
||||
$contactForm->setErrorMessage($error_message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($contactForm)
|
||||
->setGeneralError($error_message)
|
||||
;
|
||||
|
||||
// Redirect to error URL if defined
|
||||
if ($contactForm->hasErrorUrl()) {
|
||||
return $this->generateErrorRedirect($contactForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
159
local/modules/Front/Controller/CouponController.php
Normal file
159
local/modules/Front/Controller/CouponController.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Front\Controller;
|
||||
|
||||
use Front\Front;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Exception\UnmatchableConditionException;
|
||||
use Thelia\Form\Definition\FrontForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\OrderPostage;
|
||||
use Thelia\Module\Exception\DeliveryException;
|
||||
|
||||
/**
|
||||
* Class CouponController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*/
|
||||
class CouponController extends BaseFrontController
|
||||
{
|
||||
/**
|
||||
* Clear all coupons.
|
||||
*/
|
||||
public function clearAllCouponsAction()
|
||||
{
|
||||
// Dispatch Event to the Action
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::COUPON_CLEAR_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Coupon consuming
|
||||
*/
|
||||
public function consumeAction()
|
||||
{
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
$message = false;
|
||||
$couponCodeForm = $this->createForm(FrontForm::COUPON_CONSUME);
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($couponCodeForm, 'post');
|
||||
|
||||
$couponCode = $form->get('coupon-code')->getData();
|
||||
|
||||
if (null === $couponCode || empty($couponCode)) {
|
||||
$message = true;
|
||||
throw new \Exception(
|
||||
$this->getTranslator()->trans(
|
||||
'Coupon code can\'t be empty',
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$couponConsumeEvent = new CouponConsumeEvent($couponCode);
|
||||
|
||||
// Dispatch Event to the Action
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::COUPON_CONSUME, $couponConsumeEvent);
|
||||
|
||||
/* recalculate postage amount */
|
||||
$order = $this->getSession()->getOrder();
|
||||
|
||||
if (null !== $order) {
|
||||
$deliveryModule = $order->getModuleRelatedByDeliveryModuleId();
|
||||
$deliveryAddress = AddressQuery::create()->findPk($order->getChoosenDeliveryAddress());
|
||||
|
||||
if (null !== $deliveryModule && null !== $deliveryAddress) {
|
||||
$moduleInstance = $deliveryModule->getDeliveryModuleInstance($this->container);
|
||||
|
||||
$orderEvent = new OrderEvent($order);
|
||||
|
||||
try {
|
||||
$postage = OrderPostage::loadFromPostage(
|
||||
$moduleInstance->getPostage($deliveryAddress->getCountry())
|
||||
);
|
||||
|
||||
$orderEvent->setPostage($postage->getAmount());
|
||||
$orderEvent->setPostageTax($postage->getAmountTax());
|
||||
$orderEvent->setPostageTaxRuleTitle($postage->getTaxRuleTitle());
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_POSTAGE, $orderEvent);
|
||||
} catch (DeliveryException $ex) {
|
||||
// The postage has been chosen, but changes dues to coupon causes an exception.
|
||||
// Reset the postage data in the order
|
||||
$orderEvent->setDeliveryModule(0);
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->generateSuccessRedirect($couponCodeForm);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
'Please check your coupon code: %message',
|
||||
["%message" => $e->getMessage()],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (UnmatchableConditionException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
'You should <a href="%sign">sign in</a> or <a href="%register">register</a> to use this coupon',
|
||||
[
|
||||
'%sign' => $this->retrieveUrlFromRouteId('customer.login.view'),
|
||||
'%register' => $this->retrieveUrlFromRouteId('customer.create.view'),
|
||||
],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (PropelException $e) {
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
'Sorry, an error occurred: %message',
|
||||
["%message" => $e->getMessage()],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(
|
||||
sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage())
|
||||
);
|
||||
|
||||
$couponCodeForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($couponCodeForm)
|
||||
->setGeneralError($message);
|
||||
}
|
||||
|
||||
return $this->generateErrorRedirect($couponCodeForm);
|
||||
}
|
||||
}
|
||||
567
local/modules/Front/Controller/CustomerController.php
Normal file
567
local/modules/Front/Controller/CustomerController.php
Normal file
@@ -0,0 +1,567 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Front\Controller;
|
||||
|
||||
use Front\Front;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Customer\CustomerLoginEvent;
|
||||
use Thelia\Core\Event\LostPasswordEvent;
|
||||
use Thelia\Core\Event\Newsletter\NewsletterEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator;
|
||||
use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
use Thelia\Core\Security\Exception\UsernameNotFoundException;
|
||||
use Thelia\Core\Security\Exception\WrongPasswordException;
|
||||
use Thelia\Form\CustomerLogin;
|
||||
use Thelia\Form\Definition\FrontForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Customer;
|
||||
use Thelia\Model\NewsletterQuery;
|
||||
use Thelia\Tools\RememberMeTrait;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class CustomerController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class CustomerController extends BaseFrontController
|
||||
{
|
||||
use RememberMeTrait;
|
||||
|
||||
/**
|
||||
* Display the register template if no customer logged
|
||||
*/
|
||||
public function viewLoginAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser()) {
|
||||
// Redirect to home page
|
||||
return $this->generateRedirect(URL::getInstance()->getIndexPage());
|
||||
}
|
||||
|
||||
return $this->render("login");
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the register template if no customer logged
|
||||
*/
|
||||
public function viewRegisterAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser()) {
|
||||
// Redirect to home page
|
||||
return $this->generateRedirect(URL::getInstance()->getIndexPage());
|
||||
}
|
||||
|
||||
return $this->render("register");
|
||||
}
|
||||
|
||||
public function newPasswordAction()
|
||||
{
|
||||
$passwordLost = $this->createForm(FrontForm::CUSTOMER_LOST_PASSWORD);
|
||||
|
||||
if (! $this->getSecurityContext()->hasCustomerUser()) {
|
||||
try {
|
||||
$form = $this->validateForm($passwordLost);
|
||||
|
||||
$event = new LostPasswordEvent($form->get("email")->getData());
|
||||
|
||||
$this->dispatch(TheliaEvents::LOST_PASSWORD, $event);
|
||||
|
||||
return $this->generateSuccessRedirect($passwordLost);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Please check your input: %s",
|
||||
[
|
||||
'%s' => $e->getMessage()
|
||||
],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Sorry, an error occurred: %s",
|
||||
[
|
||||
'%s' => $e->getMessage()
|
||||
],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(
|
||||
sprintf(
|
||||
"Error during customer creation process : %s. Exception was %s",
|
||||
$message,
|
||||
$e->getMessage()
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"You're currently logged in. Please log out before requesting a new password.",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
}
|
||||
|
||||
$passwordLost->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($passwordLost)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
|
||||
// Redirect to error URL if defined
|
||||
if ($passwordLost->hasErrorUrl()) {
|
||||
return $this->generateErrorRedirect($passwordLost);
|
||||
}
|
||||
}
|
||||
|
||||
public function newPasswordSentAction()
|
||||
{
|
||||
$this->getParser()->assign('password_sent', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new customer.
|
||||
* On success, redirect to success_url if exists, otherwise, display the same view again.
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
if (! $this->getSecurityContext()->hasCustomerUser()) {
|
||||
$customerCreation = $this->createForm(FrontForm::CUSTOMER_CREATE);
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($customerCreation, "post");
|
||||
|
||||
$customerCreateEvent = $this->createEventInstance($form->getData());
|
||||
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent);
|
||||
|
||||
$newCustomer = $customerCreateEvent->getCustomer();
|
||||
|
||||
// Newsletter
|
||||
if (true === $form->get('newsletter')->getData()) {
|
||||
$newsletterEmail = $newCustomer->getEmail();
|
||||
$nlEvent = new NewsletterEvent(
|
||||
$newsletterEmail,
|
||||
$this->getRequest()->getSession()->getLang()->getLocale()
|
||||
);
|
||||
$nlEvent->setFirstname($newCustomer->getFirstname());
|
||||
$nlEvent->setLastname($newCustomer->getLastname());
|
||||
|
||||
// Security : Check if this new Email address already exist
|
||||
if (null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterEmail)) {
|
||||
$nlEvent->setId($newsletter->getId());
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_UPDATE, $nlEvent);
|
||||
} else {
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $nlEvent);
|
||||
}
|
||||
}
|
||||
|
||||
$this->processLogin($customerCreateEvent->getCustomer());
|
||||
|
||||
$cart = $this->getSession()->getSessionCart($this->getDispatcher());
|
||||
if ($cart->getCartItems()->count() > 0) {
|
||||
$response = $this->generateRedirectFromRoute('cart.view');
|
||||
} else {
|
||||
$response = $this->generateSuccessRedirect($customerCreation);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Please check your input: %s",
|
||||
[
|
||||
'%s' => $e->getMessage()
|
||||
],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Sorry, an error occured: %s",
|
||||
[
|
||||
'%s' => $e->getMessage()
|
||||
],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
}
|
||||
|
||||
Tlog::getInstance()->error(
|
||||
sprintf(
|
||||
"Error during customer creation process : %s. Exception was %s",
|
||||
$message,
|
||||
$e->getMessage()
|
||||
)
|
||||
);
|
||||
|
||||
$customerCreation->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($customerCreation)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
|
||||
// Redirect to error URL if defined
|
||||
if ($customerCreation->hasErrorUrl()) {
|
||||
return $this->generateErrorRedirect($customerCreation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare customer data update.
|
||||
*/
|
||||
public function viewAction()
|
||||
{
|
||||
$this->checkAuth();
|
||||
|
||||
/** @var Customer $customer */
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$data = array(
|
||||
'id' => $customer->getId(),
|
||||
'title' => $customer->getTitleId(),
|
||||
'firstname' => $customer->getFirstName(),
|
||||
'lastname' => $customer->getLastName(),
|
||||
'email' => $customer->getEmail(),
|
||||
'email_confirm' => $customer->getEmail(),
|
||||
'newsletter' => null !== NewsletterQuery::create()->findOneByEmail($customer->getEmail()),
|
||||
);
|
||||
|
||||
$customerProfileUpdateForm = $this->createForm(FrontForm::CUSTOMER_PROFILE_UPDATE, 'form', $data);
|
||||
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($customerProfileUpdateForm);
|
||||
}
|
||||
|
||||
public function updatePasswordAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser()) {
|
||||
$customerPasswordUpdateForm = $this->createForm(FrontForm::CUSTOMER_PASSWORD_UPDATE);
|
||||
|
||||
try {
|
||||
/** @var Customer $customer */
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$form = $this->validateForm($customerPasswordUpdateForm, "post");
|
||||
|
||||
$customerChangeEvent = $this->createEventInstance($form->getData());
|
||||
$customerChangeEvent->setCustomer($customer);
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEPROFILE, $customerChangeEvent);
|
||||
|
||||
return $this->generateSuccessRedirect($customerPasswordUpdateForm);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Please check your input: %s",
|
||||
[
|
||||
'%s' => $e->getMessage()
|
||||
],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Sorry, an error occured: %s",
|
||||
[
|
||||
'%s' => $e->getMessage()
|
||||
],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
}
|
||||
|
||||
Tlog::getInstance()->error(
|
||||
sprintf(
|
||||
"Error during customer password modification process : %s.",
|
||||
$message
|
||||
)
|
||||
);
|
||||
|
||||
$customerPasswordUpdateForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($customerPasswordUpdateForm)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
|
||||
// Redirect to error URL if defined
|
||||
if ($customerPasswordUpdateForm->hasErrorUrl()) {
|
||||
return $this->generateErrorRedirect($customerPasswordUpdateForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser()) {
|
||||
$customerProfileUpdateForm = $this->createForm(FrontForm::CUSTOMER_PROFILE_UPDATE);
|
||||
|
||||
try {
|
||||
/** @var Customer $customer */
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$newsletterOldEmail = $customer->getEmail();
|
||||
|
||||
$form = $this->validateForm($customerProfileUpdateForm, "post");
|
||||
|
||||
$customerChangeEvent = $this->createEventInstance($form->getData());
|
||||
$customerChangeEvent->setCustomer($customer);
|
||||
|
||||
$customerChangeEvent->setEmailUpdateAllowed(
|
||||
(intval(ConfigQuery::read('customer_change_email', 0))) ? true : false
|
||||
);
|
||||
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEPROFILE, $customerChangeEvent);
|
||||
|
||||
$updatedCustomer = $customerChangeEvent->getCustomer();
|
||||
|
||||
// Newsletter
|
||||
if (true === $form->get('newsletter')->getData()) {
|
||||
$nlEvent = new NewsletterEvent(
|
||||
$updatedCustomer->getEmail(),
|
||||
$this->getRequest()->getSession()->getLang()->getLocale()
|
||||
);
|
||||
$nlEvent->setFirstname($updatedCustomer->getFirstname());
|
||||
$nlEvent->setLastname($updatedCustomer->getLastname());
|
||||
|
||||
if (null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterOldEmail)) {
|
||||
$nlEvent->setId($newsletter->getId());
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_UPDATE, $nlEvent);
|
||||
} else {
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $nlEvent);
|
||||
}
|
||||
} else {
|
||||
if (null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterOldEmail)) {
|
||||
$nlEvent = new NewsletterEvent(
|
||||
$updatedCustomer->getEmail(),
|
||||
$this->getRequest()->getSession()->getLang()->getLocale()
|
||||
);
|
||||
$nlEvent->setId($newsletter->getId());
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_UNSUBSCRIBE, $nlEvent);
|
||||
}
|
||||
}
|
||||
|
||||
$this->processLogin($updatedCustomer);
|
||||
|
||||
return $this->generateSuccessRedirect($customerProfileUpdateForm);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Please check your input: %s",
|
||||
[
|
||||
'%s' => $e->getMessage()
|
||||
],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Sorry, an error occured: %s",
|
||||
[
|
||||
'%s' => $e->getMessage()
|
||||
],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
}
|
||||
|
||||
Tlog::getInstance()->error(sprintf("Error during customer modification process : %s.", $message));
|
||||
|
||||
$customerProfileUpdateForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($customerProfileUpdateForm)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
|
||||
// Redirect to error URL if defined
|
||||
if ($customerProfileUpdateForm->hasErrorUrl()) {
|
||||
return $this->generateErrorRedirect($customerProfileUpdateForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform user login. On a successful login, the user is redirected to the URL
|
||||
* found in the success_url form parameter, or / if none was found.
|
||||
*
|
||||
* If login is not successfull, the same view is displayed again.
|
||||
*
|
||||
*/
|
||||
public function loginAction()
|
||||
{
|
||||
if (!$this->getSecurityContext()->hasCustomerUser()) {
|
||||
$request = $this->getRequest();
|
||||
$customerLoginForm = new CustomerLogin($request);
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($customerLoginForm, "post");
|
||||
|
||||
// If User is a new customer
|
||||
if ($form->get('account')->getData() == 0 && $form->get("email")->getErrors()->count() == 0) {
|
||||
return $this->generateRedirectFromRoute(
|
||||
"customer.create.process",
|
||||
["email" => $form->get("email")->getData()]
|
||||
);
|
||||
} else {
|
||||
try {
|
||||
$authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm);
|
||||
|
||||
/** @var Customer $customer */
|
||||
$customer = $authenticator->getAuthentifiedUser();
|
||||
|
||||
$this->processLogin($customer);
|
||||
|
||||
if (intval($form->get('remember_me')->getData()) > 0) {
|
||||
// If a remember me field if present and set in the form, create
|
||||
// the cookie thant store "remember me" information
|
||||
$this->createRememberMeCookie(
|
||||
$customer,
|
||||
$this->getRememberMeCookieName(),
|
||||
$this->getRememberMeCookieExpiration()
|
||||
);
|
||||
}
|
||||
|
||||
return $this->generateSuccessRedirect($customerLoginForm);
|
||||
|
||||
} catch (UsernameNotFoundException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Wrong email or password. Please try again",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (WrongPasswordException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Wrong email or password. Please try again",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (AuthenticationException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Wrong email or password. Please try again",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Please check your input: %s",
|
||||
['%s' => $e->getMessage()],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Sorry, an error occured: %s",
|
||||
['%s' => $e->getMessage()],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
}
|
||||
|
||||
Tlog::getInstance()->error(
|
||||
sprintf(
|
||||
"Error during customer login process : %s. Exception was %s",
|
||||
$message,
|
||||
$e->getMessage()
|
||||
)
|
||||
);
|
||||
|
||||
$customerLoginForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()->addForm($customerLoginForm);
|
||||
|
||||
if ($customerLoginForm->hasErrorUrl()) {
|
||||
return $this->generateErrorRedirect($customerLoginForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform customer logout.
|
||||
*/
|
||||
public function logoutAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser()) {
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_LOGOUT);
|
||||
}
|
||||
|
||||
$this->clearRememberMeCookie($this->getRememberMeCookieName());
|
||||
|
||||
// Redirect to home page
|
||||
return $this->generateRedirect(URL::getInstance()->getIndexPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch event for customer login action
|
||||
*
|
||||
* @param Customer $customer
|
||||
*/
|
||||
protected function processLogin(Customer $customer)
|
||||
{
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_LOGIN, new CustomerLoginEvent($customer));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return \Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent
|
||||
*/
|
||||
private function createEventInstance($data)
|
||||
{
|
||||
$customerCreateEvent = new CustomerCreateOrUpdateEvent(
|
||||
isset($data["title"])?$data["title"]:null,
|
||||
isset($data["firstname"])?$data["firstname"]:null,
|
||||
isset($data["lastname"])?$data["lastname"]:null,
|
||||
isset($data["address1"])?$data["address1"]:null,
|
||||
isset($data["address2"])?$data["address2"]:null,
|
||||
isset($data["address3"])?$data["address3"]:null,
|
||||
isset($data["phone"])?$data["phone"]:null,
|
||||
isset($data["cellphone"])?$data["cellphone"]:null,
|
||||
isset($data["zipcode"])?$data["zipcode"]:null,
|
||||
isset($data["city"])?$data["city"]:null,
|
||||
isset($data["country"])?$data["country"]:null,
|
||||
isset($data["email"])?$data["email"]:null,
|
||||
isset($data["password"]) ? $data["password"]:null,
|
||||
$this->getRequest()->getSession()->getLang()->getId(),
|
||||
isset($data["reseller"])?$data["reseller"]:null,
|
||||
isset($data["sponsor"])?$data["sponsor"]:null,
|
||||
isset($data["discount"])?$data["discount"]:null,
|
||||
isset($data["company"])?$data["company"]:null,
|
||||
null,
|
||||
isset($data["state"])?$data["state"]:null
|
||||
);
|
||||
|
||||
return $customerCreateEvent;
|
||||
}
|
||||
|
||||
|
||||
protected function getRememberMeCookieName()
|
||||
{
|
||||
return ConfigQuery::read('customer_remember_me_cookie_name', 'crmcn');
|
||||
}
|
||||
|
||||
protected function getRememberMeCookieExpiration()
|
||||
{
|
||||
return ConfigQuery::read('customer_remember_me_cookie_expiration', 2592000 /* 1 month */);
|
||||
}
|
||||
}
|
||||
202
local/modules/Front/Controller/FeedController.php
Normal file
202
local/modules/Front/Controller/FeedController.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
|
||||
namespace Front\Controller;
|
||||
|
||||
use Doctrine\Common\Cache\FilesystemCache;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Model\BrandQuery;
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Lang;
|
||||
use Thelia\Model\LangQuery;
|
||||
|
||||
/**
|
||||
* Controller uses to generate RSS Feeds
|
||||
*
|
||||
* A default cache of 2 hours is used to avoid attack. You can flush cache if you have `ADMIN` role and pass flush=1 in
|
||||
* query string parameter.
|
||||
*
|
||||
* @package Front\Controller
|
||||
* @author Julien Chanséaume <jchanseaume@openstudio.fr>
|
||||
*/
|
||||
class FeedController extends BaseFrontController {
|
||||
|
||||
|
||||
/**
|
||||
* Folder name for feeds cache
|
||||
*/
|
||||
const FEED_CACHE_DIR = "feeds";
|
||||
|
||||
/**
|
||||
* Key prefix for feed cache
|
||||
*/
|
||||
const FEED_CACHE_KEY = "feed";
|
||||
|
||||
|
||||
/**
|
||||
* render the RSS feed
|
||||
*
|
||||
* @param $context string The context of the feed : catalog, content. default: catalog
|
||||
* @param $lang string The lang of the feed : fr_FR, en_US, ... default: default language of the site
|
||||
* @param $id string The id of the parent element. The id of the main parent category for catalog context.
|
||||
* The id of the content folder for content context
|
||||
* @return Response
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function generateAction($context, $lang, $id)
|
||||
{
|
||||
|
||||
/** @var Request $request */
|
||||
$request = $this->getRequest();
|
||||
|
||||
// context
|
||||
if ("" === $context){
|
||||
$context = "catalog";
|
||||
} else if (! in_array($context, array("catalog", "content", "brand")) ){
|
||||
$this->pageNotFound();
|
||||
}
|
||||
|
||||
// the locale : fr_FR, en_US,
|
||||
if ("" !== $lang) {
|
||||
if (! $this->checkLang($lang)){
|
||||
$this->pageNotFound();
|
||||
}
|
||||
} else {
|
||||
try{
|
||||
$lang = Lang::getDefaultLanguage();
|
||||
$lang = $lang->getLocale();
|
||||
} catch (\RuntimeException $ex){
|
||||
// @todo generate error page
|
||||
throw new \RuntimeException("No default language is defined. Please define one.");
|
||||
}
|
||||
}
|
||||
if (null === $lang = LangQuery::create()->findOneByLocale($lang)){
|
||||
$this->pageNotFound();
|
||||
}
|
||||
$lang = $lang->getId();
|
||||
|
||||
// check if element exists and is visible
|
||||
if ("" !== $id){
|
||||
if (false === $this->checkId($context, $id)){
|
||||
$this->pageNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
$flush = $request->query->get("flush", "");
|
||||
|
||||
// check if feed already in cache
|
||||
$cacheContent = false;
|
||||
|
||||
$cacheDir = $this->getCacheDir();
|
||||
$cacheKey = self::FEED_CACHE_KEY . $lang . $context . $id;
|
||||
$cacheExpire = intval(ConfigQuery::read("feed_ttl", '7200')) ?: 7200;
|
||||
|
||||
$cacheDriver = new FilesystemCache($cacheDir);
|
||||
if (!($this->checkAdmin() && "" !== $flush)){
|
||||
$cacheContent = $cacheDriver->fetch($cacheKey);
|
||||
} else {
|
||||
$cacheDriver->delete($cacheKey);
|
||||
}
|
||||
|
||||
// if not in cache
|
||||
if (false === $cacheContent){
|
||||
// render the view
|
||||
$cacheContent = $this->renderRaw(
|
||||
"feed",
|
||||
array(
|
||||
"_context_" => $context,
|
||||
"_lang_" => $lang,
|
||||
"_id_" => $id
|
||||
)
|
||||
);
|
||||
// save cache
|
||||
$cacheDriver->save($cacheKey, $cacheContent, $cacheExpire);
|
||||
}
|
||||
|
||||
$response = new Response();
|
||||
$response->setContent($cacheContent);
|
||||
$response->headers->set('Content-Type', 'application/rss+xml');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the cache directory for feeds
|
||||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
protected function getCacheDir()
|
||||
{
|
||||
$cacheDir = $this->container->getParameter("kernel.cache_dir");
|
||||
$cacheDir = rtrim($cacheDir, '/');
|
||||
$cacheDir .= '/' . self::FEED_CACHE_DIR . '/';
|
||||
|
||||
return $cacheDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current user has ADMIN role
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkAdmin(){
|
||||
return $this->getSecurityContext()->hasAdminUser();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a lang is used
|
||||
*
|
||||
* @param $lang string The lang code. e.g.: fr
|
||||
* @return bool true if the language is used, otherwise false
|
||||
*/
|
||||
private function checkLang($lang)
|
||||
{
|
||||
// load locals
|
||||
$lang = LangQuery::create()
|
||||
->findOneByLocale($lang);
|
||||
|
||||
return (null !== $lang);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the element exists and is visible
|
||||
*
|
||||
* @param $context string catalog or content
|
||||
* @param $id string id of the element
|
||||
* @return bool
|
||||
*/
|
||||
private function checkId($context, $id)
|
||||
{
|
||||
$ret = false;
|
||||
if (is_numeric($id)){
|
||||
if ("catalog" === $context){
|
||||
$cat = CategoryQuery::create()->findPk($id);
|
||||
$ret = (null !== $cat && $cat->getVisible());
|
||||
} elseif ("brand" === $context) {
|
||||
$brand = BrandQuery::create()->findPk($id);
|
||||
$ret = (null !== $brand && $brand->getVisible());
|
||||
} else {
|
||||
$folder = FolderQuery::create()->findPk($id);
|
||||
$ret = (null !== $folder && $folder->getVisible());
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
164
local/modules/Front/Controller/NewsletterController.php
Normal file
164
local/modules/Front/Controller/NewsletterController.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Front\Controller;
|
||||
|
||||
use Front\Front;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Core\Event\Newsletter\NewsletterEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\Definition\FrontForm;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\Customer;
|
||||
use Thelia\Model\NewsletterQuery;
|
||||
|
||||
/**
|
||||
* Class NewsletterController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <manu@raynaud.io>, Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class NewsletterController extends BaseFrontController
|
||||
{
|
||||
/**
|
||||
* @since 2.3.0-alpha2
|
||||
*/
|
||||
public function unsubscribeAction()
|
||||
{
|
||||
$errorMessage = false;
|
||||
|
||||
$newsletterForm = $this->createForm(FrontForm::NEWSLETTER_UNSUBSCRIBE);
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($newsletterForm);
|
||||
|
||||
$email = $form->get('email')->getData();
|
||||
|
||||
if (null !== $newsletter = NewsletterQuery::create()->findOneByEmail($email)) {
|
||||
$event = new NewsletterEvent(
|
||||
$email,
|
||||
$this->getRequest()->getSession()->getLang()->getLocale()
|
||||
);
|
||||
|
||||
$event->setId($newsletter->getId());
|
||||
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_UNSUBSCRIBE, $event);
|
||||
|
||||
// If a success URL is defined in the form, redirect to it, otherwise use the defaut view
|
||||
if ($newsletterForm->hasSuccessUrl() && !$this->getRequest()->isXmlHttpRequest()) {
|
||||
return $this->generateSuccessRedirect($newsletterForm);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
|
||||
Tlog::getInstance()->error(sprintf('Error during newsletter unsubscription : %s', $errorMessage));
|
||||
|
||||
$newsletterForm->setErrorMessage($errorMessage);
|
||||
}
|
||||
|
||||
// If Ajax Request
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
return new JsonResponse([
|
||||
"success" => ($errorMessage) ? false : true,
|
||||
"message" => ($errorMessage) ? $errorMessage : $this->getTranslator()->trans(
|
||||
"Your subscription to our newsletter has been canceled.",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
)
|
||||
], ($errorMessage) ? 500 : 200);
|
||||
}
|
||||
|
||||
$this->getParserContext()
|
||||
->setGeneralError($errorMessage)
|
||||
->addForm($newsletterForm);
|
||||
|
||||
// If an error URL is defined in the form, redirect to it, otherwise use the defaut view
|
||||
if ($errorMessage && $newsletterForm->hasErrorUrl()) {
|
||||
return $this->generateErrorRedirect($newsletterForm);
|
||||
}
|
||||
}
|
||||
|
||||
public function subscribeAction()
|
||||
{
|
||||
$errorMessage = false;
|
||||
|
||||
$newsletterForm = $this->createForm(FrontForm::NEWSLETTER);
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($newsletterForm);
|
||||
|
||||
$event = new NewsletterEvent(
|
||||
$form->get('email')->getData(),
|
||||
$this->getRequest()->getSession()->getLang()->getLocale()
|
||||
);
|
||||
|
||||
/** @var Customer $customer */
|
||||
if (null !== $customer = $this->getSecurityContext()->getCustomerUser()) {
|
||||
$event
|
||||
->setFirstname($customer->getFirstname())
|
||||
->setLastname($customer->getLastname())
|
||||
;
|
||||
} else {
|
||||
$event
|
||||
->setFirstname($form->get('firstname')->getData())
|
||||
->setLastname($form->get('lastname')->getData())
|
||||
;
|
||||
}
|
||||
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $event);
|
||||
|
||||
// If a success URL is defined in the form, redirect to it, otherwise use the defaut view
|
||||
if ($newsletterForm->hasSuccessUrl() && ! $this->getRequest()->isXmlHttpRequest()) {
|
||||
return $this->generateSuccessRedirect($newsletterForm);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
|
||||
Tlog::getInstance()->error(sprintf('Error during newsletter subscription : %s', $errorMessage));
|
||||
|
||||
$newsletterForm->setErrorMessage($errorMessage);
|
||||
}
|
||||
|
||||
// If Ajax Request
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
return new JsonResponse([
|
||||
"success" => ($errorMessage) ? false : true,
|
||||
"message" => ($errorMessage) ? $errorMessage : $this->getTranslator()->trans(
|
||||
"Thanks for signing up! We'll keep you posted whenever we have any new updates.",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
)
|
||||
], ($errorMessage) ? 500 : 200);
|
||||
}
|
||||
|
||||
$this->getParserContext()
|
||||
->setGeneralError($errorMessage)
|
||||
->addForm($newsletterForm);
|
||||
|
||||
// If an error URL is defined in the form, redirect to it, otherwise use the defaut view
|
||||
if ($errorMessage && $newsletterForm->hasErrorUrl()) {
|
||||
return $this->generateErrorRedirect($newsletterForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
599
local/modules/Front/Controller/OrderController.php
Normal file
599
local/modules/Front/Controller/OrderController.php
Normal file
@@ -0,0 +1,599 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Front\Controller;
|
||||
|
||||
use Front\Front;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Core\Event\Delivery\DeliveryPostageEvent;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
use Thelia\Core\Event\Product\VirtualProductOrderDownloadResponseEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Symfony\Component\HttpFoundation\Response as BaseResponse;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
use Thelia\Form\Definition\FrontForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\Address;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\AreaDeliveryModuleQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\Order;
|
||||
use Thelia\Model\OrderPostage;
|
||||
use Thelia\Model\OrderProductQuery;
|
||||
use Thelia\Model\OrderQuery;
|
||||
use Thelia\Module\AbstractDeliveryModule;
|
||||
use Thelia\Module\Exception\DeliveryException;
|
||||
|
||||
/**
|
||||
* Class OrderController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class OrderController extends BaseFrontController
|
||||
{
|
||||
/**
|
||||
* Check if the cart contains only virtual products.
|
||||
*/
|
||||
public function deliverView()
|
||||
{
|
||||
$this->checkAuth();
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
// check if the cart contains only virtual products
|
||||
$cart = $this->getSession()->getSessionCart($this->getDispatcher());
|
||||
|
||||
$deliveryAddress = $this->getCustomerAddress();
|
||||
|
||||
if ($cart->isVirtual()) {
|
||||
if (null !== $deliveryAddress) {
|
||||
$deliveryModule = ModuleQuery::create()->retrieveVirtualProductDelivery($this->container);
|
||||
|
||||
if (false === $deliveryModule) {
|
||||
Tlog::getInstance()->error(
|
||||
$this->getTranslator()->trans(
|
||||
"To enable the virtual product feature, the VirtualProductDelivery module should be activated",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
)
|
||||
);
|
||||
} elseif (count($deliveryModule) == 1) {
|
||||
return $this->registerVirtualProductDelivery($deliveryModule[0], $deliveryAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'order-delivery',
|
||||
[
|
||||
'delivery_address_id' => (null !== $deliveryAddress) ? $deliveryAddress->getId() : null
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractDeliveryModule $moduleInstance
|
||||
* @param Address $deliveryAddress
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
private function registerVirtualProductDelivery($moduleInstance, $deliveryAddress)
|
||||
{
|
||||
/* get postage amount */
|
||||
$deliveryModule = $moduleInstance->getModuleModel();
|
||||
$cart = $this->getSession()->getSessionCart($this->getDispatcher());
|
||||
$deliveryPostageEvent = new DeliveryPostageEvent($moduleInstance, $cart, $deliveryAddress);
|
||||
|
||||
$this->getDispatcher()->dispatch(
|
||||
TheliaEvents::MODULE_DELIVERY_GET_POSTAGE,
|
||||
$deliveryPostageEvent
|
||||
);
|
||||
|
||||
$postage = $deliveryPostageEvent->getPostage();
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
$orderEvent->setDeliveryAddress($deliveryAddress->getId());
|
||||
$orderEvent->setDeliveryModule($deliveryModule->getId());
|
||||
$orderEvent->setPostage($postage->getAmount());
|
||||
$orderEvent->setPostageTax($postage->getAmountTax());
|
||||
$orderEvent->setPostageTaxRuleTitle($postage->getTaxRuleTitle());
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_POSTAGE, $orderEvent);
|
||||
|
||||
return $this->generateRedirectFromRoute("order.invoice");
|
||||
}
|
||||
|
||||
/**
|
||||
* set delivery address
|
||||
* set delivery module
|
||||
*/
|
||||
public function deliver()
|
||||
{
|
||||
$this->checkAuth();
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
$message = false;
|
||||
|
||||
$orderDelivery = $this->createForm(FrontForm::ORDER_DELIVER);
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($orderDelivery, "post");
|
||||
|
||||
$deliveryAddressId = $form->get("delivery-address")->getData();
|
||||
$deliveryModuleId = $form->get("delivery-module")->getData();
|
||||
$deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId);
|
||||
$deliveryModule = ModuleQuery::create()->findPk($deliveryModuleId);
|
||||
|
||||
/* check that the delivery address belongs to the current customer */
|
||||
if ($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
|
||||
throw new \Exception(
|
||||
$this->getTranslator()->trans(
|
||||
"Delivery address does not belong to the current customer",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/* check that the delivery module fetches the delivery address area */
|
||||
if (null === AreaDeliveryModuleQuery::create()->findByCountryAndModule(
|
||||
$deliveryAddress->getCountry(),
|
||||
$deliveryModule
|
||||
)) {
|
||||
throw new \Exception(
|
||||
$this->getTranslator()->trans(
|
||||
"Delivery module cannot be use with selected delivery address",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/* get postage amount */
|
||||
$moduleInstance = $deliveryModule->getDeliveryModuleInstance($this->container);
|
||||
|
||||
$cart = $this->getSession()->getSessionCart($this->getDispatcher());
|
||||
$deliveryPostageEvent = new DeliveryPostageEvent($moduleInstance, $cart, $deliveryAddress);
|
||||
|
||||
$this->getDispatcher()->dispatch(
|
||||
TheliaEvents::MODULE_DELIVERY_GET_POSTAGE,
|
||||
$deliveryPostageEvent
|
||||
);
|
||||
|
||||
if (!$deliveryPostageEvent->isValidModule() || null === $deliveryPostageEvent->getPostage()) {
|
||||
throw new DeliveryException(
|
||||
$this->getTranslator()->trans('The delivery module is not valid.', [], Front::MESSAGE_DOMAIN)
|
||||
);
|
||||
}
|
||||
|
||||
$postage = $deliveryPostageEvent->getPostage();
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
$orderEvent->setDeliveryAddress($deliveryAddressId);
|
||||
$orderEvent->setDeliveryModule($deliveryModuleId);
|
||||
$orderEvent->setPostage($postage->getAmount());
|
||||
$orderEvent->setPostageTax($postage->getAmountTax());
|
||||
$orderEvent->setPostageTaxRuleTitle($postage->getTaxRuleTitle());
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_POSTAGE, $orderEvent);
|
||||
|
||||
return $this->generateRedirectFromRoute("order.invoice");
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Please check your input: %s",
|
||||
['%s' => $e->getMessage()],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (PropelException $e) {
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Sorry, an error occured: %s",
|
||||
['%s' => $e->getMessage()],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(
|
||||
sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage())
|
||||
);
|
||||
|
||||
$orderDelivery->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($orderDelivery)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set invoice address
|
||||
* set payment module
|
||||
*/
|
||||
public function invoice()
|
||||
{
|
||||
$this->checkAuth();
|
||||
$this->checkCartNotEmpty();
|
||||
$this->checkValidDelivery();
|
||||
|
||||
$message = false;
|
||||
|
||||
$orderPayment = $this->createForm(FrontForm::ORDER_PAYMENT);
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($orderPayment, "post");
|
||||
|
||||
$invoiceAddressId = $form->get("invoice-address")->getData();
|
||||
$paymentModuleId = $form->get("payment-module")->getData();
|
||||
|
||||
/* check that the invoice address belongs to the current customer */
|
||||
$invoiceAddress = AddressQuery::create()->findPk($invoiceAddressId);
|
||||
if ($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
|
||||
throw new \Exception(
|
||||
$this->getTranslator()->trans(
|
||||
"Invoice address does not belong to the current customer",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
$orderEvent->setInvoiceAddress($invoiceAddressId);
|
||||
$orderEvent->setPaymentModule($paymentModuleId);
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_INVOICE_ADDRESS, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_PAYMENT_MODULE, $orderEvent);
|
||||
|
||||
return $this->generateRedirectFromRoute("order.payment.process");
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Please check your input: %s",
|
||||
['%s' => $e->getMessage()],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
} catch (PropelException $e) {
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = $this->getTranslator()->trans(
|
||||
"Sorry, an error occured: %s",
|
||||
['%s' => $e->getMessage()],
|
||||
Front::MESSAGE_DOMAIN
|
||||
);
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(
|
||||
sprintf("Error during order payment process : %s. Exception was %s", $message, $e->getMessage())
|
||||
);
|
||||
|
||||
$orderPayment->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($orderPayment)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
|
||||
return $this->generateErrorRedirect($orderPayment);
|
||||
}
|
||||
|
||||
public function pay()
|
||||
{
|
||||
/* check customer */
|
||||
$this->checkAuth();
|
||||
|
||||
/* check cart count */
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
/* check stock not empty */
|
||||
if (true === ConfigQuery::checkAvailableStock()) {
|
||||
if (null !== $response = $this->checkStockNotEmpty()) {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
/* check delivery address and module */
|
||||
$this->checkValidDelivery();
|
||||
|
||||
/* check invoice address and payment module */
|
||||
$this->checkValidInvoice();
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_PAY, $orderEvent);
|
||||
|
||||
$placedOrder = $orderEvent->getPlacedOrder();
|
||||
|
||||
if (null !== $placedOrder && null !== $placedOrder->getId()) {
|
||||
/* order has been placed */
|
||||
if ($orderEvent->hasResponse()) {
|
||||
return $orderEvent->getResponse();
|
||||
} else {
|
||||
return $this->generateRedirectFromRoute(
|
||||
'order.placed',
|
||||
[],
|
||||
['order_id' => $orderEvent->getPlacedOrder()->getId()]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
/* order has not been placed */
|
||||
return $this->generateRedirectFromRoute('cart.view');
|
||||
}
|
||||
}
|
||||
|
||||
public function orderPlaced($order_id)
|
||||
{
|
||||
/* check if the placed order matched the customer */
|
||||
$placedOrder = OrderQuery::create()->findPk(
|
||||
$this->getRequest()->attributes->get('order_id')
|
||||
);
|
||||
|
||||
if (null === $placedOrder) {
|
||||
throw new TheliaProcessException(
|
||||
$this->getTranslator()->trans(
|
||||
"No placed order",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
),
|
||||
TheliaProcessException::NO_PLACED_ORDER,
|
||||
$placedOrder
|
||||
);
|
||||
}
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
if (null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) {
|
||||
throw new TheliaProcessException(
|
||||
$this->getTranslator()->trans(
|
||||
"Received placed order id does not belong to the current customer",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
),
|
||||
TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER,
|
||||
$placedOrder
|
||||
);
|
||||
}
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_CART_CLEAR, $this->getOrderEvent());
|
||||
|
||||
$this->getParserContext()->set("placed_order_id", $placedOrder->getId());
|
||||
}
|
||||
|
||||
|
||||
public function orderFailed($order_id, $message)
|
||||
{
|
||||
if (empty($order_id)) {
|
||||
// Fallback to request parameter if the method parameter is empty.
|
||||
$order_id = $this->getRequest()->get('order_id');
|
||||
}
|
||||
|
||||
$failedOrder = OrderQuery::create()->findPk($order_id);
|
||||
|
||||
if (null !== $failedOrder) {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
if (null === $customer || $failedOrder->getCustomerId() !== $customer->getId()) {
|
||||
throw new TheliaProcessException(
|
||||
$this->getTranslator()->trans(
|
||||
"Received failed order id does not belong to the current customer",
|
||||
[],
|
||||
Front::MESSAGE_DOMAIN
|
||||
),
|
||||
TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER,
|
||||
$failedOrder
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Tlog::getInstance()->warning("Failed order ID '$order_id' not found.");
|
||||
}
|
||||
|
||||
$this->getParserContext()
|
||||
->set("failed_order_id", $order_id)
|
||||
->set("failed_order_message", $message)
|
||||
;
|
||||
}
|
||||
|
||||
protected function getOrderEvent()
|
||||
{
|
||||
$order = $this->getOrder($this->getRequest());
|
||||
|
||||
return new OrderEvent($order);
|
||||
}
|
||||
|
||||
public function getOrder(Request $request)
|
||||
{
|
||||
$session = $request->getSession();
|
||||
|
||||
if (null !== $order = $session->getOrder()) {
|
||||
return $order;
|
||||
}
|
||||
|
||||
$order = new Order();
|
||||
|
||||
$session->setOrder($order);
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
|
||||
public function viewAction($order_id)
|
||||
{
|
||||
$this->checkOrderCustomer($order_id);
|
||||
|
||||
return $this->render('account-order', ['order_id' => $order_id]);
|
||||
}
|
||||
|
||||
public function generateInvoicePdf($order_id)
|
||||
{
|
||||
$this->checkOrderCustomer($order_id);
|
||||
|
||||
|
||||
return $this->generateOrderPdf($order_id, ConfigQuery::read('pdf_invoice_file', 'invoice'));
|
||||
}
|
||||
|
||||
public function generateDeliveryPdf($order_id)
|
||||
{
|
||||
$this->checkOrderCustomer($order_id);
|
||||
|
||||
return $this->generateOrderPdf($order_id, ConfigQuery::read('pdf_delivery_file', 'delivery'));
|
||||
}
|
||||
|
||||
public function downloadVirtualProduct($order_product_id)
|
||||
{
|
||||
if (null !== $orderProduct = OrderProductQuery::create()->findPk($order_product_id)) {
|
||||
$order = $orderProduct->getOrder();
|
||||
|
||||
if ($order->isPaid(false)) {
|
||||
// check customer
|
||||
$this->checkOrderCustomer($order->getId());
|
||||
|
||||
$virtualProductEvent = new VirtualProductOrderDownloadResponseEvent($orderProduct);
|
||||
$this->getDispatcher()->dispatch(
|
||||
TheliaEvents::VIRTUAL_PRODUCT_ORDER_DOWNLOAD_RESPONSE,
|
||||
$virtualProductEvent
|
||||
);
|
||||
|
||||
$response = $virtualProductEvent->getResponse();
|
||||
|
||||
if (!$response instanceof BaseResponse) {
|
||||
throw new \RuntimeException('A Response must be added in the event TheliaEvents::VIRTUAL_PRODUCT_ORDER_DOWNLOAD_RESPONSE');
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
throw new AccessDeniedHttpException();
|
||||
|
||||
}
|
||||
|
||||
private function checkOrderCustomer($order_id)
|
||||
{
|
||||
$this->checkAuth();
|
||||
|
||||
$order = OrderQuery::create()->findPk($order_id);
|
||||
$valid = true;
|
||||
if ($order) {
|
||||
$customerOrder = $order->getCustomer();
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
if ($customerOrder->getId() != $customer->getId()) {
|
||||
$valid = false;
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
if (false === $valid) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
}
|
||||
|
||||
public function getDeliveryModuleListAjaxAction()
|
||||
{
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
// Change the delivery address if customer has changed it
|
||||
$address = null;
|
||||
$session = $this->getSession();
|
||||
$addressId = $this->getRequest()->get('address_id', null);
|
||||
if (null !== $addressId && $addressId !== $session->getOrder()->getChoosenDeliveryAddress()) {
|
||||
$address = AddressQuery::create()->findPk($addressId);
|
||||
if (null !== $address && $address->getCustomerId() === $session->getCustomerUser()->getId()) {
|
||||
$session->getOrder()->setChoosenDeliveryAddress($addressId);
|
||||
}
|
||||
}
|
||||
|
||||
$address = AddressQuery::create()->findPk($session->getOrder()->getChoosenDeliveryAddress());
|
||||
|
||||
$countryId = $address->getCountryId();
|
||||
$stateId = $address->getStateId();
|
||||
|
||||
$args = array(
|
||||
'country' => $countryId,
|
||||
'state' => $stateId,
|
||||
'address' => $session->getOrder()->getChoosenDeliveryAddress()
|
||||
);
|
||||
|
||||
return $this->render('ajax/order-delivery-module-list', $args);
|
||||
}
|
||||
|
||||
private function checkStockNotEmpty()
|
||||
{
|
||||
$cart = $this->getSession()->getSessionCart($this->getDispatcher());
|
||||
$cartItems = $cart->getCartItems();
|
||||
$flagQuantity = 0;
|
||||
foreach ($cartItems as $cartItem) {
|
||||
$pse = $cartItem->getProductSaleElements();
|
||||
if ($pse->getQuantity() <= 0) {
|
||||
$flagQuantity = 1;
|
||||
}
|
||||
}
|
||||
if ($flagQuantity == 1) {
|
||||
return $this->generateRedirectFromRoute('cart.view');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the chosen delivery address for a cart or the default customer address if not exists
|
||||
*
|
||||
* @return null|Address
|
||||
*/
|
||||
protected function getCustomerAddress()
|
||||
{
|
||||
$deliveryAddress = null;
|
||||
$addressId = $this->getSession()->getOrder()->getChoosenDeliveryAddress();
|
||||
if (null === $addressId) {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$deliveryAddress = AddressQuery::create()
|
||||
->filterByCustomerId($customer->getId())
|
||||
->orderByIsDefault(Criteria::DESC)
|
||||
->findOne();
|
||||
|
||||
if (null !== $deliveryAddress) {
|
||||
$this->getSession()->getOrder()->setChoosenDeliveryAddress(
|
||||
$deliveryAddress->getId()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$deliveryAddress = AddressQuery::create()->findPk($addressId);
|
||||
}
|
||||
|
||||
return $deliveryAddress;
|
||||
}
|
||||
}
|
||||
150
local/modules/Front/Controller/SitemapController.php
Normal file
150
local/modules/Front/Controller/SitemapController.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
|
||||
namespace Front\Controller;
|
||||
|
||||
use Doctrine\Common\Cache\FilesystemCache;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\LangQuery;
|
||||
|
||||
/**
|
||||
* Controller uses to generate sitemap.xml
|
||||
*
|
||||
* A default cache of 2 hours is used to avoid attack. You can flush cache if you have `ADMIN` role and pass flush=1 in
|
||||
* query string parameter.
|
||||
*
|
||||
* You can generate sitemap according to specific language and/or specific context (catalog/content). You have to
|
||||
* use ```lang``` and ```context``` query string parameters to do so. If a language is not used in website or if the
|
||||
* context is not supported the page not found is displayed.
|
||||
*
|
||||
* {url}/sitemap?lang=fr&context=catalog will generate a sitemap for catalog (categories and products)
|
||||
* for french language.
|
||||
*
|
||||
* @package Front\Controller
|
||||
* @author Julien Chanséaume <jchanseaume@openstudio.fr>
|
||||
*/
|
||||
class SitemapController extends BaseFrontController {
|
||||
|
||||
|
||||
/**
|
||||
* Folder name for sitemap cache
|
||||
*/
|
||||
const SITEMAP_CACHE_DIR = "sitemap";
|
||||
|
||||
/**
|
||||
* Key prefix for sitemap cache
|
||||
*/
|
||||
const SITEMAP_CACHE_KEY = "sitemap";
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
public function generateAction()
|
||||
{
|
||||
/** @var Request $request */
|
||||
$request = $this->getRequest();
|
||||
|
||||
// the locale : fr, en,
|
||||
$lang = $request->query->get("lang", "");
|
||||
if ("" !== $lang) {
|
||||
if (! $this->checkLang($lang)){
|
||||
$this->pageNotFound();
|
||||
}
|
||||
}
|
||||
// specific content : product, category, cms
|
||||
$context = $request->query->get("context", "");
|
||||
if (! in_array($context, array("", "catalog", "content")) ){
|
||||
$this->pageNotFound();
|
||||
}
|
||||
|
||||
$flush = $request->query->get("flush", "");
|
||||
|
||||
// check if sitemap already in cache
|
||||
$cacheContent = false;
|
||||
|
||||
$cacheDir = $this->getCacheDir();
|
||||
$cacheKey = self::SITEMAP_CACHE_KEY . $lang . $context;
|
||||
$cacheExpire = intval(ConfigQuery::read("sitemap_ttl", '7200')) ?: 7200;
|
||||
|
||||
$cacheDriver = new FilesystemCache($cacheDir);
|
||||
if (!($this->checkAdmin() && "" !== $flush)){
|
||||
$cacheContent = $cacheDriver->fetch($cacheKey);
|
||||
} else {
|
||||
$cacheDriver->delete($cacheKey);
|
||||
}
|
||||
|
||||
// if not in cache
|
||||
if (false === $cacheContent){
|
||||
// render the view
|
||||
$cacheContent = $this->renderRaw(
|
||||
"sitemap",
|
||||
array(
|
||||
"_lang_" => $lang,
|
||||
"_context_" => $context
|
||||
)
|
||||
);
|
||||
// save cache
|
||||
$cacheDriver->save($cacheKey, $cacheContent, $cacheExpire);
|
||||
}
|
||||
|
||||
$response = new Response();
|
||||
$response->setContent($cacheContent);
|
||||
$response->headers->set('Content-Type', 'application/xml');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the cache directory for sitemap
|
||||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
protected function getCacheDir()
|
||||
{
|
||||
$cacheDir = $this->container->getParameter("kernel.cache_dir");
|
||||
$cacheDir = rtrim($cacheDir, '/');
|
||||
$cacheDir .= '/' . self::SITEMAP_CACHE_DIR . '/';
|
||||
|
||||
return $cacheDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current user has ADMIN role
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkAdmin(){
|
||||
return $this->getSecurityContext()->hasAdminUser();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a lang is used
|
||||
*
|
||||
* @param $lang The lang code. e.g.: fr
|
||||
* @return bool true if the language is used, otherwise false
|
||||
*/
|
||||
private function checkLang($lang)
|
||||
{
|
||||
// load locals
|
||||
$lang = LangQuery::create()
|
||||
->findOneByCode($lang);
|
||||
|
||||
return (null !== $lang);
|
||||
}
|
||||
|
||||
}
|
||||
31
local/modules/Front/Front.php
Normal file
31
local/modules/Front/Front.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Front;
|
||||
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
class Front extends BaseModule
|
||||
{
|
||||
const MESSAGE_DOMAIN = 'front';
|
||||
}
|
||||
22
local/modules/Front/I18n/de_DE.php
Normal file
22
local/modules/Front/I18n/de_DE.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'Coupon code can\'t be empty' => 'Gutschein-Code darf nicht leer sein',
|
||||
'Delivery address does not belong to the current customer' => 'Lieferadresse gehört nicht zum aktuellen Kunden',
|
||||
'Delivery module cannot be use with selected delivery address' => 'Lieferung-Modul kann nicht mit ausgewählten Lieferadresse verwendet werden',
|
||||
'Error during address deletion process' => 'Fehler beim Löschen der Adresse',
|
||||
'Failed to add this article to your cart, please try again' => 'Der Artikel konnte nicht zum Warenkorb hinzugefügt werden, bitte versuchen Sie es erneut',
|
||||
'Invoice address does not belong to the current customer' => 'Rechnungsadresse gehört nicht zum aktuellen Kunden',
|
||||
'No placed order' => 'Keine Bestellungen',
|
||||
'Please check your coupon code: %message' => 'Bitte überprüfen Sie Ihren Gutschein-Code: %message',
|
||||
'Please check your input: %s' => 'Bitte überprüfen Sie Ihre Eingabe: %s',
|
||||
'Received failed order id does not belong to the current customer' => 'Empfangene Id einer fehlgeschlagenen Bestellung gehört nicht zum aktuellen Kunden',
|
||||
'Received placed order id does not belong to the current customer' => 'Empfangene Bestellungs-Id gehört nicht zum aktuellen Kunden',
|
||||
'Sorry, an error occured: %s' => 'Leider ist ein Fehler aufgetreten: %s',
|
||||
'Sorry, an error occurred: %message' => 'Leider ist ein Fehler aufgetreten: %message',
|
||||
'Sorry, an error occurred: %s' => 'Es tut uns Leid, aber ein Fehler ist aufgetreten: %s',
|
||||
'Thanks for signing up! We\'ll keep you posted whenever we have any new updates.' => 'Vielen Dank für Ihre Anmeldung! Wir halten Ihnen auf dem Laufenden über neuen Updates.',
|
||||
'To enable the virtual product feature, the VirtualProductDelivery module should be activated' => 'Um das virtuelle Produkt-Feature zu aktivieren, sollte das VirtualProductDelivery-Modul aktiviert werden',
|
||||
'Wrong email or password. Please try again' => 'E-Mail oder Passwort falsch. Bitte erneut versuchen',
|
||||
'You\'re currently logged in. Please log out before requesting a new password.' => 'Sie sind derzeit angemeldet. Bitte melden Sie sich ab, bevor Sie ein neues Passwort anfordern.',
|
||||
];
|
||||
23
local/modules/Front/I18n/en_US.php
Normal file
23
local/modules/Front/I18n/en_US.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Coupon code can\'t be empty' => 'Coupon code can\'t be empty',
|
||||
'Delivery address does not belong to the current customer' => 'Delivery address does not belong to the current customer',
|
||||
'Delivery module cannot be use with selected delivery address' => 'Delivery module cannot be use with selected delivery address',
|
||||
'Error during address deletion process' => 'Error during address deletion process',
|
||||
'Failed to add this article to your cart, please try again' => 'Failed to add this article to your cart, please try again',
|
||||
'Invoice address does not belong to the current customer' => 'Invoice address does not belong to the current customer',
|
||||
'No placed order' => 'No placed order',
|
||||
'Please check your coupon code: %message' => 'Please check your coupon code: %message',
|
||||
'Please check your input: %s' => 'Please check your input: %s',
|
||||
'Received failed order id does not belong to the current customer' => 'Received failed order id does not belong to the current customer',
|
||||
'Received placed order id does not belong to the current customer' => 'Received placed order id does not belong to the current customer',
|
||||
'Sorry, an error occured: %s' => 'Sorry, an error occured: %s',
|
||||
'Sorry, an error occurred: %message' => 'Sorry, an error occurred: %message',
|
||||
'Sorry, an error occurred: %s' => 'Sorry, an error occurred: %s',
|
||||
'Thanks for signing up! We\'ll keep you posted whenever we have any new updates.' => 'Thanks for signing up! We\'ll keep you posted whenever we have any new updates.',
|
||||
'To enable the virtual product feature, the VirtualProductDelivery module should be activated' => 'To enable the virtual product feature, the VirtualProductDelivery module should be activated',
|
||||
'Wrong email or password. Please try again' => 'Wrong email or password. Please try again',
|
||||
'You should <a href="%sign">sign in</a> or <a href="%register">register</a> to use this coupon' => 'You should <a href="%sign">sign in</a> or <a href="%register">register</a> to use this coupon',
|
||||
'You\'re currently logged in. Please log out before requesting a new password.' => 'You\'re currently logged in. Please log out before requesting a new password.',
|
||||
);
|
||||
23
local/modules/Front/I18n/fr_FR.php
Normal file
23
local/modules/Front/I18n/fr_FR.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'Coupon code can\'t be empty' => 'Le code promo ne peut être vide',
|
||||
'Delivery address does not belong to the current customer' => 'L\'adresse de livraison n\'appartient pas au client en cours',
|
||||
'Delivery module cannot be use with selected delivery address' => 'Le module de livraison ne peut pas être utilisé avec cette adresse de livraison',
|
||||
'Error during address deletion process' => 'Désolé. Une erreur s\'est produite lors de la suppression de l\'adresse',
|
||||
'Failed to add this article to your cart, please try again' => 'Impossible d\'ajouter cet article à votre panier. Merci de ré-essayer.',
|
||||
'Invoice address does not belong to the current customer' => 'L\'adresse de facturation n\'appartient pas au client en cours',
|
||||
'No placed order' => 'Aucune commande passée',
|
||||
'Please check your coupon code: %message' => 'Merci de vérifier votre code promo : %message',
|
||||
'Please check your input: %s' => 'Merci de vérifier les informations indiquées : %s',
|
||||
'Received failed order id does not belong to the current customer' => 'L\'id de commande refusée n\'appartient pas au client en cours',
|
||||
'Received placed order id does not belong to the current customer' => 'L\'id de commande passée n\'appartient pas au client en cours',
|
||||
'Sorry, an error occured: %s' => 'Désolé. Une erreur s\'est produite : %s',
|
||||
'Sorry, an error occurred: %message' => 'Désolé. Une erreur s\'est produite : %message',
|
||||
'Sorry, an error occurred: %s' => 'Désolé, une erreur est survenue : %s',
|
||||
'Thanks for signing up! We\'ll keep you posted whenever we have any new updates.' => 'Merci de votre inscription ! Nous vous tiendrons informé dès qu\'il y aura des nouveautés.',
|
||||
'To enable the virtual product feature, the VirtualProductDelivery module should be activated' => 'Pour activer les produits virtuels, le module VirtualProductDelivery doit être activé',
|
||||
'Wrong email or password. Please try again' => 'Adresse email ou mot de passe incorrect. Merci de ré-essayer.',
|
||||
'You should <a href="%sign">sign in</a> or <a href="%register">register</a> to use this coupon' => 'Vous devez <a href="%sign"> vous connecter</a> ou <a href="%register"> vous inscrire</a> pour utiliser ce coupon',
|
||||
'You\'re currently logged in. Please log out before requesting a new password.' => 'Vous être actuellement connecté au site. Vous devez vous déconnecter pour demander un nouveau mot de passe.',
|
||||
];
|
||||
7
local/modules/Front/I18n/it_IT.php
Normal file
7
local/modules/Front/I18n/it_IT.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'Coupon code can\'t be empty' => 'Il codice di sconto non può essere vuoto',
|
||||
'Thanks for signing up! We\'ll keep you posted whenever we have any new updates.' => 'Grazie per l\'inscrizione! Ti terremo aggiornato ogni volta che abbiamo eventuali nuovi aggiornamenti.',
|
||||
'You should <a href="%sign">sign in</a> or <a href="%register">register</a> to use this coupon' => 'Dovresti <a href="%sign"> accedere</a> o <a href="%register"> registrarti</a> per utilizzare questo coupon',
|
||||
];
|
||||
22
local/modules/Front/I18n/tr_TR.php
Normal file
22
local/modules/Front/I18n/tr_TR.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'Coupon code can\'t be empty' => 'Kupon şifre boş olamaz',
|
||||
'Delivery address does not belong to the current customer' => 'Teslimat adresi geçerli müşteriye ait değil',
|
||||
'Delivery module cannot be use with selected delivery address' => 'Teslim modülü seçili teslimat adresi kullanılamaz',
|
||||
'Error during address deletion process' => 'Adres silme işlemi sırasında bir hata oluştu',
|
||||
'Failed to add this article to your cart, please try again' => 'Sepetinize Bu ürün eklenemedi, lütfen tekrar deneyin',
|
||||
'Invoice address does not belong to the current customer' => 'Fatura adresi geçerli müşteriye ait değil',
|
||||
'No placed order' => 'Yerleştirilen hiçbir sipariş',
|
||||
'Please check your coupon code: %message' => 'Kupon kodunuzu gözden geçirin: %message',
|
||||
'Please check your input: %s' => 'Lütfen girişinizi denetleyin: %s',
|
||||
'Received failed order id does not belong to the current customer' => 'Alınan başarısız sipariş kimliği geçerli müşteriye ait değil',
|
||||
'Received placed order id does not belong to the current customer' => 'Alınmış yerleştirilmiş sipariş kimliği geçerli müşteriye ait değil',
|
||||
'Sorry, an error occured: %s' => 'Üzgünüz, bir hata oluştu: %s',
|
||||
'Sorry, an error occurred: %message' => 'Üzgünüz, bir hata oluştu: %message',
|
||||
'Sorry, an error occurred: %s' => 'Üzgünüz, bir hata oluştu: %s',
|
||||
'Thanks for signing up! We\'ll keep you posted whenever we have any new updates.' => 'Teşekkürler. Yeni güncelleştirmeler olduğunda sizi haberdar edeceğiz.',
|
||||
'To enable the virtual product feature, the VirtualProductDelivery module should be activated' => 'Sanal ürün özelliği etkinleştirmek için VirtualProductDelivery modülü etkinleştirilmesi',
|
||||
'Wrong email or password. Please try again' => 'Email adresi veya şifre hatalı. Lütfen tekrar deneyiniz',
|
||||
'You\'re currently logged in. Please log out before requesting a new password.' => 'Şu anda logged içinde. Lütfen yeni bir parola istemeden önce çıkış.',
|
||||
];
|
||||
165
local/modules/Front/LICENSE.txt
Normal file
165
local/modules/Front/LICENSE.txt
Normal file
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
11
local/modules/Front/composer.json
Normal file
11
local/modules/Front/composer.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "thelia/front-module",
|
||||
"license": "LGPL-3.0+",
|
||||
"type": "thelia-module",
|
||||
"require": {
|
||||
"thelia/installer": "~1.1"
|
||||
},
|
||||
"extra": {
|
||||
"installer-name": "Front"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user