[-] FO : #FSCFV-903 : Add Mail confirmation sending when subscribing to the newsletter via Accont creation or edition
This commit is contained in:
1 parent
d9dacf573a
commit
af82f229b3
3 files changed
+50
-8
No files matched your search
@@ -347,6 +347,26 @@ class AuthControllerCore extends FrontController
|
|||||||
$this->context->smarty->assign('authentification_error', $this->errors);
|
$this->context->smarty->assign('authentification_error', $this->errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the newsletter settings and set the customer infos.
|
||||||
|
*
|
||||||
|
* @param Customer $customer Reference on the customer Object.
|
||||||
|
*
|
||||||
|
* @note At this point, the email has been validated.
|
||||||
|
*/
|
||||||
|
protected function processCustomerNewsletter(&$customer)
|
||||||
|
{
|
||||||
|
if (Tools::getValue('newsletter'))
|
||||||
|
{
|
||||||
|
$customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
|
||||||
|
$customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
|
||||||
|
|
||||||
|
if ($module_newsletter = Module::getInstanceByName('blocknewsletter'))
|
||||||
|
if ($module_newsletter->active)
|
||||||
|
$module_newsletter->confirmSubscription(Tools::getValue('email'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process submit on an account
|
* Process submit on an account
|
||||||
*/
|
*/
|
||||||
@@ -379,10 +399,7 @@ class AuthControllerCore extends FrontController
|
|||||||
if (!count($this->errors))
|
if (!count($this->errors))
|
||||||
{
|
{
|
||||||
if (Tools::isSubmit('newsletter'))
|
if (Tools::isSubmit('newsletter'))
|
||||||
{
|
$this->processCustomerNewsletter($customer);
|
||||||
$customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
|
|
||||||
$customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
|
|
||||||
}
|
|
||||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']);
|
$customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']);
|
||||||
$customer->active = 1;
|
$customer->active = 1;
|
||||||
// New Guest customer
|
// New Guest customer
|
||||||
@@ -494,10 +511,7 @@ class AuthControllerCore extends FrontController
|
|||||||
if (Customer::customerExists(Tools::getValue('email')))
|
if (Customer::customerExists(Tools::getValue('email')))
|
||||||
$this->errors[] = Tools::displayError('An account is already registered with this e-mail, please enter your password or request a new one.', false);
|
$this->errors[] = Tools::displayError('An account is already registered with this e-mail, please enter your password or request a new one.', false);
|
||||||
if (Tools::isSubmit('newsletter'))
|
if (Tools::isSubmit('newsletter'))
|
||||||
{
|
$this->processCustomerNewsletter($customer);
|
||||||
$customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
|
|
||||||
$customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']);
|
$customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']);
|
||||||
if (!count($this->errors))
|
if (!count($this->errors))
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ class IdentityControllerCore extends FrontController
|
|||||||
*/
|
*/
|
||||||
public function postProcess()
|
public function postProcess()
|
||||||
{
|
{
|
||||||
|
$origin_newsletter = (bool)$this->customer->newsletter;
|
||||||
|
|
||||||
if (isset($_POST['years']) && isset($_POST['months']) && isset($_POST['days']))
|
if (isset($_POST['years']) && isset($_POST['months']) && isset($_POST['days']))
|
||||||
$this->customer->birthday = (int)($_POST['years']).'-'.(int)($_POST['months']).'-'.(int)($_POST['days']);
|
$this->customer->birthday = (int)($_POST['years']).'-'.(int)($_POST['months']).'-'.(int)($_POST['days']);
|
||||||
|
|
||||||
@@ -76,8 +78,14 @@ class IdentityControllerCore extends FrontController
|
|||||||
{
|
{
|
||||||
$this->customer->id_default_group = (int)$prev_id_default_group;
|
$this->customer->id_default_group = (int)$prev_id_default_group;
|
||||||
$this->customer->firstname = Tools::ucfirst(Tools::strtolower($this->customer->firstname));
|
$this->customer->firstname = Tools::ucfirst(Tools::strtolower($this->customer->firstname));
|
||||||
|
|
||||||
if (!isset($_POST['newsletter']))
|
if (!isset($_POST['newsletter']))
|
||||||
$this->customer->newsletter = 0;
|
$this->customer->newsletter = 0;
|
||||||
|
elseif (!$origin_newsletter && isset($_POST['newsletter']))
|
||||||
|
if ($module_newsletter = Module::getInstanceByName('blocknewsletter'))
|
||||||
|
if ($module_newsletter->active)
|
||||||
|
$module_newsletter->confirmSubscription($this->customer->email);
|
||||||
|
|
||||||
if (!isset($_POST['optin']))
|
if (!isset($_POST['optin']))
|
||||||
$this->customer->optin = 0;
|
$this->customer->optin = 0;
|
||||||
if (Tools::getValue('passwd'))
|
if (Tools::getValue('passwd'))
|
||||||
|
|||||||
@@ -422,6 +422,26 @@ class Blocknewsletter extends Module
|
|||||||
return $this->l('Thank you for subscribing to our newsletter.');
|
return $this->l('Thank you for subscribing to our newsletter.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the confirmation mails to the given $email address if needed.
|
||||||
|
*
|
||||||
|
* @param string $email Email where to send the confirmation
|
||||||
|
*
|
||||||
|
* @note the email has been verified and might not yet been registered. Called by AuthController::processCustomerNewsletter
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function confirmSubscription($email)
|
||||||
|
{
|
||||||
|
if ($email)
|
||||||
|
{
|
||||||
|
if ($discount = Configuration::get('NW_VOUCHER_CODE'))
|
||||||
|
$this->sendVoucher($email, $discount);
|
||||||
|
|
||||||
|
if (Configuration::get('NW_CONFIRMATION_EMAIL'))
|
||||||
|
$this->sendConfirmationEmail($email);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send an email containing a voucher code
|
* Send an email containing a voucher code
|
||||||
* @param string $email
|
* @param string $email
|
||||||
|
|||||||
Reference in new issue
Block a user