Merge branch 'master' of https://github.com/thelia/thelia into coupon
* 'master' of https://github.com/thelia/thelia: (87 commits) Missing ajax-loader icon don't use alternative Logger in debugbar if debug is disabled Remove debug bar Move temporarily fontawesome's font into the web folder Add loader css fix product visibility comparaison parameter Change this page on public page Bug : Remove close tag </a> decode url before searching if it's a rewritten url Modification font-size of price elements add page View All Add button "add product to cart" Footer : Static to dynamic content Add order on attribute_combination loop Fix bug in Content Loop with "current_folder" params Creation of Content page Change path /customer/account into /account Change path : /customer/update into /account/update /password into /account/password CustomerUpdateForm - Extend CustomerCreation Update profile - new method [Not finished yet] ...
This commit is contained in:
@@ -392,8 +392,6 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
|
||||
$dataType = $form->all();
|
||||
|
||||
$changeEvent = $this->getUpdateEvent($data);
|
||||
|
||||
$this->dispatch($this->updateEventIdentifier, $changeEvent);
|
||||
|
||||
39
core/lib/Thelia/Controller/Admin/AdminProfileController.php
Normal file
39
core/lib/Thelia/Controller/Admin/AdminProfileController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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 Thelia\Controller\Admin;
|
||||
|
||||
/**
|
||||
* Class AdminProfileController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AdminProfileController extends BaseAdminController
|
||||
{
|
||||
public function defaultAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.admin-profile.view")) return $response;
|
||||
return $this->render("admin-profiles", array("display_admin_profile" => 20));
|
||||
}
|
||||
|
||||
}
|
||||
39
core/lib/Thelia/Controller/Admin/LanguageController.php
Normal file
39
core/lib/Thelia/Controller/Admin/LanguageController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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 Thelia\Controller\Admin;
|
||||
|
||||
/**
|
||||
* Class LanguageController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LanguageController extends BaseAdminController
|
||||
{
|
||||
public function defaultAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.languages.view")) return $response;
|
||||
return $this->render("languages");
|
||||
}
|
||||
|
||||
}
|
||||
39
core/lib/Thelia/Controller/Admin/MailingSystemController.php
Normal file
39
core/lib/Thelia/Controller/Admin/MailingSystemController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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 Thelia\Controller\Admin;
|
||||
|
||||
/**
|
||||
* Class MailingSystemController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class MailingSystemController extends BaseAdminController
|
||||
{
|
||||
public function defaultAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.mailing-system.view")) return $response;
|
||||
return $this->render("mailing-system");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -68,6 +68,7 @@ class TaxController extends AbstractCrudController
|
||||
$event->setTitle($formData['title']);
|
||||
$event->setDescription($formData['description']);
|
||||
$event->setType($formData['type']);
|
||||
$event->setRequirements($this->getRequirements($formData['type'], $formData));
|
||||
|
||||
return $event;
|
||||
}
|
||||
@@ -76,16 +77,12 @@ class TaxController extends AbstractCrudController
|
||||
{
|
||||
$event = new TaxEvent();
|
||||
|
||||
/* check the requirements */
|
||||
if(!$this->checkRequirements($formData)) {
|
||||
|
||||
}
|
||||
|
||||
$event->setLocale($formData['locale']);
|
||||
$event->setId($formData['id']);
|
||||
$event->setTitle($formData['title']);
|
||||
$event->setDescription($formData['description']);
|
||||
$event->setType($formData['type']);
|
||||
$event->setRequirements($this->getRequirements($formData['type'], $formData));
|
||||
|
||||
return $event;
|
||||
}
|
||||
@@ -207,4 +204,24 @@ class TaxController extends AbstractCrudController
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function getRequirements($type, $formData)
|
||||
{
|
||||
$requirements = array();
|
||||
foreach($formData as $data => $value) {
|
||||
if(!strstr($data, ':')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$couple = explode(':', $data);
|
||||
|
||||
if(count($couple) != 2 || $couple[0] != $type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$requirements[$couple[1]] = $value;
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
}
|
||||
}
|
||||
@@ -236,6 +236,23 @@ class TaxRuleController extends AbstractCrudController
|
||||
return parent::updateAction();
|
||||
}
|
||||
|
||||
public function setDefaultAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
|
||||
|
||||
$setDefaultEvent = new TaxRuleEvent();
|
||||
|
||||
$taxRuleId = $this->getRequest()->attributes->get('tax_rule_id');
|
||||
|
||||
$setDefaultEvent->setId(
|
||||
$taxRuleId
|
||||
);
|
||||
|
||||
$this->dispatch(TheliaEvents::TAX_RULE_SET_DEFAULT, $setDefaultEvent);
|
||||
|
||||
$this->redirectToListTemplate();
|
||||
}
|
||||
|
||||
public function processUpdateTaxesAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
|
||||
@@ -31,10 +31,11 @@ use Thelia\Core\Security\Exception\UsernameNotFoundException;
|
||||
use Thelia\Form\CustomerCreation;
|
||||
use Thelia\Form\CustomerLogin;
|
||||
use Thelia\Form\CustomerLostPasswordForm;
|
||||
use Thelia\Form\CustomerModification;
|
||||
use Thelia\Form\CustomerUpdateForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\Customer;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Core\Security\Exception\WrongPasswordException;
|
||||
@@ -128,32 +129,56 @@ class CustomerController extends BaseFrontController
|
||||
}
|
||||
}
|
||||
|
||||
protected function getExistingCustomer($customer_id)
|
||||
{
|
||||
return CustomerQuery::create()
|
||||
->findOneById($customer_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update customer data. On success, redirect to success_url if exists.
|
||||
* Otherwise, display the same view again.
|
||||
*/
|
||||
public function viewAction()
|
||||
{
|
||||
$this->checkAuth();
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$data = array(
|
||||
'id' => $customer->getId(),
|
||||
'title' => $customer->getTitleId(),
|
||||
'firstname' => $customer->getFirstName(),
|
||||
'lastname' => $customer->getLastName(),
|
||||
'email' => $customer->getEmail(),
|
||||
);
|
||||
|
||||
$customerUpdateForm = new CustomerUpdateForm($this->getRequest(), 'form', $data);
|
||||
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($customerUpdateForm);
|
||||
}
|
||||
|
||||
public function updateAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser()) {
|
||||
|
||||
$message = false;
|
||||
|
||||
$customerModification = new CustomerModification($this->getRequest());
|
||||
$customerUpdateForm = new CustomerUpdateForm($this->getRequest());
|
||||
|
||||
try {
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$form = $this->validateForm($customerModification, "post");
|
||||
$form = $this->validateForm($customerUpdateForm, "post");
|
||||
|
||||
$customerChangeEvent = $this->createEventInstance($form->getData());
|
||||
$customerChangeEvent->setCustomer($customer);
|
||||
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEACCOUNT, $customerChangeEvent);
|
||||
|
||||
$this->processLogin($customerChangeEvent->getCustomer());
|
||||
|
||||
$this->redirectSuccess($customerModification);
|
||||
$this->redirectSuccess($customerUpdateForm);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
@@ -164,10 +189,10 @@ class CustomerController extends BaseFrontController
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during customer modification process : %s.", $message));
|
||||
|
||||
$customerModification->setErrorMessage($message);
|
||||
$customerUpdateForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($customerModification)
|
||||
->addForm($customerUpdateForm)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
@@ -193,31 +218,33 @@ class CustomerController extends BaseFrontController
|
||||
|
||||
$form = $this->validateForm($customerLoginForm, "post");
|
||||
|
||||
$authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm);
|
||||
// If User is a new customer
|
||||
if ($form->get('account')->getData() == 0 && !$form->get("email")->getErrors()) {
|
||||
$this->redirectToRoute("customer.create.view", array("email" => $form->get("email")->getData()));
|
||||
} else {
|
||||
|
||||
$customer = $authenticator->getAuthentifiedUser();
|
||||
try {
|
||||
|
||||
$this->processLogin($customer);
|
||||
$authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm);
|
||||
|
||||
$this->redirectSuccess($customerLoginForm);
|
||||
$customer = $authenticator->getAuthentifiedUser();
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$this->processLogin($customer);
|
||||
|
||||
if ($request->request->has("account")) {
|
||||
$account = $request->request->get("account");
|
||||
$form = $customerLoginForm->getForm();
|
||||
if ($account == 0 && $form->get("email")->getData() !== null) {
|
||||
$this->redirectToRoute("customer.create.view", array("email" => $form->get("email")->getData()));
|
||||
$this->redirectSuccess($customerLoginForm);
|
||||
|
||||
} catch (UsernameNotFoundException $e) {
|
||||
$message = "Wrong email or password. Please try again";
|
||||
} catch (WrongPasswordException $e) {
|
||||
$message = "Wrong email or password. Please try again";
|
||||
} catch (AuthenticationException $e) {
|
||||
$message = "Wrong email or password. Please try again";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (UsernameNotFoundException $e) {
|
||||
$message = "Wrong email or password. Please try again";
|
||||
} catch (WrongPasswordException $e) {
|
||||
$message = "Wrong email or password. Please try again";
|
||||
} catch (AuthenticationException $e) {
|
||||
$message = "Wrong email or password. Please try again";
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
@@ -265,14 +292,14 @@ class CustomerController extends BaseFrontController
|
||||
$data["title"],
|
||||
$data["firstname"],
|
||||
$data["lastname"],
|
||||
$data["address1"],
|
||||
$data["address2"],
|
||||
$data["address3"],
|
||||
$data["phone"],
|
||||
$data["cellphone"],
|
||||
$data["zipcode"],
|
||||
$data["city"],
|
||||
$data["country"],
|
||||
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(),
|
||||
|
||||
Reference in New Issue
Block a user