Merge branch 'master' into tax

Conflicts:
	core/lib/Thelia/Config/Resources/config.xml
	templates/admin/default/configuration.html
This commit is contained in:
Etienne Roudeix
2013-10-21 08:13:18 +02:00
93 changed files with 6046 additions and 3974 deletions

View File

@@ -55,6 +55,7 @@
<form name="thelia.install.step3" class="Thelia\Form\InstallStep3Form"/>
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
<form name="thelia.customer.update" class="Thelia\Form\CustomerUpdateForm"/>
<form name="thelia.customer.modification" class="Thelia\Form\CustomerModification"/>
<form name="thelia.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
@@ -130,6 +131,10 @@
<form name="thelia.admin.country.creation" class="Thelia\Form\CountryCreationForm"/>
<form name="thelia.admin.country.modification" class="Thelia\Form\CountryModificationForm"/>
<form name="thelia.admin.language.creation" class="Thelia\Form\LanguageCreationForm"/>
<form name="thelia.admin.admin-profile.creation" class="Thelia\Form\AdminProfileCreationForm"/>
<form name="thelia.admin.area.create" class="Thelia\Form\Area\AreaCreateForm"/>
<form name="thelia.admin.area.modification" class="Thelia\Form\Area\AreaModificationForm"/>

View File

@@ -4,22 +4,22 @@
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 to administration base -->
<!-- Route to administration base -->
<route id="admin" path="/admin">
<default key="_controller">Thelia\Controller\Admin\AdminController::indexAction</default>
</route>
<!-- Route to the administration login page -->
<!-- Route to the administration login page -->
<route id="admin.login" path="/admin/login">
<default key="_controller">Thelia\Controller\Admin\SessionController::showLoginAction</default>
</route>
<!-- Route to the administration logout page -->
<!-- Route to the administration logout page -->
<route id="admin.logout" path="/admin/logout">
<default key="_controller">Thelia\Controller\Admin\SessionController::checkLogoutAction</default>
</route>
<!-- Route to the login check controller -->
<!-- Route to the login check controller -->
<route id="admin.checklogin" path="/admin/checklogin">
<default key="_controller">Thelia\Controller\Admin\SessionController::checkLoginAction</default>
</route>
@@ -31,7 +31,7 @@
<!-- Route to the catalog controller -->
<!-- Route to the catalog controller -->
<route id="admin.catalog" path="/admin/catalog">
<default key="_controller">Thelia\Controller\Admin\CategoryController::defaultAction</default>
@@ -887,7 +887,7 @@
<!-- end tax rules management -->
<!-- The default route, to display a template -->
<!-- The default route, to display a template -->
<route id="admin.processTemplate" path="/admin/{template}">
<default key="_controller">Thelia\Controller\Admin\AdminController::processTemplateAction</default>

View File

@@ -4,56 +4,75 @@
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="home" path="/" >
<route id="home" path="/">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">index</default>
</route>
<!-- Customer routes -->
<!-- Search routes -->
<route id="search" path="/search">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">search</default>
</route>
<route id="view_all" path="/view_all" methods="get">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">view_all</default>
</route>
<!-- Customer routes : Register -->
<route id="customer.create.process" path="/register" methods="post">
<default key="_controller">Thelia\Controller\Front\CustomerController::createAction</default>
<default key="_view">register</default>
</route>
<route id="customer.create.view" path="/register">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">register</default>
</route>
<!-- Customer routes : Login -->
<route id="customer.login.process" path="/login" methods="post">
<default key="_controller">Thelia\Controller\Front\CustomerController::loginAction</default>
<default key="_view">login</default>
</route>
<route id="customer.login.view" path="/login">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">login</default>
</route>
<!-- Customer routes : Logout -->
<route id="customer.logout.process" path="/logout">
<default key="_controller">Thelia\Controller\Front\CustomerController::logoutAction</default>
</route>
<route id="customer.account.view" path="/customer/account">
<!-- Customer routes : Account -->
<route id="customer.account.view" path="/account">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">account</default>
</route>
<route id="customer.create.process" path="/customer/create" methods="post">
<default key="_controller">Thelia\Controller\Front\CustomerController::createAction</default>
<default key="_view">register</default>
<route id="customer.update.view" path="/account/update" methods="get">
<default key="_controller">Thelia\Controller\Front\CustomerController::viewAction</default>
<default key="_view">account-update</default>
</route>
<route id="customer.update.process" path="/customer/update" methods="post">
<route id="customer.update.process" path="/account/update" methods="post">
<default key="_controller">Thelia\Controller\Front\CustomerController::updateAction</default>
</route>
<route id="customer.login.process" path="/customer/login" methods="post">
<default key="_controller">Thelia\Controller\Front\CustomerController::loginAction</default>
<default key="_view">login</default>
<default key="_view">account-update</default>
</route>
<route id="customer.password.retrieve.view" path="/password" methods="get">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">password</default>
</route>
<route id="customer.password.retrieve.process" path="/password" methods="post">
<route id="customer.password.retrieve.process" path="/account/password" methods="post">
<default key="_controller">Thelia\Controller\Front\CustomerController::newPasswordAction</default>
<default key="_view">password</default>
<default key="_view">account-password</default>
</route>
<route id="customer.password.retrieve.view" path="account/password" methods="get">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">account-password</default>
</route>
<!-- end customer routes -->

