Merge branch 'master' of github.com:thelia/thelia
This commit is contained in:
@@ -73,11 +73,8 @@ class Address extends BaseAction implements EventSubscriberInterface
|
||||
$con = Propel::getWriteConnection(AddressTableMap::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
try {
|
||||
if ($addressModel->isNew()) {
|
||||
$addressModel->setLabel($event->getLabel());
|
||||
}
|
||||
|
||||
$addressModel
|
||||
->setLabel($event->getLabel())
|
||||
->setTitleId($event->getTitle())
|
||||
->setFirstname($event->getFirstname())
|
||||
->setLastname($event->getLastname())
|
||||
|
||||
@@ -60,7 +60,7 @@ class Customer extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
}
|
||||
|
||||
public function updateProfil(CustomerCreateOrUpdateEvent $event)
|
||||
public function updateProfile(CustomerCreateOrUpdateEvent $event)
|
||||
{
|
||||
|
||||
$customer = $event->getCustomer();
|
||||
@@ -166,7 +166,7 @@ class Customer extends BaseAction implements EventSubscriberInterface
|
||||
return array(
|
||||
TheliaEvents::CUSTOMER_CREATEACCOUNT => array('create', 128),
|
||||
TheliaEvents::CUSTOMER_UPDATEACCOUNT => array('modify', 128),
|
||||
TheliaEvents::CUSTOMER_UPDATEPROFIL => array('updateProfil', 128),
|
||||
TheliaEvents::CUSTOMER_UPDATEPROFILE => array('updateProfile', 128),
|
||||
TheliaEvents::CUSTOMER_LOGOUT => array('logout', 128),
|
||||
TheliaEvents::CUSTOMER_LOGIN => array('login', 128),
|
||||
TheliaEvents::CUSTOMER_DELETEACCOUNT => array('delete', 128),
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<form name="thelia.front.customer.login" class="Thelia\Form\CustomerLogin"/>
|
||||
<form name="thelia.front.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
|
||||
<form name="thelia.front.customer.create" class="Thelia\Form\CustomerCreateForm"/>
|
||||
<form name="thelia.front.customer.profil.update" class="Thelia\Form\CustomerProfilUpdateForm"/>
|
||||
<form name="thelia.front.customer.profile.update" class="Thelia\Form\CustomerProfileUpdateForm"/>
|
||||
<form name="thelia.front.customer.password.update" class="Thelia\Form\CustomerPasswordUpdateForm"/>
|
||||
<form name="thelia.front.address.create" class="Thelia\Form\AddressCreateForm"/>
|
||||
<form name="thelia.front.address.update" class="Thelia\Form\AddressUpdateForm"/>
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
</route>
|
||||
|
||||
<route id="cart.update.quantity" path="/cart/update">
|
||||
<default key="_controller">Thelia\Controller\Front\CartController::changeItem</default>
|
||||
<default key="_controller">Thelia\Controller\Front\CartController::changeItem</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
@@ -156,17 +156,51 @@ class AddressController extends BaseFrontController
|
||||
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()) {
|
||||
$this->redirectToRoute('default');
|
||||
// If Ajax Request
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
return $this->jsonResponse(json_encode(array(
|
||||
"success" => false,
|
||||
"message" => "Error during address deletion process"
|
||||
)));
|
||||
} else {
|
||||
$this->redirectToRoute('default');
|
||||
}
|
||||
}
|
||||
|
||||
$this->dispatch(TheliaEvents::ADDRESS_DELETE, new AddressEvent($address));
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::ADDRESS_DELETE, new AddressEvent($address));
|
||||
} catch (\Exception $e) {
|
||||
$error_message = $e->getMessage();
|
||||
}
|
||||
|
||||
$this->redirectToRoute('default', array('view'=>'account'));
|
||||
\Thelia\Log\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(array(
|
||||
"success" => true,
|
||||
"message" => ""
|
||||
)));;
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
} else {
|
||||
$this->redirectToRoute('default', array('view'=>'account'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function createAddressEvent($form)
|
||||
|
||||
@@ -56,7 +56,7 @@ class BaseFrontController extends BaseController
|
||||
public function checkAuth()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser() === false) {
|
||||
$this->redirectToRoute('default', array('view'=>'login'));
|
||||
$this->redirectToRoute('customer.login.process');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ use Thelia\Form\CustomerCreateForm;
|
||||
use Thelia\Form\CustomerLogin;
|
||||
use Thelia\Form\CustomerLostPasswordForm;
|
||||
use Thelia\Form\CustomerPasswordUpdateForm;
|
||||
use Thelia\Form\CustomerProfilUpdateForm;
|
||||
use Thelia\Form\CustomerProfileUpdateForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\Customer;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
@@ -149,10 +149,10 @@ class CustomerController extends BaseFrontController
|
||||
'newsletter' => null !== NewsletterQuery::create()->findOneByEmail($customer->getEmail()),
|
||||
);
|
||||
|
||||
$customerProfilUpdateForm = new CustomerProfilUpdateForm($this->getRequest(), 'form', $data);
|
||||
$customerProfileUpdateForm = new CustomerProfileUpdateForm($this->getRequest(), 'form', $data);
|
||||
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($customerProfilUpdateForm);
|
||||
$this->getParserContext()->addForm($customerProfileUpdateForm);
|
||||
}
|
||||
|
||||
public function updatePasswordAction()
|
||||
@@ -169,7 +169,7 @@ class CustomerController extends BaseFrontController
|
||||
|
||||
$customerChangeEvent = $this->createEventInstance($form->getData());
|
||||
$customerChangeEvent->setCustomer($customer);
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEPROFIL, $customerChangeEvent);
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEPROFILE, $customerChangeEvent);
|
||||
|
||||
$this->redirectSuccess($customerPasswordUpdateForm);
|
||||
|
||||
@@ -198,17 +198,17 @@ class CustomerController extends BaseFrontController
|
||||
|
||||
$message = false;
|
||||
|
||||
$customerProfilUpdateForm = new CustomerProfilUpdateForm($this->getRequest());
|
||||
$customerProfileUpdateForm = new CustomerProfileUpdateForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$newsletterOldEmail = $customer->getEmail();
|
||||
|
||||
$form = $this->validateForm($customerProfilUpdateForm, "post");
|
||||
$form = $this->validateForm($customerProfileUpdateForm, "post");
|
||||
|
||||
$customerChangeEvent = $this->createEventInstance($form->getData());
|
||||
$customerChangeEvent->setCustomer($customer);
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEPROFIL, $customerChangeEvent);
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEPROFILE, $customerChangeEvent);
|
||||
|
||||
$updatedCustomer = $customerChangeEvent->getCustomer();
|
||||
|
||||
@@ -234,7 +234,7 @@ class CustomerController extends BaseFrontController
|
||||
|
||||
$this->processLogin($updatedCustomer);
|
||||
|
||||
$this->redirectSuccess($customerProfilUpdateForm);
|
||||
$this->redirectSuccess($customerProfileUpdateForm);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
@@ -245,10 +245,10 @@ class CustomerController extends BaseFrontController
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during customer modification process : %s.", $message));
|
||||
|
||||
$customerProfilUpdateForm->setErrorMessage($message);
|
||||
$customerProfileUpdateForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($customerProfilUpdateForm)
|
||||
->addForm($customerProfileUpdateForm)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ class CustomerController extends BaseFrontController
|
||||
|
||||
// If User is a new customer
|
||||
if ($form->get('account')->getData() == 0 && !$form->get("email")->getErrors()) {
|
||||
$this->redirectToRoute("default", array("view" => "register","email" => $form->get("email")->getData()));
|
||||
$this->redirectToRoute("customer.create.process", array("email" => $form->get("email")->getData()));
|
||||
} else {
|
||||
|
||||
try {
|
||||
|
||||
@@ -72,9 +72,9 @@ final class TheliaEvents
|
||||
const CUSTOMER_UPDATEACCOUNT = "action.updateCustomer";
|
||||
|
||||
/**
|
||||
* sent on customer account update profil
|
||||
* sent on customer account update profile
|
||||
*/
|
||||
const CUSTOMER_UPDATEPROFIL = "action.updateProfilCustomer";
|
||||
const CUSTOMER_UPDATEPROFILE = "action.updateProfileCustomer";
|
||||
|
||||
/**
|
||||
* sent on customer removal
|
||||
|
||||
@@ -23,14 +23,15 @@
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
|
||||
/**
|
||||
* Class CustomerProfilUpdateForm
|
||||
* Class CustomerProfileUpdateForm
|
||||
* @package Thelia\Form
|
||||
* @author Christophe Laffont <claffont@openstudio.fr>
|
||||
*/
|
||||
class CustomerProfilUpdateForm extends CustomerCreateForm
|
||||
class CustomerProfileUpdateForm extends CustomerCreateForm
|
||||
{
|
||||
|
||||
protected function buildForm()
|
||||
@@ -81,6 +82,6 @@ class CustomerProfilUpdateForm extends CustomerCreateForm
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_customer_profil_update";
|
||||
return "thelia_customer_profile_update";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user