diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index de8507cfc..a9bc64895 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -458,7 +458,7 @@ class AdminCustomersControllerCore extends AdminController 'label' => $this->l('Disabled') ) ), - 'disabled' => true, + 'disabled' => (bool)!Configuration::get('PS_CUSTOMER_NEWSLETTER'), 'hint' => $this->l('This customer will receive your newsletter via email.') ), array( diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 53fd39763..95c532e3d 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -100,7 +100,7 @@ class AuthControllerCore extends FrontController $this->assignCountries(); - $newsletter = Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active; + $newsletter = Module::isEnabled('blocknewsletter') && Configuration::get('PS_CUSTOMER_NEWSLETTER'); $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN')); diff --git a/controllers/front/IdentityController.php b/controllers/front/IdentityController.php index e41ba9476..39231664d 100644 --- a/controllers/front/IdentityController.php +++ b/controllers/front/IdentityController.php @@ -151,7 +151,7 @@ class IdentityControllerCore extends FrontController 'HOOK_CUSTOMER_IDENTITY_FORM' => Hook::exec('displayCustomerIdentityForm'), )); - $newsletter = Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active; + $newsletter = Module::isEnabled('blocknewsletter') && Configuration::get('PS_CUSTOMER_NEWSLETTER'); $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN')); diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index 2c5c02b3d..4be955e76 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -519,7 +519,7 @@ class OrderOpcControllerCore extends ParentOrderController } Tools::safePostVars(); - $newsletter = Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active; + $newsletter = Module::isEnabled('blocknewsletter') && Configuration::get('PS_CUSTOMER_NEWSLETTER'); $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN')); $this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase()); diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml index 746c940a6..87d2dff7f 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -878,6 +878,9 @@ 1 + + 1 + 1 diff --git a/modules/blocknewsletter/blocknewsletter.php b/modules/blocknewsletter/blocknewsletter.php index 4049ab084..67b08eca6 100644 --- a/modules/blocknewsletter/blocknewsletter.php +++ b/modules/blocknewsletter/blocknewsletter.php @@ -138,6 +138,7 @@ class Blocknewsletter extends Module public function getContent() { if (Tools::isSubmit('submitUpdate')) { + Configuration::updateValue('PS_CUSTOMER_NEWSLETTER', (bool)Tools::getValue('PS_CUSTOMER_NEWSLETTER')); Configuration::updateValue('NW_CONFIRMATION_EMAIL', (bool)Tools::getValue('NW_CONFIRMATION_EMAIL')); Configuration::updateValue('NW_VERIFICATION_EMAIL', (bool)Tools::getValue('NW_VERIFICATION_EMAIL')); @@ -825,6 +826,23 @@ class Blocknewsletter extends Module 'icon' => 'icon-cogs' ), 'input' => array( + array( + 'type' => 'switch', + 'label' => $this->l('Enable newsletter registration'), + 'name' => 'PS_CUSTOMER_NEWSLETTER', + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + 'label' => $this->l('Yes') + ), + array( + 'id' => 'active_off', + 'value' => 0, + 'label' => $this->l('No') + ) + ), + ), array( 'type' => 'switch', 'label' => $this->l('Would you like to send a verification email after subscription?'), @@ -971,6 +989,7 @@ class Blocknewsletter extends Module public function getConfigFieldsValues() { return array( + 'PS_CUSTOMER_NEWSLETTER' => Tools::getValue('PS_CUSTOMER_NEWSLETTER', Configuration::get('PS_CUSTOMER_NEWSLETTER')), 'NW_VERIFICATION_EMAIL' => Tools::getValue('NW_VERIFICATION_EMAIL', Configuration::get('NW_VERIFICATION_EMAIL')), 'NW_CONFIRMATION_EMAIL' => Tools::getValue('NW_CONFIRMATION_EMAIL', Configuration::get('NW_CONFIRMATION_EMAIL')), 'NW_VOUCHER_CODE' => Tools::getValue('NW_VOUCHER_CODE', Configuration::get('NW_VOUCHER_CODE')),