context->customer->isLogged()) Tools::redirect('index.php?controller=authentication&back=modules/ant_nw_frequences/ant_nw_frequences-frequence.php'); parent::init(); $this->customer = $this->context->customer; } public function initContent() { parent::initContent(); if (Module::isInstalled('blocknewsletter')) { $this->context->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active); } $this->context->smarty->assign('optin', $this->customer->optin); $this->context->smarty->assign('frequence_nw', $this->customer->frequence_nw); $this->context->smarty->assign('isnewsletter', $this->customer->newsletter); $this->setTemplate('frequence.tpl'); } public function postProcess(){ $freq_h = 1; $freq_3x = 2; $origin_newsletter = (bool)$this->customer->newsletter; if (Tools::isSubmit('submitFrequence')){ if (!Tools::getIsset('newsletter')) { $this->customer->newsletter = 0; } elseif (!$origin_newsletter && Tools::getIsset('newsletter')) { $this->customer->newsletter = 1; if ($module_newsletter = Module::getInstanceByName('blocknewsletter')) { if ($module_newsletter->active) { $module_newsletter->confirmSubscription($this->customer->email); } } } if (Tools::getValue('frequence_nw')) { $this->customer->frequence_nw = (int)Tools::getValue('frequence_nw'); } else { $this->customer->frequence_nw = 0; } if (!Tools::getIsset('optin')) { $this->customer->optin = 0; } else { $this->customer->optin = 1; } if ($this->customer->update()) { $this->context->smarty->assign('confirmation', 1); } } return true; } }