From d34be78f9f2ec4c1e827e868eb6a7df945278f09 Mon Sep 17 00:00:00 2001 From: vAugagneur Date: Wed, 29 Aug 2012 13:37:41 +0000 Subject: [PATCH] [-] MO : fixed bug #PSCFV-3791- customer privacy module error bug git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17073 b9a71923-0436-4b27-9f14-aed3839534dd --- controllers/front/AuthController.php | 1 + .../blockcustomerprivacy.php | 39 +++++++++++++++---- .../blockcustomerprivacy.tpl | 27 ------------- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index efc1d5cbc..4efb51c10 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -372,6 +372,7 @@ class AuthControllerCore extends FrontController */ protected function processSubmitAccount() { + Hook::exec('actionBeforeSubmitAccount'); $this->create_account = true; if (Tools::isSubmit('submitAccount')) $this->context->smarty->assign('email_create', 1); diff --git a/modules/blockcustomerprivacy/blockcustomerprivacy.php b/modules/blockcustomerprivacy/blockcustomerprivacy.php index 551019a32..dbf035be3 100644 --- a/modules/blockcustomerprivacy/blockcustomerprivacy.php +++ b/modules/blockcustomerprivacy/blockcustomerprivacy.php @@ -49,7 +49,7 @@ class Blockcustomerprivacy extends Module public function install() { - $return = (parent::install() && $this->registerHook('createAccountForm')); + $return = (parent::install() && $this->registerHook('createAccountForm') && $this->registerHook('header') && $this->registerHook('actionBeforeSubmitAccount')); Configuration::updateValue('CUSTPRIV_MESSAGE', array($this->context->language->id => $this->l('The personal data you provide is used to answer to your queries, process your orders or allow you to access specific information.').' '. $this->l('You have a right to modify and delete all the personal information which we hold concerning yourself in the "my account" page.') @@ -153,18 +153,41 @@ class Blockcustomerprivacy extends Module return $content; } - public function hookCreateAccountForm($params) + public function checkConfig() { if (!$this->active) - return; + return false; + $message = Configuration::get('CUSTPRIV_MESSAGE', $this->context->language->id); if (empty($message)) + return false; + + return true; + } + + public function hookHeader($params) + { + if (!$this->checkConfig()) + return; + $this->context->controller->addJS(($this->_path).'blockcustomerprivacy.js'); + } + + public function hookActionBeforeSubmitAccount($params) + { + if (!$this->checkConfig()) return; - $this->smarty->assign(array( - 'privacy_message' => $message, - 'error_message' => $this->l('Please agree with the customer data privacy by ticking the checkbox below.') - )); + if (!Tools::getValue('customer_privacy')) + $this->context->controller->errors[] = $this->l('Please agree with the customer data privacy by ticking the checkbox below.'); + } + + public function hookCreateAccountForm($params) + { + if (!$this->checkConfig()) + return; + + $this->smarty->assign('privacy_message', Configuration::get('CUSTPRIV_MESSAGE', $this->context->language->id)); + return $this->display(__FILE__, 'blockcustomerprivacy.tpl'); } -} +} \ No newline at end of file diff --git a/modules/blockcustomerprivacy/blockcustomerprivacy.tpl b/modules/blockcustomerprivacy/blockcustomerprivacy.tpl index 93d5caf28..96486101d 100644 --- a/modules/blockcustomerprivacy/blockcustomerprivacy.tpl +++ b/modules/blockcustomerprivacy/blockcustomerprivacy.tpl @@ -23,33 +23,6 @@ * International Registered Trademark & Property of PrestaShop SA *} - -

{l s='Customer data privacy' mod='blockcustomerprivacy'}