[-] MO : #PSTEST-303 - Fixed problems using deprecated methods
// Change baseDir vars to use the current domain // Change css rules git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12153 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
1 parent
a2eb4fc64d
commit
da301372b9
17 files changed
+301
-247
No files matched your search
@@ -232,15 +232,19 @@ class FrontControllerCore extends Controller
|
|||||||
setlocale(LC_NUMERIC, 'en_US.UTF-8');
|
setlocale(LC_NUMERIC, 'en_US.UTF-8');
|
||||||
|
|
||||||
/* get page name to display it in body id */
|
/* get page name to display it in body id */
|
||||||
// @todo check here
|
|
||||||
$page_name = Dispatcher::getInstance()->getController();
|
|
||||||
$page_name = (preg_match('/^[0-9]/', $page_name)) ? 'page_'.$page_name : $page_name;
|
|
||||||
|
|
||||||
// Are we in a module ?
|
// Are we in a payment module
|
||||||
if (preg_match('#^'.preg_quote($this->context->shop->getPhysicalURI(), '#').'modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m))
|
$module_name = Tools::getValue('module');
|
||||||
|
if (Tools::getValue('controller') == 'module' && $module_name != '' && new $module_name() instanceof PaymentModule)
|
||||||
|
$page_name = 'module-payment-submit';
|
||||||
|
// Are we in a module
|
||||||
|
else if (preg_match('#^'.preg_quote($this->context->shop->getPhysicalURI(), '#').'modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m))
|
||||||
$page_name = 'module-'.$m[1].'-'.str_replace(array('.php', '/'), array('', '-'), $m[2]);
|
$page_name = 'module-'.$m[1].'-'.str_replace(array('.php', '/'), array('', '-'), $m[2]);
|
||||||
if (Tools::getValue('controller') == 'module' && Tools::getValue('module') != '')
|
else
|
||||||
$page_name = 'module-paypal-payment-submit';
|
{
|
||||||
|
$page_name = Dispatcher::getInstance()->getController();
|
||||||
|
$page_name = (preg_match('/^[0-9]/', $page_name)) ? 'page_'.$page_name : $page_name;
|
||||||
|
}
|
||||||
|
|
||||||
$this->context->smarty->assign(Tools::getMetaTags($this->context->language->id, $page_name));
|
$this->context->smarty->assign(Tools::getMetaTags($this->context->language->id, $page_name));
|
||||||
$this->context->smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
|
$this->context->smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
|
||||||
@@ -272,7 +276,7 @@ class FrontControllerCore extends Controller
|
|||||||
'page_name' => $page_name,
|
'page_name' => $page_name,
|
||||||
'base_dir' => _PS_BASE_URL_.__PS_BASE_URI__,
|
'base_dir' => _PS_BASE_URL_.__PS_BASE_URI__,
|
||||||
'base_dir_ssl' => $protocol_link.Tools::getShopDomainSsl().__PS_BASE_URI__,
|
'base_dir_ssl' => $protocol_link.Tools::getShopDomainSsl().__PS_BASE_URI__,
|
||||||
'content_dir' => $protocol_content.(($useSSL)?Tools::getShopDomainSsl():Tools::getShopDomain()).__PS_BASE_URI__,
|
'content_dir' => $protocol_content.Tools::getServerName().__PS_BASE_URI__,
|
||||||
'tpl_dir' => _PS_THEME_DIR_,
|
'tpl_dir' => _PS_THEME_DIR_,
|
||||||
'modules_dir' => _MODULE_DIR_,
|
'modules_dir' => _MODULE_DIR_,
|
||||||
'mail_dir' => _MAIL_DIR_,
|
'mail_dir' => _MAIL_DIR_,
|
||||||
|
|||||||
@@ -30,21 +30,21 @@ if (!defined('_PS_VERSION_'))
|
|||||||
|
|
||||||
class Blocknewsletter extends Module
|
class Blocknewsletter extends Module
|
||||||
{
|
{
|
||||||
const GUEST_NOT_REGISTERED = -1;
|
const GUEST_NOT_REGISTERED = -1;
|
||||||
const CUSTOMER_NOT_REGISTERED = 0;
|
const CUSTOMER_NOT_REGISTERED = 0;
|
||||||
const GUEST_REGISTERED = 1;
|
const GUEST_REGISTERED = 1;
|
||||||
const CUSTOMER_REGISTERED = 2;
|
const CUSTOMER_REGISTERED = 2;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->name = 'blocknewsletter';
|
$this->name = 'blocknewsletter';
|
||||||
$this->tab = 'front_office_features';
|
$this->tab = 'front_office_features';
|
||||||
$this->need_instance = 0;
|
$this->need_instance = 0;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->displayName = $this->l('Newsletter block');
|
$this->displayName = $this->l('Newsletter block');
|
||||||
$this->description = $this->l('Adds a block for newsletter subscription.');
|
$this->description = $this->l('Adds a block for newsletter subscription.');
|
||||||
$this->confirmUninstall = $this->l('Are you sure you want to delete all your contacts ?');
|
$this->confirmUninstall = $this->l('Are you sure you want to delete all your contacts ?');
|
||||||
|
|
||||||
$this->version = '1.4';
|
$this->version = '1.4';
|
||||||
@@ -58,20 +58,20 @@ class Blocknewsletter extends Module
|
|||||||
1 => 'txt'
|
1 => 'txt'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function install()
|
public function install()
|
||||||
{
|
{
|
||||||
if (parent::install() == false OR $this->registerHook('leftColumn') == false OR $this->registerHook('header') == false)
|
if (parent::install() == false OR $this->registerHook('leftColumn') == false OR $this->registerHook('header') == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Configuration::updateValue('NW_SALT', Tools::passwdGen(16));
|
Configuration::updateValue('NW_SALT', Tools::passwdGen(16));
|
||||||
|
|
||||||
return Db::getInstance()->execute('
|
return Db::getInstance()->execute('
|
||||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'newsletter` (
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'newsletter` (
|
||||||
`id` int(6) NOT NULL AUTO_INCREMENT,
|
`id` int(6) NOT NULL AUTO_INCREMENT,
|
||||||
`id_shop` INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
|
`id_shop` INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
|
||||||
`id_group_shop` INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
|
`id_group_shop` INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
|
||||||
`email` varchar(255) NOT NULL,
|
`email` varchar(255) NOT NULL,
|
||||||
`newsletter_date_add` DATETIME NULL,
|
`newsletter_date_add` DATETIME NULL,
|
||||||
`ip_registration_newsletter` varchar(15) NOT NULL,
|
`ip_registration_newsletter` varchar(15) NOT NULL,
|
||||||
@@ -79,14 +79,14 @@ class Blocknewsletter extends Module
|
|||||||
`active` TINYINT(1) NOT NULL DEFAULT \'0\',
|
`active` TINYINT(1) NOT NULL DEFAULT \'0\',
|
||||||
PRIMARY KEY(`id`)
|
PRIMARY KEY(`id`)
|
||||||
) ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8');
|
) ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstall()
|
public function uninstall()
|
||||||
{
|
{
|
||||||
if (!parent::uninstall())
|
if (!parent::uninstall())
|
||||||
return false;
|
return false;
|
||||||
return Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'newsletter');
|
return Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'newsletter');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
@@ -159,19 +159,19 @@ class Blocknewsletter extends Module
|
|||||||
* 1 = registered in block
|
* 1 = registered in block
|
||||||
* 2 = registered in customer
|
* 2 = registered in customer
|
||||||
*/
|
*/
|
||||||
private function isNewsletterRegistered($customerEmail)
|
private function isNewsletterRegistered($customerEmail)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT `email`
|
$sql = 'SELECT `email`
|
||||||
FROM '._DB_PREFIX_.'newsletter
|
FROM '._DB_PREFIX_.'newsletter
|
||||||
WHERE `email` = \''.pSQL($customerEmail).'\'
|
WHERE `email` = \''.pSQL($customerEmail).'\'
|
||||||
AND id_shop = '.$this->context->shop->getID(true);
|
AND id_shop = '.$this->context->shop->getID(true);
|
||||||
|
|
||||||
if (Db::getInstance()->getRow($sql))
|
if (Db::getInstance()->getRow($sql))
|
||||||
return self::GUEST_REGISTERED;
|
return self::GUEST_REGISTERED;
|
||||||
|
|
||||||
$sql = 'SELECT `newsletter`
|
$sql = 'SELECT `newsletter`
|
||||||
FROM '._DB_PREFIX_.'customer
|
FROM '._DB_PREFIX_.'customer
|
||||||
WHERE `email` = \''.pSQL($customerEmail).'\'
|
WHERE `email` = \''.pSQL($customerEmail).'\'
|
||||||
AND id_shop = '.$this->context->shop->getID(true);
|
AND id_shop = '.$this->context->shop->getID(true);
|
||||||
|
|
||||||
if (!$registered = Db::getInstance()->getRow($sql))
|
if (!$registered = Db::getInstance()->getRow($sql))
|
||||||
@@ -181,44 +181,44 @@ class Blocknewsletter extends Module
|
|||||||
return self::CUSTOMER_REGISTERED;
|
return self::CUSTOMER_REGISTERED;
|
||||||
|
|
||||||
return self::CUSTOMER_NOT_REGISTERED;
|
return self::CUSTOMER_NOT_REGISTERED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register in block newsletter
|
* Register in block newsletter
|
||||||
*/
|
*/
|
||||||
private function newsletterRegistration()
|
private function newsletterRegistration()
|
||||||
{
|
{
|
||||||
if (empty($_POST['email']) OR !Validate::isEmail($_POST['email']))
|
if (empty($_POST['email']) OR !Validate::isEmail($_POST['email']))
|
||||||
return $this->error = $this->l('Invalid e-mail address');
|
return $this->error = $this->l('Invalid e-mail address');
|
||||||
|
|
||||||
/* Unsubscription */
|
/* Unsubscription */
|
||||||
else if ($_POST['action'] == '1')
|
else if ($_POST['action'] == '1')
|
||||||
{
|
{
|
||||||
$register_status = $this->isNewsletterRegistered($_POST['email']);
|
$register_status = $this->isNewsletterRegistered($_POST['email']);
|
||||||
if ($register_status < 1)
|
if ($register_status < 1)
|
||||||
return $this->error = $this->l('E-mail address not registered');
|
return $this->error = $this->l('E-mail address not registered');
|
||||||
else if ($register_status == self::GUEST_REGISTERED)
|
else if ($register_status == self::GUEST_REGISTERED)
|
||||||
{
|
{
|
||||||
if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'newsletter WHERE `email` = \''.pSQL($_POST['email']).'\' AND id_shop = '.$this->context->shop->getID(true)))
|
if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'newsletter WHERE `email` = \''.pSQL($_POST['email']).'\' AND id_shop = '.$this->context->shop->getID(true)))
|
||||||
return $this->error = $this->l('Error during unsubscription');
|
return $this->error = $this->l('Error during unsubscription');
|
||||||
return $this->valid = $this->l('Unsubscription successful');
|
return $this->valid = $this->l('Unsubscription successful');
|
||||||
}
|
}
|
||||||
else if ($register_status == self::CUSTOMER_REGISTERED)
|
else if ($register_status == self::CUSTOMER_REGISTERED)
|
||||||
{
|
{
|
||||||
if (!Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'customer SET `newsletter` = 0 WHERE `email` = \''.pSQL($_POST['email']).'\' AND id_shop = '.$this->context->shop->getID(true)))
|
if (!Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'customer SET `newsletter` = 0 WHERE `email` = \''.pSQL($_POST['email']).'\' AND id_shop = '.$this->context->shop->getID(true)))
|
||||||
return $this->error = $this->l('Error during unsubscription');
|
return $this->error = $this->l('Error during unsubscription');
|
||||||
return $this->valid = $this->l('Unsubscription successful');
|
return $this->valid = $this->l('Unsubscription successful');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Subscription */
|
/* Subscription */
|
||||||
else if ($_POST['action'] == '0')
|
else if ($_POST['action'] == '0')
|
||||||
{
|
{
|
||||||
$register_status = $this->isNewsletterRegistered($_POST['email']);
|
$register_status = $this->isNewsletterRegistered($_POST['email']);
|
||||||
if ($register_status > 0)
|
//if ($register_status > 0)
|
||||||
return $this->error = $this->l('E-mail address already registered');
|
// return $this->error = $this->l('E-mail address already registered');
|
||||||
|
|
||||||
$email = pSQL($_POST['email']);
|
$email = pSQL($_POST['email']);
|
||||||
if (!$this->isRegistered($register_status))
|
if (true || !$this->isRegistered($register_status))
|
||||||
{
|
{
|
||||||
if (Configuration::get('NW_VERIFICATION_EMAIL'))
|
if (Configuration::get('NW_VERIFICATION_EMAIL'))
|
||||||
{
|
{
|
||||||
@@ -229,49 +229,48 @@ class Blocknewsletter extends Module
|
|||||||
if (!$token = $this->getToken($email, $register_status))
|
if (!$token = $this->getToken($email, $register_status))
|
||||||
return $this->error = $this->l('Error during subscription');
|
return $this->error = $this->l('Error during subscription');
|
||||||
|
|
||||||
$this->sendVerificationEmail($email, $token);
|
|
||||||
return $this->valid = $this->l('A verification email has been sent. Please check your email.');
|
return $this->valid = $this->l('A verification email has been sent. Please check your email.');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($this->register($email, $register_status))
|
if ($this->register($email, $register_status))
|
||||||
$this->valid = $this->l('Subscription successful');
|
$this->valid = $this->l('Subscription successful');
|
||||||
else
|
else
|
||||||
return $this->error = $this->l('Error during subscription');
|
return $this->error = $this->l('Error during subscription');
|
||||||
|
|
||||||
if ($code = Configuration::get('NW_VOUCHER_CODE'))
|
if ($code = Configuration::get('NW_VOUCHER_CODE'))
|
||||||
$this->sendVoucher($email, $code);
|
$this->sendVoucher($email, $code);
|
||||||
|
|
||||||
if (Configuration::get('NW_CONFIRMATION_EMAIL'))
|
if (Configuration::get('NW_CONFIRMATION_EMAIL'))
|
||||||
$this->sendConfirmationEmail($email);
|
$this->sendConfirmationEmail($email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the registered status correspond to a registered user
|
* Return true if the registered status correspond to a registered user
|
||||||
* @param int $register_status
|
* @param int $register_status
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function isRegistered($register_status)
|
protected function isRegistered($register_status)
|
||||||
{
|
{
|
||||||
return in_array(
|
return in_array(
|
||||||
$register_status,
|
$register_status,
|
||||||
array(self::GUEST_REGISTERED, self::CUSTOMER_REGISTERED)
|
array(self::GUEST_REGISTERED, self::CUSTOMER_REGISTERED)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe an email to the newsletter. It will create an entry in the newsletter table
|
* Subscribe an email to the newsletter. It will create an entry in the newsletter table
|
||||||
* or update the customer table depending of the register status
|
* or update the customer table depending of the register status
|
||||||
*
|
*
|
||||||
* @param unknown_type $email
|
* @param unknown_type $email
|
||||||
* @param unknown_type $register_status
|
* @param unknown_type $register_status
|
||||||
*/
|
*/
|
||||||
protected function register($email, $register_status)
|
protected function register($email, $register_status)
|
||||||
{
|
{
|
||||||
if ($register_status == self::GUEST_NOT_REGISTERED)
|
if ($register_status == self::GUEST_NOT_REGISTERED)
|
||||||
{
|
{
|
||||||
if (!$this->registerGuest(Tools::getValue('email')))
|
if (!$this->registerGuest(Tools::getValue('email')))
|
||||||
@@ -280,38 +279,38 @@ class Blocknewsletter extends Module
|
|||||||
else if ($register_status == self::CUSTOMER_NOT_REGISTERED)
|
else if ($register_status == self::CUSTOMER_NOT_REGISTERED)
|
||||||
{
|
{
|
||||||
if (!$this->registerUser(Tools::getValue('email')))
|
if (!$this->registerUser(Tools::getValue('email')))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe a customer to the newsletter
|
* Subscribe a customer to the newsletter
|
||||||
*
|
*
|
||||||
* @param string $email
|
* @param string $email
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function registerUser($email)
|
protected function registerUser($email)
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE '._DB_PREFIX_.'customer
|
$sql = 'UPDATE '._DB_PREFIX_.'customer
|
||||||
SET `newsletter` = 1, newsletter_date_add = NOW(), `ip_registration_newsletter` = \''.pSQL(Tools::getRemoteAddr()).'\'
|
SET `newsletter` = 1, newsletter_date_add = NOW(), `ip_registration_newsletter` = \''.pSQL(Tools::getRemoteAddr()).'\'
|
||||||
WHERE `email` = \''.pSQL($email).'\'
|
WHERE `email` = \''.pSQL($email).'\'
|
||||||
AND id_shop = '.$this->context->shop->getID(true);
|
AND id_shop = '.$this->context->shop->getID(true);
|
||||||
|
|
||||||
return Db::getInstance()->execute($sql);
|
return Db::getInstance()->execute($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe a guest to the newsletter
|
* Subscribe a guest to the newsletter
|
||||||
*
|
*
|
||||||
* @param string $email
|
* @param string $email
|
||||||
* @param bool $active
|
* @param bool $active
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function registerGuest($email, $active = true)
|
protected function registerGuest($email, $active = true)
|
||||||
{
|
{
|
||||||
$sql = 'INSERT INTO '._DB_PREFIX_.'newsletter (id_shop, id_group_shop, email, newsletter_date_add, ip_registration_newsletter, http_referer, active)
|
$sql = 'INSERT INTO '._DB_PREFIX_.'newsletter (id_shop, id_group_shop, email, newsletter_date_add, ip_registration_newsletter, http_referer, active)
|
||||||
VALUES
|
VALUES
|
||||||
('.$this->context->shop->getID().',
|
('.$this->context->shop->getID().',
|
||||||
'.$this->context->shop->getGroupID().',
|
'.$this->context->shop->getGroupID().',
|
||||||
@@ -328,55 +327,55 @@ class Blocknewsletter extends Module
|
|||||||
)';
|
)';
|
||||||
|
|
||||||
return Db::getInstance()->execute($sql);
|
return Db::getInstance()->execute($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function activateGuest($email)
|
public function activateGuest($email)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'newsletter`
|
return Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'newsletter`
|
||||||
SET `active` = 1
|
SET `active` = 1
|
||||||
WHERE `email` = \''.pSQL($email).'\''
|
WHERE `email` = \''.pSQL($email).'\''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a guest email by token
|
|
||||||
* @param string $token
|
|
||||||
* @return string email
|
|
||||||
*/
|
|
||||||
protected function getGuestEmailByToken($token)
|
|
||||||
{
|
|
||||||
$sql = 'SELECT `email`
|
|
||||||
FROM `'._DB_PREFIX_.'newsletter`
|
|
||||||
WHERE MD5(CONCAT( `email` , `newsletter_date_add`, \''.pSQL(Configuration::get('NW_SALT')).'\')) = \''.pSQL($token).'\'
|
|
||||||
AND `active` = 0';
|
|
||||||
|
|
||||||
return Db::getInstance()->getValue($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a customer email by token
|
* Returns a guest email by token
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @return string email
|
* @return string email
|
||||||
*/
|
*/
|
||||||
protected function getUserEmailByToken($token)
|
protected function getGuestEmailByToken($token)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT `email`
|
$sql = 'SELECT `email`
|
||||||
FROM `'._DB_PREFIX_.'customer`
|
FROM `'._DB_PREFIX_.'newsletter`
|
||||||
WHERE MD5(CONCAT( `email` , `date_add`, \''.pSQL(Configuration::get('NW_SALT')).'\')) = \''.pSQL($token).'\'
|
WHERE MD5(CONCAT( `email` , `newsletter_date_add`, \''.pSQL(Configuration::get('NW_SALT')).'\')) = \''.pSQL($token).'\'
|
||||||
AND `newsletter` = 0';
|
AND `active` = 0';
|
||||||
|
|
||||||
return Db::getInstance()->getValue($sql);
|
return Db::getInstance()->getValue($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a token associated to an user
|
* Returns a customer email by token
|
||||||
*
|
* @param string $token
|
||||||
* @param string $email
|
* @return string email
|
||||||
* @param string $register_status
|
*/
|
||||||
*/
|
protected function getUserEmailByToken($token)
|
||||||
protected function getToken($email, $register_status)
|
{
|
||||||
{
|
$sql = 'SELECT `email`
|
||||||
|
FROM `'._DB_PREFIX_.'customer`
|
||||||
|
WHERE MD5(CONCAT( `email` , `date_add`, \''.pSQL(Configuration::get('NW_SALT')).'\')) = \''.pSQL($token).'\'
|
||||||
|
AND `newsletter` = 0';
|
||||||
|
|
||||||
|
return Db::getInstance()->getValue($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a token associated to an user
|
||||||
|
*
|
||||||
|
* @param string $email
|
||||||
|
* @param string $register_status
|
||||||
|
*/
|
||||||
|
protected function getToken($email, $register_status)
|
||||||
|
{
|
||||||
if (in_array($register_status, array(self::GUEST_NOT_REGISTERED, self::GUEST_REGISTERED)))
|
if (in_array($register_status, array(self::GUEST_NOT_REGISTERED, self::GUEST_REGISTERED)))
|
||||||
{
|
{
|
||||||
$sql = 'SELECT MD5(CONCAT( `email` , `newsletter_date_add`, \''.pSQL(Configuration::get('NW_SALT')).'\')) as token
|
$sql = 'SELECT MD5(CONCAT( `email` , `newsletter_date_add`, \''.pSQL(Configuration::get('NW_SALT')).'\')) as token
|
||||||
@@ -393,40 +392,40 @@ class Blocknewsletter extends Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Db::getInstance()->getValue($sql);
|
return Db::getInstance()->getValue($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ends the registration process to the newsletter
|
* Ends the registration process to the newsletter
|
||||||
*
|
*
|
||||||
* @param string $token
|
* @param string $token
|
||||||
*/
|
*/
|
||||||
public function confirmEmail($token)
|
public function confirmEmail($token)
|
||||||
{
|
{
|
||||||
$activated = false;
|
$activated = false;
|
||||||
|
|
||||||
if ($email = $this->getGuestEmailByToken($token))
|
if ($email = $this->getGuestEmailByToken($token))
|
||||||
$activated = $this->activateGuest($email);
|
$activated = $this->activateGuest($email);
|
||||||
else if ($email = $this->getUserEmailByToken($token))
|
else if ($email = $this->getUserEmailByToken($token))
|
||||||
$activated = $this->registerUser($email);
|
$activated = $this->registerUser($email);
|
||||||
|
|
||||||
if (!$activated)
|
if (!$activated)
|
||||||
return $this->l('Email already registered or invalid');
|
return $this->l('Email already registered or invalid');
|
||||||
|
|
||||||
if ($discount = Configuration::get('NW_VOUCHER_CODE'))
|
if ($discount = Configuration::get('NW_VOUCHER_CODE'))
|
||||||
$this->sendVoucher($email, $discount);
|
$this->sendVoucher($email, $discount);
|
||||||
|
|
||||||
if (Configuration::get('NW_CONFIRMATION_EMAIL'))
|
if (Configuration::get('NW_CONFIRMATION_EMAIL'))
|
||||||
$this->sendConfirmationEmail($email);
|
$this->sendConfirmationEmail($email);
|
||||||
|
|
||||||
return $this->l('Thank you for subscribing to our newsletter.');
|
return $this->l('Thank you for subscribing to our newsletter.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send an email containing a voucher code
|
* Send an email containing a voucher code
|
||||||
* @param string $email
|
* @param string $email
|
||||||
* @param string $discount
|
* @param string $discount
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function sendVoucher($email, $code)
|
protected function sendVoucher($email, $code)
|
||||||
{
|
{
|
||||||
return Mail::Send($this->context->language->id, 'newsletter_voucher', Mail::l('Newsletter voucher', $this->context->language->id), array('{discount}' => $code), $email, null, null, null, null, null, dirname(__FILE__).'/mails/');
|
return Mail::Send($this->context->language->id, 'newsletter_voucher', Mail::l('Newsletter voucher', $this->context->language->id), array('{discount}' => $code), $email, null, null, null, null, null, dirname(__FILE__).'/mails/');
|
||||||
@@ -450,7 +449,7 @@ class Blocknewsletter extends Module
|
|||||||
*/
|
*/
|
||||||
protected function sendVerificationEmail($email, $token)
|
protected function sendVerificationEmail($email, $token)
|
||||||
{
|
{
|
||||||
$verif_url = Tools::getShopDomain(true)._MODULE_DIR_.$this->name.'/verification.php?token='.$token;
|
$verif_url = Context::getContext()->link->getModuleLink('blocknewsletter', 'verification').'&token='.$token;
|
||||||
return Mail::Send($this->context->language->id, 'newsletter_verif', Mail::l('Email verification', $this->context->language->id), array('{verif_url}' => $verif_url), $email, null, null, null, null, null, dirname(__FILE__).'/mails/');
|
return Mail::Send($this->context->language->id, 'newsletter_verif', Mail::l('Email verification', $this->context->language->id), array('{verif_url}' => $verif_url), $email, null, null, null, null, null, dirname(__FILE__).'/mails/');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,7 +481,7 @@ class Blocknewsletter extends Module
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->smarty->assign('this_path', $this->_path);
|
$this->smarty->assign('this_path', $this->_path);
|
||||||
return $this->display(__FILE__, 'blocknewsletter.tpl');
|
return $this->display(__FILE__, 'blocknewsletter.tpl');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hookDisplayHeader($params)
|
public function hookDisplayHeader($params)
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* 2007-2011 PrestaShop
|
||||||
|
*
|
||||||
|
* NOTICE OF LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||||
|
* that is bundled with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://opensource.org/licenses/afl-3.0.php
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@prestashop.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* DISCLAIMER
|
||||||
|
*
|
||||||
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||||
|
* versions in the future. If you wish to customize PrestaShop for your
|
||||||
|
* needs please refer to http://www.prestashop.com for more information.
|
||||||
|
*
|
||||||
|
* @author PrestaShop SA <contact@prestashop.com>
|
||||||
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
|
* @version Release: $Revision$
|
||||||
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.5.0
|
||||||
|
*/
|
||||||
|
class ModuleBlocknewsletterController extends ModuleController
|
||||||
|
{
|
||||||
|
private $message = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see FrontController::postProcess()
|
||||||
|
*/
|
||||||
|
public function postProcess()
|
||||||
|
{
|
||||||
|
$this->display_column_left = true;
|
||||||
|
if ($this->process == 'verification')
|
||||||
|
$this->processVerification();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate cheque payment
|
||||||
|
*/
|
||||||
|
public function processVerification()
|
||||||
|
{
|
||||||
|
$module = new Blocknewsletter();
|
||||||
|
$this->message = $module->confirmEmail(Tools::getValue('token'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see FrontController::initContent()
|
||||||
|
*/
|
||||||
|
public function initContent()
|
||||||
|
{
|
||||||
|
parent::initContent();
|
||||||
|
|
||||||
|
if ($this->process == 'verification')
|
||||||
|
$this->assignVerificationExecution();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign cheque payment template
|
||||||
|
*/
|
||||||
|
public function assignVerificationExecution()
|
||||||
|
{
|
||||||
|
$this->context->smarty->assign('message', $this->message);
|
||||||
|
|
||||||
|
$this->setTemplate('verification_execution.tpl');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
||||||
|
Tools::displayFileAsDeprecated();
|
||||||
|
|
||||||
require_once('blocknewsletter.php');
|
require_once('blocknewsletter.php');
|
||||||
|
|
||||||
$module = new Blocknewsletter();
|
$module = new Blocknewsletter();
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{*
|
||||||
|
* 2007-2011 PrestaShop
|
||||||
|
*
|
||||||
|
* NOTICE OF LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||||
|
* that is bundled with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://opensource.org/licenses/afl-3.0.php
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@prestashop.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* DISCLAIMER
|
||||||
|
*
|
||||||
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||||
|
* versions in the future. If you wish to customize PrestaShop for your
|
||||||
|
* needs please refer to http://www.prestashop.com for more information.
|
||||||
|
*
|
||||||
|
* @author PrestaShop SA <contact@prestashop.com>
|
||||||
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
|
* @version Release: $Revision$
|
||||||
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*}
|
||||||
|
{$message}
|
||||||
@@ -23,12 +23,6 @@
|
|||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
<script type="text/javascript">
|
|
||||||
// <![CDATA[
|
|
||||||
var baseDir = '{$base_dir_ssl}';
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{*
|
{*
|
||||||
** Compatibility code for Prestashop older than 1.4.2 using a recent theme
|
** Compatibility code for Prestashop older than 1.4.2 using a recent theme
|
||||||
** Ignore list isn't require here
|
** Ignore list isn't require here
|
||||||
|
|||||||
@@ -78,7 +78,6 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//<![CDATA[
|
//<![CDATA[
|
||||||
var baseDir = '{$base_dir_ssl}';
|
|
||||||
{literal}
|
{literal}
|
||||||
$(document).ready(function()
|
$(document).ready(function()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1000,6 +1000,7 @@ margin: 10px 0 0 0;*/
|
|||||||
#order .delivery_option.alternate_item, #orderopc .delivery_option.alternate_item {
|
#order .delivery_option.alternate_item, #orderopc .delivery_option.alternate_item {
|
||||||
border-top: 1px solid #bdc2c9;
|
border-top: 1px solid #bdc2c9;
|
||||||
background: #f1f2f4;
|
background: #f1f2f4;
|
||||||
|
border-bottom: 1px solid #bdc2c9;
|
||||||
}
|
}
|
||||||
#order .delivery_option label > table.resume td, #orderopc .delivery_option label > table.resume td {
|
#order .delivery_option label > table.resume td, #orderopc .delivery_option label > table.resume td {
|
||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
@@ -1018,7 +1019,7 @@ margin: 10px 0 0 0;*/
|
|||||||
padding-left:10px;
|
padding-left:10px;
|
||||||
width: 160px;
|
width: 160px;
|
||||||
}
|
}
|
||||||
#order .delivery_options_address .delivery_option_logo img, #orderopc .delivery_options_address .delivery_option_logo img { height: 40px; }
|
#order .delivery_options_address .delivery_option_logo img, #orderopc .delivery_options_address .delivery_option_logo img { /*height: 40px;*/ }
|
||||||
#orderopc .delivery_option_carrier {
|
#orderopc .delivery_option_carrier {
|
||||||
margin: 0 0 0 45px;
|
margin: 0 0 0 45px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
@@ -1032,10 +1033,10 @@ margin: 10px 0 0 0;*/
|
|||||||
|
|
||||||
.order_carrier_content {
|
.order_carrier_content {
|
||||||
padding:15px;
|
padding:15px;
|
||||||
border:1px solid #ccc;
|
border:1px solid #ccc;
|
||||||
font-size:12px;
|
font-size:12px;
|
||||||
color:#000;
|
color:#000;
|
||||||
background:#f8f8f8
|
background:#f8f8f8
|
||||||
}
|
}
|
||||||
.order_carrier_content h3 {
|
.order_carrier_content h3 {
|
||||||
padding:15px 0 10px 0;
|
padding:15px 0 10px 0;
|
||||||
@@ -1609,8 +1610,8 @@ ul#suppliers_list li .right_side {float:right;}
|
|||||||
/* ************************************************************************************************
|
/* ************************************************************************************************
|
||||||
addons paypal
|
addons paypal
|
||||||
************************************************************************************************ */
|
************************************************************************************************ */
|
||||||
#module-paypal-payment-submit #left_column {display:none}
|
#module-payment-submit #left_column {display:none}
|
||||||
#module-paypal-payment-submit #center_column{width:757px}
|
#module-payment-submit #center_column{width:757px}
|
||||||
|
|
||||||
|
|
||||||
/* ************************************************************************************************
|
/* ************************************************************************************************
|
||||||
|
|||||||
@@ -23,13 +23,6 @@
|
|||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
//<![CDATA[
|
|
||||||
var baseDir = '{$base_dir_ssl}';
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{capture name=path}<a href="{$link->getPageLink('my-account.php', true)}">{l s='My account'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='My Vouchers'}{/capture}
|
{capture name=path}<a href="{$link->getPageLink('my-account.php', true)}">{l s='My account'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='My Vouchers'}{/capture}
|
||||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
{include file="$tpl_dir./breadcrumb.tpl"}
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,6 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
//<![CDATA[
|
|
||||||
var baseDir = '{$base_dir_ssl}';
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{capture name=path}<a href="{$link->getPageLink('my-account', true)}">{l s='My account'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='Order history'}{/capture}
|
{capture name=path}<a href="{$link->getPageLink('my-account', true)}">{l s='My account'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='Order history'}{/capture}
|
||||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
{include file="$tpl_dir./breadcrumb.tpl"}
|
||||||
{include file="$tpl_dir./errors.tpl"}
|
{include file="$tpl_dir./errors.tpl"}
|
||||||
|
|||||||
@@ -24,12 +24,6 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
//<![CDATA[
|
|
||||||
var baseDir = '{$base_dir_ssl}';
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{capture name=path}<a href="{$link->getPageLink('my-account', true)}">{l s='My account'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='Your personal information'}{/capture}
|
{capture name=path}<a href="{$link->getPageLink('my-account', true)}">{l s='My account'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='Your personal information'}{/capture}
|
||||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
{include file="$tpl_dir./breadcrumb.tpl"}
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,6 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
//<![CDATA[
|
|
||||||
var baseDir = '{$base_dir_ssl}';
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{capture name=path}{l s='My account'}{/capture}
|
{capture name=path}{l s='My account'}{/capture}
|
||||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
{include file="$tpl_dir./breadcrumb.tpl"}
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,6 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
//<![CDATA[
|
|
||||||
var baseDir = '{$base_dir_ssl}';
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{capture name=path}{l s='Order confirmation'}{/capture}
|
{capture name=path}{l s='Order confirmation'}{/capture}
|
||||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
{include file="$tpl_dir./breadcrumb.tpl"}
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,6 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
//<![CDATA[
|
|
||||||
var baseDir = '{$base_dir_ssl}';
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{capture name=path}<a href="{$link->getPageLink('my-account', true)}">{l s='My account'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='Return Merchandise Authorization (RMA)'}{/capture}
|
{capture name=path}<a href="{$link->getPageLink('my-account', true)}">{l s='My account'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='Return Merchandise Authorization (RMA)'}{/capture}
|
||||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
{include file="$tpl_dir./breadcrumb.tpl"}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
{else}
|
{else}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// <![CDATA[
|
// <![CDATA[
|
||||||
var baseDir = '{$base_dir_ssl}';
|
|
||||||
var imgDir = '{$img_dir}';
|
var imgDir = '{$img_dir}';
|
||||||
var authenticationUrl = '{$link->getPageLink("authentication", true)}';
|
var authenticationUrl = '{$link->getPageLink("authentication", true)}';
|
||||||
var orderOpcUrl = '{$link->getPageLink("order-opc", true)}';
|
var orderOpcUrl = '{$link->getPageLink("order-opc", true)}';
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
{if !$opc}
|
{if !$opc}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// <![CDATA[
|
// <![CDATA[
|
||||||
var baseDir = '{$base_dir_ssl}';
|
|
||||||
var currencySign = '{$currencySign|html_entity_decode:2:"UTF-8"}';
|
var currencySign = '{$currencySign|html_entity_decode:2:"UTF-8"}';
|
||||||
var currencyRate = '{$currencyRate|floatval}';
|
var currencyRate = '{$currencyRate|floatval}';
|
||||||
var currencyFormat = '{$currencyFormat|intval}';
|
var currencyFormat = '{$currencyFormat|intval}';
|
||||||
|
|||||||
@@ -24,12 +24,6 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
//<![CDATA[
|
|
||||||
var baseDir = '{$base_dir_ssl}';
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{capture name=path}<a href="{$link->getPageLink('my-account', true)}">{l s='My account'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='Credit slips'}{/capture}
|
{capture name=path}<a href="{$link->getPageLink('my-account', true)}">{l s='My account'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='Credit slips'}{/capture}
|
||||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
{include file="$tpl_dir./breadcrumb.tpl"}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user