From e1d48d2a28e2af161d89e7c22016a3a839ee6f07 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 11 Sep 2013 12:30:05 +0200 Subject: [PATCH 01/12] finish registration form --- core/lib/Thelia/Form/CustomerCreation.php | 7 +- templates/default/register.html | 165 ++++++++++++++-------- 2 files changed, 115 insertions(+), 57 deletions(-) diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index e6f77c0de..24e64faff 100755 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -65,7 +65,10 @@ class CustomerCreation extends BaseForm "label_attr" => array( "for" => "address" ), - "label" => Translator::getInstance()->trans("Street Address") + "label" => Translator::getInstance()->trans("Street Address"), + "label_attr" => array( + "for" => "address1" + ) )) ->add("address2", "text", array( "label" => Translator::getInstance()->trans("Address Line 2"), @@ -80,7 +83,7 @@ class CustomerCreation extends BaseForm ) )) ->add("company", "text", array( - "label" => Translator::getInstance()->trans("Company name"), + "label" => Translator::getInstance()->trans("Company Name"), "label_attr" => array( "for" => "company" ) diff --git a/templates/default/register.html b/templates/default/register.html index 3a14ce675..48339b873 100644 --- a/templates/default/register.html +++ b/templates/default/register.html @@ -101,74 +101,129 @@
-
- -
- -
-
+ {form_field form=$form field="company"} +
+ +
+ + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} -
- -
- -
-
+ {form_field form=$form field="address1"} +
+ +
+ + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} -
- -
- -
-
+ {form_field form=$form field="address2"} +
+ +
+ + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} -
- -
- -
-
+ {form_field form=$form field="city"} +
+ +
+ + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} -
- -
- -
-
+ {form_field form=$form field="zipcode"} +
+ +
+ + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} -
- -
- -
-
+ {form_field form=$form field="country"} +
+ +
+ + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field}
- 3. Login Information + 3. {intl l="Login Information"}
-
- -
- -
-
+ {form_field form=$form field="password"} +
+ +
+ + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} -
- -
- -
-
+ {form_field form=$form field="password_confirm"} +
+ +
+ + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field}
From 858cc7f4f230d2d4e1100f7cc4c10446a0b7a2f6 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 11 Sep 2013 14:32:57 +0200 Subject: [PATCH 02/12] validate customer creation form --- .../Thelia/Config/Resources/routing/front.xml | 6 +- core/lib/Thelia/Controller/BaseController.php | 2 - .../Controller/Front/CustomerController.php | 10 ++- templates/default/register.html | 62 +++++++++++++------ 4 files changed, 57 insertions(+), 23 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index d06585f73..bb1e9422b 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -12,7 +12,7 @@ Thelia\Controller\Front\CustomerController::createAction - connexion + register @@ -57,6 +57,10 @@ + + Thelia\Controller\Front\DefaultController::noAction + cart + Thelia\Controller\Front\CartController::addItem cart diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index bd2556072..988159be4 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -215,8 +215,6 @@ class BaseController extends ContainerAware $url = $this->getRequest()->get("success_url"); } - echo "url=$url"; - if (null !== $url) $this->redirect($url); } diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index 85db69472..0a60126e6 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -44,6 +44,7 @@ use Thelia\Core\Security\Exception\WrongPasswordException; */ class CustomerController extends BaseFrontController { + use \Thelia\Cart\CartTrait; /** * Create a new customer. * On success, redirect to success_url if exists, otherwise, display the same view again. @@ -65,7 +66,12 @@ class CustomerController extends BaseFrontController $this->processLogin($customerCreateEvent->getCustomer()); - $this->redirectSuccess($customerCreation); + $cart = $this->getCart($this->getRequest()); + if($cart->getCartItems()->count() > 0) { + $this->redirectToRoute("cart.view"); + } else { + $this->redirectSuccess($customerCreation); + } } catch (FormValidationException $e) { $message = sprintf("Please check your input: %s", $e->getMessage()); } catch (\Exception $e) { @@ -232,7 +238,7 @@ class CustomerController extends BaseFrontController $data["country"], isset($data["email"])?$data["email"]:null, isset($data["password"]) ? $data["password"]:null, - $this->getRequest()->getSession()->getLang(), + $this->getRequest()->getSession()->getLang()->getId(), isset($data["reseller"])?$data["reseller"]:null, isset($data["sponsor"])?$data["sponsor"]:null, isset($data["discount"])?$data["discount"]:null diff --git a/templates/default/register.html b/templates/default/register.html index 48339b873..9e0caf202 100644 --- a/templates/default/register.html +++ b/templates/default/register.html @@ -19,18 +19,44 @@

{intl l="Create New Account"}

{form name="thelia.customer.creation"}
+ {form_field form=$form field='success_url'} + {* the url the user is redirected to on login success *} + {/form_field} + {form_field form=$form field='error_message'} + {* the url the user is redirected to on login success *} + {/form_field} + {form_hidden_fields form=$form} + {if $form_error}
{$form_error_message}
{/if}
1. {intl l="Personal Informations"}
+ {form_field form=$form field="title"} +
+ +
+ + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} {form_field form=$form field="firstname"} -
+
- + {if $error } {$message} {elseif $value != "" && !$error} @@ -40,7 +66,7 @@
{/form_field} {form_field form=$form field="lastname"} -
+
@@ -53,7 +79,7 @@
{/form_field} {form_field form=$form field="email"} -
+
@@ -67,7 +93,7 @@
{/form_field} {form_field form=$form field="phone"} -
+
@@ -80,7 +106,7 @@
{/form_field} {form_field form=$form field="cellphone"} -
+
@@ -102,7 +128,7 @@
{form_field form=$form field="company"} -
+
@@ -116,7 +142,7 @@ {/form_field} {form_field form=$form field="address1"} -
+
@@ -130,7 +156,7 @@ {/form_field} {form_field form=$form field="address2"} -
+
@@ -144,7 +170,7 @@ {/form_field} {form_field form=$form field="city"} -
+
@@ -158,7 +184,7 @@ {/form_field} {form_field form=$form field="zipcode"} -
+
@@ -172,13 +198,13 @@ {/form_field} {form_field form=$form field="country"} -
+
- + {loop type="country" name="country.list"} - + {/loop} {if $error } @@ -198,7 +224,7 @@
{form_field form=$form field="password"} -
+
@@ -212,7 +238,7 @@ {/form_field} {form_field form=$form field="password_confirm"} -
+
@@ -231,7 +257,7 @@
From ec245862327d6a3722c4d41c70b87d5562452232 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 11 Sep 2013 15:04:47 +0200 Subject: [PATCH 03/12] add some information in propelcollector --- .../DebugBar/DataCollector/PropelCollector.php | 4 ++-- .../modules/DebugBar/Smarty/Plugin/DebugBar.php | 17 ----------------- templates/admin/default/admin-layout.tpl | 2 +- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/local/modules/DebugBar/DataCollector/PropelCollector.php b/local/modules/DebugBar/DataCollector/PropelCollector.php index 823a31666..b0d503b18 100644 --- a/local/modules/DebugBar/DataCollector/PropelCollector.php +++ b/local/modules/DebugBar/DataCollector/PropelCollector.php @@ -66,8 +66,8 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa return array( 'nb_statements' => count($this->statements), 'nb_failed_statements' => 0, - 'accumulated_duration' => '10', - 'accumulated_duration_str' => $this->formatDuration(1), + 'accumulated_duration' => $this->accumulatedTime, + 'accumulated_duration_str' => $this->formatDuration($this->accumulatedTime), 'peak_memory_usage' => $this->peakMemory, 'peak_memory_usage_str' => $this->formatBytes($this->peakMemory), 'statements' => $this->statements diff --git a/local/modules/DebugBar/Smarty/Plugin/DebugBar.php b/local/modules/DebugBar/Smarty/Plugin/DebugBar.php index 70a896433..0cd1abee9 100644 --- a/local/modules/DebugBar/Smarty/Plugin/DebugBar.php +++ b/local/modules/DebugBar/Smarty/Plugin/DebugBar.php @@ -104,23 +104,6 @@ class DebugBar extends AbstractSmartyPlugin return $render; } - public function renderHead($params, \Smarty_Internal_Template $template) - { - $render = ""; - if ($this->debugMode) { - $javascriptRenderer = $this->debugBar->getJavascriptRenderer(); - $assets = $javascriptRenderer->getAssets(); - - $cssCollection = $assets[0]; - $jsCollection = $assets[1]; - - $render .= sprintf('', $cssCollection->dump()); - $render .= sprintf('', $jsCollection->dump()); - } - - return $render; - } - /** * @return an array of SmartyPluginDescriptor */ diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index 942557600..188ba75f4 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -224,7 +224,7 @@ {debugbar_renderjs} - {debugbar_renderresult} + {block name="after-javascript-include"}{/block} From 1ec9e7486d57f803e2dda4bfd45d027b0be01dc0 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 11 Sep 2013 15:21:43 +0200 Subject: [PATCH 04/12] just add Propel information in phpDebugBar --- local/modules/DebugBar/Config/config.xml | 2 +- local/modules/DebugBar/Listeners/DebugBarListeners.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/local/modules/DebugBar/Config/config.xml b/local/modules/DebugBar/Config/config.xml index 6713c8ce6..12c5ccd24 100644 --- a/local/modules/DebugBar/Config/config.xml +++ b/local/modules/DebugBar/Config/config.xml @@ -30,7 +30,7 @@ - + diff --git a/local/modules/DebugBar/Listeners/DebugBarListeners.php b/local/modules/DebugBar/Listeners/DebugBarListeners.php index 7d0981d5d..336aa952c 100644 --- a/local/modules/DebugBar/Listeners/DebugBarListeners.php +++ b/local/modules/DebugBar/Listeners/DebugBarListeners.php @@ -22,7 +22,11 @@ /*************************************************************************************/ namespace DebugBar\Listeners; +use DebugBar\DataCollector\MemoryCollector; +use DebugBar\DataCollector\MessagesCollector; +use DebugBar\DataCollector\PhpInfoCollector; use DebugBar\DataCollector\PropelCollector; +use DebugBar\DataCollector\TimeDataCollector; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\KernelEvents; use Thelia\Action\BaseAction; @@ -40,6 +44,12 @@ class DebugBarListeners extends BaseAction implements EventSubscriberInterface { { $debugBar = $this->container->get("debugBar"); + + $debugBar->addCollector(new PhpInfoCollector()); + //$debugBar->addCollector(new MessagesCollector()); + //$debugBar->addCollector(new RequestDataCollector()); + //$debugBar->addCollector(new TimeDataCollector()); + $debugBar->addCollector(new MemoryCollector()); $debugBar->addCollector(new PropelCollector()); } From 769993cc96f21eb37bd0dc7eb1024be8c3985da7 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 11 Sep 2013 15:26:47 +0200 Subject: [PATCH 05/12] add TimeDataCollector --- local/modules/DebugBar/Listeners/DebugBarListeners.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local/modules/DebugBar/Listeners/DebugBarListeners.php b/local/modules/DebugBar/Listeners/DebugBarListeners.php index 336aa952c..f789a9a13 100644 --- a/local/modules/DebugBar/Listeners/DebugBarListeners.php +++ b/local/modules/DebugBar/Listeners/DebugBarListeners.php @@ -48,7 +48,7 @@ class DebugBarListeners extends BaseAction implements EventSubscriberInterface { $debugBar->addCollector(new PhpInfoCollector()); //$debugBar->addCollector(new MessagesCollector()); //$debugBar->addCollector(new RequestDataCollector()); - //$debugBar->addCollector(new TimeDataCollector()); + $debugBar->addCollector(new TimeDataCollector()); $debugBar->addCollector(new MemoryCollector()); $debugBar->addCollector(new PropelCollector()); } From c1edc0e4ffae4248d02d12d4fb9a9372475e4477 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 11 Sep 2013 15:48:55 +0200 Subject: [PATCH 06/12] update phpdebugbar dependency --- composer.json | 3 +-- composer.lock | 16 ++++++++-------- .../Thelia/Config/Resources/routing/front.xml | 2 +- templates/default/layout.tpl | 7 +++++++ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 9d179a987..2d315bd3a 100755 --- a/composer.json +++ b/composer.json @@ -36,13 +36,12 @@ "simplepie/simplepie": "dev-master", "imagine/imagine": "dev-master", - "symfony/serializer": "dev-master", "symfony/icu": "1.0" }, "require-dev" : { "phpunit/phpunit": "3.7.*", "fzaninotto/faker": "dev-master", - "maximebf/debugbar": "1.*" + "maximebf/debugbar": "dev-master" }, "minimum-stability": "stable", "config" : { diff --git a/composer.lock b/composer.lock index 0215c3d0f..61160ea49 100755 --- a/composer.lock +++ b/composer.lock @@ -3,8 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "ba2f3e0943f00c7c3bf0c086bc611b0f", - + "hash": "28dfdc7a840f9e70df422581f82a871f", "packages": [ { "name": "imagine/imagine", @@ -1621,16 +1620,16 @@ }, { "name": "maximebf/debugbar", - "version": "1.5.1", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/maximebf/php-debugbar.git", - "reference": "37dccc40da52bf9f85571c30cf302da696db0d05" + "reference": "7fbe0a5d4ffc7f4e205c2b15542382308d34bd0d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/37dccc40da52bf9f85571c30cf302da696db0d05", - "reference": "37dccc40da52bf9f85571c30cf302da696db0d05", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/7fbe0a5d4ffc7f4e205c2b15542382308d34bd0d", + "reference": "7fbe0a5d4ffc7f4e205c2b15542382308d34bd0d", "shasum": "" }, "require": { @@ -1666,7 +1665,7 @@ "keywords": [ "debug" ], - "time": "2013-08-17 02:02:49" + "time": "2013-09-11 13:01:19" }, { "name": "phpunit/php-code-coverage", @@ -2048,7 +2047,8 @@ "ptachoire/cssembed": 20, "simplepie/simplepie": 20, "imagine/imagine": 20, - "fzaninotto/faker": 20 + "fzaninotto/faker": 20, + "maximebf/debugbar": 20 }, "platform": { "php": ">=5.4" diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index bb1e9422b..aefd77fd1 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -34,7 +34,7 @@ login - + Thelia\Controller\Front\CustomerController::logoutAction diff --git a/templates/default/layout.tpl b/templates/default/layout.tpl index 3b2fe5dcd..5ef6f5386 100644 --- a/templates/default/layout.tpl +++ b/templates/default/layout.tpl @@ -84,8 +84,15 @@ URL: http://www.thelia.net {/loop}
diff --git a/templates/default/password.html b/templates/default/password.html new file mode 100644 index 000000000..c65691fb6 --- /dev/null +++ b/templates/default/password.html @@ -0,0 +1,33 @@ +{extends file="layout.tpl"} + +{block name="breadcrumb"} + +{/block} + +{block name="main-content"} +
+
+

{intl l="Password Forgotten"}

+ +
+ +

{intl l="Please enter your email address below. You will receive a link to reset your password."}

+ +
+ + +
+
+ {intl l="Cancel"} + +
+
+
+
+{/block} diff --git a/templates/default/register.html b/templates/default/register.html index 9e0caf202..7100737bc 100644 --- a/templates/default/register.html +++ b/templates/default/register.html @@ -4,7 +4,7 @@ From 9cc31626964bcf12f8faa2cb77e9316d3c7cb3e6 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 11 Sep 2013 17:22:23 +0200 Subject: [PATCH 10/12] finishing creating lost password template --- core/lib/Thelia/Config/Resources/config.xml | 1 + .../Thelia/Config/Resources/routing/front.xml | 7 +++- .../Controller/Front/CustomerController.php | 37 +++++++++++++++++++ core/lib/Thelia/Core/Event/TheliaEvents.php | 4 ++ templates/default/password.html | 23 ++++++++---- 5 files changed, 64 insertions(+), 8 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 74e1f4629..a73d28434 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -41,6 +41,7 @@
+ diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index f0c624290..e83dd7f07 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -38,11 +38,16 @@ Thelia\Controller\Front\CustomerController::logoutAction - + Thelia\Controller\Front\DefaultController::noAction password + + Thelia\Controller\Front\CustomerController::newPasswordAction + password + + diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index 0a60126e6..a0fd74abc 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -24,11 +24,13 @@ namespace Thelia\Controller\Front; use Thelia\Core\Event\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\CustomerLoginEvent; +use Thelia\Core\Event\LostPasswordEvent; use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator; use Thelia\Core\Security\Exception\AuthenticationException; 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\Exception\FormValidationException; use Thelia\Model\Customer; @@ -45,6 +47,41 @@ use Thelia\Core\Security\Exception\WrongPasswordException; class CustomerController extends BaseFrontController { use \Thelia\Cart\CartTrait; + + public function newPasswordAction() + { + if (! $this->getSecurityContext()->hasCustomerUser()) { + $message = false; + + $passwordLost = new CustomerLostPasswordForm($this->getRequest()); + + try { + + $form = $this->validateForm($passwordLost); + + $event = new LostPasswordEvent($form->get("email")->getData()); + + $this->dispatch(TheliaEvents::LOST_PASSWORD, $event); + + } catch (FormValidationException $e) { + $message = sprintf("Please check your input: %s", $e->getMessage()); + } catch (\Exception $e) { + $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf("Error during customer creation process : %s. Exception was %s", $message, $e->getMessage())); + + $passwordLost->setErrorMessage($message); + + $this->getParserContext() + ->addForm($passwordLost) + ->setGeneralError($message) + ; + } + } + } + /** * Create a new customer. * On success, redirect to success_url if exists, otherwise, display the same view again. diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index c19d3a400..8aa024615 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -71,6 +71,10 @@ final class TheliaEvents */ const CUSTOMER_UPDATEACCOUNT = "action.updateCustomer"; + /** + * sent when a customer need a new password + */ + const LOST_PASSWORD = "action.lostPassword"; /** * Sent before the logout of the administrator. */ diff --git a/templates/default/password.html b/templates/default/password.html index c65691fb6..ec472a1f9 100644 --- a/templates/default/password.html +++ b/templates/default/password.html @@ -14,20 +14,29 @@

{intl l="Password Forgotten"}

+ {form name="thelia.customer.lostpassword"} + - - -

{intl l="Please enter your email address below. You will receive a link to reset your password."}

- -
- - +

{intl l="Please enter your email address below." {intl l="You will receive a link to reset your password."}

+ {form_field form=$form field="email"} +
+ +
+ + {if $error} + {$message} + {elseif !$error && $value != ""} + {intl l="You will receive a link to reset your password."} + {/if} +
+ {/form_field}
{intl l="Cancel"}
+ {/form}
{/block} From bb5946457a1b1f0696ecf22bdbe3a24d5ca021e3 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 11 Sep 2013 17:24:26 +0200 Subject: [PATCH 11/12] add missing files --- .../Thelia/Core/Event/LostPasswordEvent.php | 51 ++++++++++ .../Thelia/Form/CustomerLostPasswordForm.php | 96 +++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 core/lib/Thelia/Core/Event/LostPasswordEvent.php create mode 100644 core/lib/Thelia/Form/CustomerLostPasswordForm.php diff --git a/core/lib/Thelia/Core/Event/LostPasswordEvent.php b/core/lib/Thelia/Core/Event/LostPasswordEvent.php new file mode 100644 index 000000000..fe1f9dc5f --- /dev/null +++ b/core/lib/Thelia/Core/Event/LostPasswordEvent.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + + +/** + * Class LostPasswordEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class LostPasswordEvent extends ActionEvent { + + protected $email; + + public function __construct($email) + { + $this->email = $email; + } + + /** + * @return mixed + */ + public function getEmail() + { + return $this->email; + } + + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/CustomerLostPasswordForm.php b/core/lib/Thelia/Form/CustomerLostPasswordForm.php new file mode 100644 index 000000000..d950bf614 --- /dev/null +++ b/core/lib/Thelia/Form/CustomerLostPasswordForm.php @@ -0,0 +1,96 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\Constraints\Email; +use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Core\Translation\Translator; +use Thelia\Model\CustomerQuery; + +/** + * Class CustomerLostPasswordForm + * @package Thelia\Form + * @author Manuel Raynaud + */ +class CustomerLostPasswordForm extends BaseForm { + + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->formBuilder attribute : + * + * $this->formBuilder->add("name", "text") + * ->add("email", "email", array( + * "attr" => array( + * "class" => "field" + * ), + * "label" => "email", + * "constraints" => array( + * new \Symfony\Component\Validator\Constraints\NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ + protected function buildForm() + { + $this->formBuilder + ->add("email", "email", array( + "constraints" => array( + new NotBlank(), + new Email(), + new Callback(array( + "methods" => array( + array($this, + "verifyExistingEmail") + ) + )) + ), + "label" => Translator::getInstance()->trans("Please enter your email address"), + "label_attr" => array( + "for" => "forgot-email" + ) + )); + } + + public function verifyExistingEmail($value, ExecutionContextInterface $context) + { + $customer = CustomerQuery::create()->findOneByEmail($value); + if (null === $customer) { + $context->addViolation("This email does not exists exists"); + } + } + + /** + * @return string the name of you form. This name must be unique + */ + public function getName() + { + return "thelia_customer_creation"; + } +} \ No newline at end of file From d846d108323c0c0f5a9456e793534c5f5ed2fd13 Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 11 Sep 2013 17:47:52 +0200 Subject: [PATCH 12/12] Working - CasperJS : coupon rule --- tests/functionnal/casperjs/exe/30_coupons.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/functionnal/casperjs/exe/30_coupons.js b/tests/functionnal/casperjs/exe/30_coupons.js index 6031d71f8..2ac04a759 100644 --- a/tests/functionnal/casperjs/exe/30_coupons.js +++ b/tests/functionnal/casperjs/exe/30_coupons.js @@ -9,7 +9,7 @@ casper.test.comment('Testing coupons'); //UPDATE COUPON RULE casper.start(thelia2_login_coupon_update_url, function() { - console.log('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png'); this.echo('\nCOUPON RULE - EDIT'); this.test.assertTitle('Update coupon - Thelia Back Office', 'Web page title OK'); // this.test.assertSelectorHasText('#content-header > h1', 'Liste des pays', 'Web page main content OK'); @@ -18,12 +18,10 @@ casper.start(thelia2_login_coupon_update_url, function() { // Create rule this.evaluate(function() { -// document.querySelector('select#category-rule').selectedItem = 'thelia.constraint.rule.available_for_x_articles'; $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); return true; }); - this.capture('tests/functionnal/casperjs/pictures/screenshot-category-rule.png'); -// this.click('constraint-list > tr:last-child > td > a.constraint-update-btn'); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected.png'); }); casper.wait(1000, function() { @@ -31,7 +29,21 @@ casper.wait(1000, function() { }); casper.then(function(){ + this.evaluate(function() { + $('#quantity-operator').val('>=').change(); + return true; + }); + this.sendKeys('input#quantity-value', '4'); + this.click('#constraint-save-btn'); +}); +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); + +casper.then(function(){ + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', ' If cart products quantity is superior or equals to 4','3rd rule found'); }); ////EDIT CHECK