View 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));
}
}

View 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");
}
}

View 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");
}
}

View File

@@ -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(),

View File

@@ -102,6 +102,7 @@ class Cart extends BaseLoop
->set("TAXED_PRICE", $cartItem->getTaxedPrice($taxCountry))
->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice($taxCountry))
->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0);
$loopResultRow->set("PRODUCT_SALE_ELEMENTS_ID", $productSaleElement->getId());
$result->addRow($loopResultRow);
}

View File

@@ -86,6 +86,7 @@ class Content extends BaseI18nLoop
*/
public function exec(&$pagination)
{
$search = ContentQuery::create();
/* manage translations */
@@ -138,27 +139,15 @@ class Content extends BaseI18nLoop
$current_folder = $this->getCurrent_folder();
if ($current_folder === true) {
$search->filterByFolder(
FolderQuery::create()->filterByContent(
ContentFolderQuery::create()->filterByContentId(
$this->request->get("content_id"),
Criteria::EQUAL
)->find(),
Criteria::IN
)->find(),
Criteria::IN
);
$current = ContentQuery::create()->findPk($this->request->get("content_id"));
$search->filterByFolder($current->getFolders(), Criteria::IN);
} elseif ($current_folder === false) {
$search->filterByFolder(
FolderQuery::create()->filterByContent(
ContentFolderQuery::create()->filterByContentId(
$this->request->get("content_id"),
Criteria::EQUAL
)->find(),
Criteria::IN
)->find(),
Criteria::NOT_IN
);
$current = ContentQuery::create()->findPk($this->request->get("content_id"));
$search->filterByFolder($current->getFolders(), Criteria::NOT_IN);
}
$visible = $this->getVisible();

View File

@@ -87,6 +87,7 @@ class Product extends BaseI18nLoop
Argument::createIntTypeArgument('depth', 1),
Argument::createBooleanOrBothTypeArgument('visible', 1),
Argument::createIntTypeArgument('currency'),
Argument::createAnyTypeArgument('title'),
new Argument(
'order',
new TypeCollection(
@@ -171,6 +172,17 @@ class Product extends BaseI18nLoop
$search->filterByRef($ref, Criteria::IN);
}
$title = $this->getTitle();
if(!is_null($title)){
$search->where(" CASE WHEN NOT ISNULL(`requested_locale_i18n`.ID) THEN `requested_locale_i18n`.`TITLE` ELSE `default_locale_i18n`.`TITLE` END ".Criteria::LIKE." ?", "%".$title."%", \PDO::PARAM_STR);
}
$category = $this->getCategory();
$categoryDefault = $this->getCategoryDefault();
@@ -461,7 +473,7 @@ class Product extends BaseI18nLoop
$visible = $this->getVisible();
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
if ($visible !== BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
$exclude = $this->getExclude();

View File

@@ -124,12 +124,8 @@ class Form extends AbstractSmartyPlugin
$template->assign("value", $fieldValue);
$template->assign("options", $formFieldView->vars);
$template->assign("checked", isset($fieldVars['checked']) ? $fieldVars['checked'] : false);
// If Checkbox input type
if ($fieldVars['checked'] !== null) {
$this->renderFormFieldCheckBox($template, $formFieldView['checked']);
}
//data
$template->assign("data", $fieldVars['data']);
@@ -137,6 +133,8 @@ class Form extends AbstractSmartyPlugin
$template->assign("label", $fieldVars["label"]);
$template->assign("label_attr", $fieldVars["label_attr"]);
$template->assign('required', isset($fieldVars['required']) ? $fieldVars['required'] : false);
$errors = $fieldVars["errors"];
$template->assign("error", empty($errors) ? false : true);
@@ -177,6 +175,7 @@ class Form extends AbstractSmartyPlugin
if($formFieldType instanceof TheliaType) {
$template->assign("formType", $formFieldView->vars['type']);
switch($formFieldView->vars['type']) {
case "choice":
if(!isset($formFieldView->vars['options']['choices']) || !is_array($formFieldView->vars['options']['choices'])) {
@@ -429,17 +428,4 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
new SmartyPluginDescriptor("block", "form_error", $this, "formError")
);
}
/**
* @param \Smarty_Internal_Template $template
* @param $formFieldView
*/
public function renderFormFieldCheckBox(\Smarty_Internal_Template $template, $isChecked)
{
$template->assign("value", 0);
if ($isChecked) {
$template->assign("value", 1);
}
$template->assign("value", $isChecked);
}
}

View File

@@ -0,0 +1,65 @@
<?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\Form;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
class AdminProfileCreationForm extends BaseForm
{
protected function buildForm()
{
$this->formBuilder
->add("wording" , "text" , array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Wording *"),
"label_attr" => array(
"for" => "wording"
))
)
->add("name" , "text" , array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Name *"),
"label_attr" => array(
"for" => "name"
))
)
->add("description" , "text" , array(
"label" => Translator::getInstance()->trans("Description"),
"label_attr" => array(
"for" => "description"
))
)
;
}
public function getName()
{
return "thelia_admin_profile_creation";
}
}

View File

@@ -40,6 +40,16 @@ class CustomerCreation extends BaseForm
{
$this->formBuilder
->add("auto_login", "integer")
// Personal Informations
->add("title", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array(
"for" => "title"
)
))
->add("firstname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
@@ -58,84 +68,6 @@ class CustomerCreation extends BaseForm
"for" => "lastname"
)
))
->add("address1", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label_attr" => array(
"for" => "address"
),
"label" => Translator::getInstance()->trans("Street Address"),
"label_attr" => array(
"for" => "address1"
)
))
->add("address2", "text", array(
"label" => Translator::getInstance()->trans("Address Line 2"),
"label_attr" => array(
"for" => "address2"
)
))
->add("address3", "text", array(
"label" => Translator::getInstance()->trans("Address Line 3"),
"label_attr" => array(
"for" => "address3"
)
))
->add("company", "text", array(
"label" => Translator::getInstance()->trans("Company Name"),
"label_attr" => array(
"for" => "company"
)
))
->add("phone", "text", array(
"label" => Translator::getInstance()->trans("Phone"),
"label_attr" => array(
"for" => "phone"
)
))
->add("cellphone", "text", array(
"label" => Translator::getInstance()->trans("Cellphone"),
"label_attr" => array(
"for" => "cellphone"
)
))
->add("zipcode", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Zip code"),
"label_attr" => array(
"for" => "zipcode"
)
))
->add("city", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("City"),
"label_attr" => array(
"for" => "city"
)
))
->add("country", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Country"),
"label_attr" => array(
"for" => "country"
)
))
->add("title", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array(
"for" => "title"
)
))
->add("email", "email", array(
"constraints" => array(
new Constraints\NotBlank(),
@@ -143,7 +75,7 @@ class CustomerCreation extends BaseForm
new Constraints\Callback(array(
"methods" => array(
array($this,
"verifyExistingEmail")
"verifyExistingEmail")
)
))
),
@@ -163,6 +95,79 @@ class CustomerCreation extends BaseForm
),
"label" => "email confirmation"
))*/
->add("phone", "text", array(
"label" => Translator::getInstance()->trans("Phone"),
"label_attr" => array(
"for" => "phone"
),
"required" => false
))
->add("cellphone", "text", array(
"label" => Translator::getInstance()->trans("Cellphone"),
"label_attr" => array(
"for" => "cellphone"
),
"required" => false
))
// Delivery Informations
->add("company", "text", array(
"label" => Translator::getInstance()->trans("Company Name"),
"label_attr" => array(
"for" => "company"
),
"required" => false
))
->add("address1", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Street Address"),
"label_attr" => array(
"for" => "address1"
)
))
->add("address2", "text", array(
"label" => Translator::getInstance()->trans("Address Line 2"),
"label_attr" => array(
"for" => "address2"
),
"required" => false
))
->add("address3", "text", array(
"label" => Translator::getInstance()->trans("Address Line 3"),
"label_attr" => array(
"for" => "address3"
),
"required" => false
))
->add("city", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("City"),
"label_attr" => array(
"for" => "city"
)
))
->add("zipcode", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Zip code"),
"label_attr" => array(
"for" => "zipcode"
)
))
->add("country", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Country"),
"label_attr" => array(
"for" => "country"
)
))
// Login Information
->add("password", "password", array(
"constraints" => array(
new Constraints\NotBlank(),
@@ -186,8 +191,14 @@ class CustomerCreation extends BaseForm
"for" => "password_confirmation"
)
))
;
->add("agreed", "checkbox", array(
"constraints" => array(
new Constraints\True(array("message" => "Please accept the Terms and conditions in order to register."))
),
"label_attr" => array(
"for" => "agreed"
)
));
}
public function verifyPasswordField($value, ExecutionContextInterface $context)

