12853 - remove all unecessary codes added for this ticket in ant_nw_frequences

This commit is contained in:
Rodney Figaro 2017-04-12 12:52:48 +02:00
parent 45160160a6
commit db414ac2e6
4 changed files with 5 additions and 61 deletions

View File

@ -1,23 +0,0 @@
<?php
class ant_nw_customer
{
const EMAIL_TOKEN = '8F256D8FEE9B722DA453FA7C2239EACAB79EAEA4';
public static function encodeEmail($email)
{
return sha1($email.self::EMAIL_TOKEN);
}
public static function getCustomerFromEncodedEmail($encoded_email)
{
$sql = 'SELECT `id_customer`
FROM `'._DB_PREFIX_.'customer`
WHERE SHA1(CONCAT(`email`, \''.self::EMAIL_TOKEN.'\')) = \''.pSQL($encoded_email).'\'';
$id_customer = Db::getInstance()->getValue($sql);
if ($id_customer === false) {
return null;
}
return new Customer($id_customer);
}
}

View File

@ -2,8 +2,6 @@
if (!defined('_PS_VERSION_'))
exit;
require_once _PS_MODULE_DIR_.'/ant_nw_frequences/ant_nw_customer.php';
class ant_nw_frequences extends Module
{
public function __construct()
@ -80,9 +78,4 @@ class ant_nw_frequences extends Module
);
return $tab_routes;
}
public function encodeEmail($email)
{
return ant_nw_customer::encodeEmail($email);
}
}

View File

@ -3,29 +3,16 @@
* @company Antadis
*/
require_once _PS_MODULE_DIR_.'/ant_nw_frequences/ant_nw_customer.php';
class ant_nw_frequencesfrequenceModuleFrontController extends ModuleFrontController
{
private $encoded_email = '';
public function init()
{
parent::init();
$this->encoded_email = Tools::getValue('e');
if (!empty($this->encoded_email)) {
$this->customer = ant_nw_customer::getCustomerFromEncodedEmail($this->encoded_email);
}
elseif (!$this->context->customer->isLogged()){
Tools::redirect('index.php?controller=authentication&back=modules/ant_nw_frequences/ant_nw_frequences-frequence.php');
}
else {
$this->customer = $this->context->customer;
}
if ($this->customer===null || !Validate::isLoadedObject($this->customer)){
if (!$this->context->customer->isLogged()){
Tools::redirect('index.php?controller=authentication&back=modules/ant_nw_frequences/ant_nw_frequences-frequence.php');
}
$this->customer = $this->context->customer;
}
public function initContent()
@ -34,21 +21,18 @@ class ant_nw_frequencesfrequenceModuleFrontController extends ModuleFrontControl
if (Module::isInstalled('blocknewsletter')) {
$this->context->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
}
if ((int)$this->customer->newsletter == 1) {
$this->context->smarty->assign('frequence_nw', $this->customer->frequence_nw);
}
else {
$this->context->smarty->assign('frequence_nw', 'unsub');
}
$this->context->smarty->assign('encoded_email', $this->encoded_email);
$this->setTemplate('frequence.tpl');
}
public function postProcess()
{
$freq_h = 1;
$freq_3x = 2;
$origin_newsletter = (bool)$this->customer->newsletter;
if (Tools::isSubmit('submitFrequence')){
@ -60,7 +44,7 @@ class ant_nw_frequencesfrequenceModuleFrontController extends ModuleFrontControl
}
else {
if (!$origin_newsletter && Tools::getIsset('newsletter')) {
if (!$origin_newsletter) {
$this->customer->newsletter = 1;
if ($module_newsletter = Module::getInstanceByName('blocknewsletter')) {

View File

@ -23,7 +23,6 @@
* International Registered Trademark & Property of PrestaShop SA
*}
{if !isset($encoded_email) || empty($encoded_email)}
{capture name=path}
<a href="{$link->getPageLink('my-account', true)|escape:'html':'UTF-8'}">
{l s='My account' mod='ant_nw_frequences'}
@ -35,13 +34,8 @@
{l s='Your personal information' mod='ant_nw_frequences'}
</span>
{/capture}
{/if}
<div class="row">
<div class='snotmobile col-xs-3 left-account'>
{if isset($encoded_email) && !empty($encoded_email)}
<div class="block-left-account" style='height:300px;'>
</div>
{else}
<div class="block-left-account">
<h2 class="account">{l s='Votre compte' mod='ant_nw_frequences'}</h2>
@ -89,7 +83,6 @@
{hook h='displayCustomerAccount' }
</ul>
</div>
{/if}
</div>
<div class='col-xs-12 col-sm-9 right-account'>
<a href="{$link->getPageLink('my-account', true)|escape:'html':'UTF-8'} " class="smobile btn-back" >
@ -104,13 +97,10 @@
</p>
{elseif isset($confirmation_unsub) && $confirmation_unsub}
<p class="alert alert-success">
{l s='Votre demande de désabonnement à nos newsletters a bien été pris en compte. Celle-ci sera effective d\'ici quelques minutes.' mod='ant_nw_frequences'}
{l s='Votre demande de désabonnement à nos newsletters a bien été enregistrée. Celle-ci sera prise en compte dans les plus brefs délais.' mod='ant_nw_frequences'}
</p>
{else}
<form action="{$link->getModuleLink('ant_nw_frequences','frequence')|escape:'html':'UTF-8'}" method="post" class="std">
{if isset($encoded_email)}
<input type='hidden' name='e' value='{$encoded_email}' />
{/if}
<fieldset>
{if $newsletter}
<div class="col-xs-12 form-group">