View File

@@ -22,10 +22,19 @@
/*************************************************************************************/
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Model\Base\CustomerQuery;
/**
* Class CustomerLogin
* @package Thelia\Form
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CustomerLogin extends BaseForm
{
protected function buildForm()
@@ -33,27 +42,82 @@ class CustomerLogin extends BaseForm
$this->formBuilder
->add("email", "email", array(
"constraints" => array(
new NotBlank(),
new Email()
new Constraints\NotBlank(),
new Constraints\Email(),
new Constraints\Callback(array(
"methods" => array(
array($this, "verifyExistingEmail")
)
))
),
"label" => Translator::getInstance()->trans("Please enter your email address"),
"label_attr" => array(
"for" => "email"
)
))
->add("account", "choice", array(
"constraints" => array(
new Constraints\Callback(array(
"methods" => array(
array($this, "verifyAccount")
)
))
),
"required" => true
"choices" => array(
0 => Translator::getInstance()->trans("No, I am a new customer."),
1 => Translator::getInstance()->trans("Yes, I have a password :")
),
"label_attr" => array(
"for" => "account"
),
"data" => 0
))
->add("password", "password", array(
"constraints" => array(
new NotBlank()
),
/*"constraints" => array(
new Constraints\NotBlank()
),*/
"label" => Translator::getInstance()->trans("Please enter your password"),
"label_attr" => array(
"for" => "password"
),
"required" => true
))
->add("remember_me", "checkbox")
;
"required" => false
));
}
/**
* If the user select "Yes, I have a password", we check the password.
*/
public function verifyAccount($value, ExecutionContextInterface $context)
{
if ($value == 1) {
$data = $context->getRoot()->getData();
if (false === $data['password'] || (empty($data['password']) && '0' != $data['password'])) {
$context->getViolations()->add(new ConstraintViolation(
'This value should not be blank.',
'account_password',
array(),
$context->getRoot(),
'children[password].data',
'propertyPath'
));
}
}
}
/**
* If the user select "I'am a new customer", we make sure is email address does not exit in the database.
*/
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
if ($data["account"] == 0) {
$customer = CustomerQuery::create()->findOneByEmail($value);
if ($customer) {
$context->addViolation("A user already exists with this email address. Please login or if you've forgotten your password, go to Reset Your Password.");
}
}
}
public function getName()

View File

@@ -82,7 +82,7 @@ class CustomerLostPasswordForm extends BaseForm
{
$customer = CustomerQuery::create()->findOneByEmail($value);
if (null === $customer) {
$context->addViolation("This email does not exists exists");
$context->addViolation("This email does not exists");
}
}

View File

@@ -0,0 +1,75 @@
<?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\Form;
use Symfony\Component\Validator\Constraints;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Translation\Translator;
/**
* Class CustomerUpdateForm
* @package Thelia\Form
* @author Christophe Laffont <claffont@openstudio.fr>
*/
class CustomerUpdateForm extends CustomerCreation
{
protected function buildForm()
{
parent::buildForm();
$this->formBuilder
->remove("auto_login")
// Remove From Personal Informations
->remove("phone")
->remove("cellphone")
// Remove Delivery Informations
->remove("company")
->remove("address1")
->remove("address2")
->remove("address3")
->remove("city")
->remove("zipcode")
->remove("country")
// Remove Login Information
->remove("password")
->remove("password_confirm")
// Remove Terms & conditions
->remove("agreed")
// Add Newsletter
->add("newsletter", "checkbox", array(
"label" => "I would like to receive the newsletter our the latest news.",
"label_attr" => array(
"for" => "newsletter"
),
"required" => false
));
}
public function getName()
{
return "thelia_customer_update";
}
}

View File

@@ -0,0 +1,58 @@
<?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\Form;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
class LanguageCreationForm extends BaseForm
{
protected function buildForm()
{
$this->formBuilder
->add("title", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Language title *"),
"label_attr" => array(
"for" => "title"
)
))
->add("isocode", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("ISO Code *"),
"label_attr" => array(
"for" => "isocode"
)
))
;
}
public function getName()
{
return "thelia_language_creation";
}
}

View File

@@ -59,7 +59,7 @@ class RewritingResolver
public function load($rewrittenUrl)
{
$rewrittenUrl = ltrim($rewrittenUrl, '/');
$rewrittenUrl = urldecode($rewrittenUrl);
$this->search = $this->rewritingUrlQuery->getResolverSearch($rewrittenUrl);
if($this->search->count() == 0) {