Merge branch 'mailalerts_real_multishop' of https://github.com/axome/PrestaShop into axome-mailalerts_real_multishop

Conflicts:
	modules/mailalerts/mailalerts.php
This commit is contained in:
gRoussac
2013-09-12 10:09:25 +02:00
4 changed files with 211 additions and 112 deletions
+46 -17
View File
@@ -36,6 +36,8 @@ class MailAlert extends ObjectModel
public $id_shop;
public $id_lang;
/**
* @see ObjectModel::$definition
*/
@@ -47,15 +49,19 @@ class MailAlert extends ObjectModel
'customer_email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true),
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true)
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true)
),
);
public static function customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop = null)
public static function customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop = null, $id_lang = null)
{
if ($id_shop == null)
$id_shop = Context::getContext()->shop->id;
if ($id_lang == null)
$id_lang = Context::getContext()->language->id;
$customer = new Customer($id_customer);
$customer_email = $customer->email;
@@ -70,14 +76,15 @@ class MailAlert extends ObjectModel
return count(Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql));
}
public static function deleteAlert($id_customer, $customer_email, $id_product, $id_product_attribute)
public static function deleteAlert($id_customer, $customer_email, $id_product, $id_product_attribute, $id_shop)
{
$sql = '
DELETE FROM `'._DB_PREFIX_.self::$definition['table'].'`
WHERE '.(($id_customer > 0) ? '(`customer_email` = \''.pSQL($customer_email).'\' OR `id_customer` = '.(int)$id_customer.')' :
'`customer_email` = \''.pSQL($customer_email).'\'').
' AND `id_product` = '.(int)$id_product.'
AND `id_product_attribute` = '.(int)$id_product_attribute;
AND `id_product_attribute` = '.(int)$id_product_attribute.'
AND `id_shop` = '.(int)$id_shop;
return Db::getInstance()->execute($sql);
}
@@ -160,17 +167,23 @@ class MailAlert extends ObjectModel
public static function sendCustomerAlert($id_product, $id_product_attribute)
{
$link = new Link();
$id_lang = (int)Context::getContext()->language->id;
$product = new Product((int)$id_product, false, $id_lang);
$templateVars = array(
'{product}' => (is_array($product->name) ? $product->name[$id_lang] : $product->name),
'{product_link}' => $link->getProductLink($product)
);
$context = Context::getContext()->cloneContext();
$customers = self::getCustomers($id_product, $id_product_attribute);
foreach ($customers as $customer)
{
$id_shop = (int)$customer['id_shop'];
$id_lang = (int)$customer['id_lang'];
$context->shop->id = $id_shop;
$context->language->id = $id_lang;
$product = new Product((int)$id_product, false, $id_lang, $id_shop);
$product_link = $link->getProductLink($product, $product->link_rewrite, null, null, $id_lang, $id_shop);
$templateVars = array(
'{product}' => (is_array($product->name) ? $product->name[$id_lang] : $product->name),
'{product_link}' => $product_link
);
if ($customer['id_customer'])
{
$customer = new Customer((int)$customer['id_customer']);
@@ -182,14 +195,30 @@ class MailAlert extends ObjectModel
$customer_id = 0;
$customer_email = $customer['customer_email'];
}
$iso = Language::getIsoById($id_lang);
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.txt') &&
file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.html'))
Mail::Send((int)Configuration::get('PS_LANG_DEFAULT'), 'customer_qty', Mail::l('Product available', $id_lang), $templateVars, strval($customer_email), NULL, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/');
Mail::Send(
$id_lang,
'customer_qty',
Mail::l('Product available', $id_lang),
$templateVars,
strval($customer_email),
NULL,
strval(Configuration::get('PS_SHOP_EMAIL', null, null, $id_shop)),
strval(Configuration::get('PS_SHOP_NAME', null, null, $id_shop)),
NULL,
NULL,
dirname(__FILE__).'/mails/',
false,
$id_shop
);
Hook::exec('actionModuleMailAlertSendCustomer', array('product' => (is_array($product->name) ? $product->name[$id_lang] : $product->name), 'link' => $link->getProductLink($product), 'customer' => $customer, 'product_obj' => $product));
self::deleteAlert((int)$customer_id, strval($customer_email), (int)$id_product, (int)$id_product_attribute);
Hook::exec('actionModuleMailAlertSendCustomer', array('product' => (is_array($product->name) ? $product->name[$id_lang] : $product->name), 'link' => $product_link, 'customer' => $customer, 'product_obj' => $product));
self::deleteAlert((int)$customer_id, strval($customer_email), (int)$id_product, (int)$id_product_attribute, $id_shop);
}
}
@@ -244,7 +273,7 @@ class MailAlert extends ObjectModel
public static function getCustomers($id_product, $id_product_attribute)
{
$sql = '
SELECT id_customer, customer_email
SELECT id_customer, customer_email, id_shop, id_lang
FROM `'._DB_PREFIX_.self::$definition['table'].'`
WHERE `id_product` = '.(int)$id_product.' AND `id_product_attribute` = '.(int)$id_product_attribute;
@@ -64,8 +64,10 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController
if (!Validate::isLoadedObject($product))
die('0');
if (MailAlert::deleteAlert((int)Context::getContext()->customer->id, (int)Context::getContext()->customer->email, (int)$product->id, (int)$this->id_product_attribute))
$context = Context::getContext();
if (MailAlert::deleteAlert((int)$context->customer->id, (int)$context->customer->email, (int)$product->id, (int)$this->id_product_attribute))
die('0');
die(1);
}
@@ -74,29 +76,32 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController
*/
public function processAdd()
{
if (Context::getContext()->customer->isLogged())
$context = Context::getContext();
if ($context->customer->isLogged())
{
$id_customer = (int)Context::getContext()->customer->id;
$id_customer = (int)$context->customer->id;
$customer = new Customer($id_customer);
$customer_email = strval($customer->email);
}
else
{
$customer_email = strval(Tools::getValue('customer_email'));
$customer = Context::getContext()->customer->getByEmail($customer_email);
$customer = $context->customer->getByEmail($customer_email);
$id_customer = (isset($customer->id) && ($customer->id != null)) ? (int)$customer->id : null;
}
$id_product = (int)Tools::getValue('id_product');
$id_product_attribute = (int)Tools::getValue('id_product_attribute');
$id_shop = (int)Context::getContext()->shop->id;
$product = new Product($id_product, null, null, $id_shop, Context::getContext());
$id_shop = (int)$context->shop->id;
$id_lang = (int)$context->language->id;
$product = new Product($id_product, false, $id_lang, $id_shop, $context);
$mailAlert = MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop);
if ($mailAlert)
die('2');
else if (!Validate::isLoadedObject($product))
elseif (!Validate::isLoadedObject($product))
die('0');
$mailAlert = new MailAlert();
@@ -106,10 +111,11 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController
$mailAlert->id_product = (int)$id_product;
$mailAlert->id_product_attribute = (int)$id_product_attribute;
$mailAlert->id_shop = (int)$id_shop;
$mailAlert->id_lang = (int)$id_lang;
if ($mailAlert->add() !== false)
die('1');
die('0');
}
@@ -122,15 +128,15 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController
die('0');
$id_customer = (int)$this->context->customer->id;
if (!$id_product = (int)(Tools::getValue('id_product')))
die ('0');
$id_product_attribute = (int)(Tools::getValue('id_product_attribute'));
$id_shop = (int)Context::getContext()->shop->id;
if (MailAlert::customerHasNotification((int)$id_customer, (int)$id_product, (int)$id_product_attribute, (int)$id_shop))
die ('1');
if (!$id_product = (int)(Tools::getValue('id_product')))
die('0');
$id_product_attribute = (int)(Tools::getValue('id_product_attribute'));
if (MailAlert::customerHasNotification((int)$id_customer, (int)$id_product, (int)$id_product_attribute, (int)$this->context->shop->id))
die('1');
die('0');
}
}
+114 -79
View File
@@ -40,13 +40,13 @@ class MailAlerts extends Module
private $_merchant_coverage;
private $_product_coverage;
const __MA_MAIL_DELIMITOR__ = ',';
const __MA_MAIL_DELIMITOR__ = "\n";
public function __construct()
{
$this->name = 'mailalerts';
$this->tab = 'administration';
$this->version = '2.4';
$this->version = '2.5';
$this->author = 'PrestaShop';
$this->need_instance = 0;
@@ -100,7 +100,8 @@ class MailAlerts extends Module
`id_product` int(10) unsigned NOT NULL,
`id_product_attribute` int(10) unsigned NOT NULL,
`id_shop` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_customer`,`customer_email`,`id_product`,`id_product_attribute`)
`id_lang` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_customer`,`customer_email`,`id_product`,`id_product_attribute`,`id_shop`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
if (!Db::getInstance()->execute($sql))
@@ -161,7 +162,7 @@ class MailAlerts extends Module
$errors[] = $this->l('Invalid e-mail:').' '.Tools::safeOutput($email);
break;
}
else if (!empty($email) && count($email) > 0)
elseif (!empty($email) && count($email) > 0)
$emails[$k] = $email;
else
unset($emails[$k]);
@@ -171,15 +172,15 @@ class MailAlerts extends Module
if (!Configuration::updateValue('MA_MERCHANT_MAILS', strval($emails)))
$errors[] = $this->l('Cannot update settings');
else if (!Configuration::updateValue('MA_MERCHANT_ORDER', (int)Tools::getValue('mA_merchand_order')))
elseif (!Configuration::updateValue('MA_MERCHANT_ORDER', (int)Tools::getValue('mA_merchand_order')))
$errors[] = $this->l('Cannot update settings');
else if (!Configuration::updateValue('MA_MERCHANT_OOS', (int)Tools::getValue('mA_merchand_oos')))
elseif (!Configuration::updateValue('MA_MERCHANT_OOS', (int)Tools::getValue('mA_merchand_oos')))
$errors[] = $this->l('Cannot update settings');
else if (!Configuration::updateValue('MA_LAST_QTIES', (int)Tools::getValue('MA_LAST_QTIES')))
elseif (!Configuration::updateValue('MA_LAST_QTIES', (int)Tools::getValue('MA_LAST_QTIES')))
$errors[] = $this->l('Cannot update settings');
else if (!Configuration::updateGlobalValue('MA_MERCHANT_COVERAGE', (int)Tools::getValue('mA_merchant_coverage')))
elseif (!Configuration::updateGlobalValue('MA_MERCHANT_COVERAGE', (int)Tools::getValue('mA_merchant_coverage')))
$errors[] = $this->l('Cannot update settings');
else if (!Configuration::updateGlobalValue('MA_PRODUCT_COVERAGE', (int)Tools::getValue('MA_PRODUCT_COVERAGE')))
elseif (!Configuration::updateGlobalValue('MA_PRODUCT_COVERAGE', (int)Tools::getValue('MA_PRODUCT_COVERAGE')))
$errors[] = $this->l('Cannot update settings');
}
}
@@ -262,14 +263,16 @@ class MailAlerts extends Module
return;
// Getting differents vars
$id_lang = (int)Context::getContext()->language->id;
$context = Context::getContext();
$id_lang = (int)$context->language->id;
$id_shop = (int)$context->shop->id;
$currency = $params['currency'];
$configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME'));
$order = $params['order'];
$customer = $params['customer'];
$configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME', 'PS_MAIL_COLOR'), $id_lang, null, $id_shop);
$delivery = new Address((int)$order->id_address_delivery);
$invoice = new Address((int)$order->id_address_invoice);
$order_date_text = Tools::displayDate($order->date_add);
$order_date_text = Tools::displayDate($order->date_add, (int)$id_lang);
$carrier = new Carrier((int)$order->id_carrier);
$message = $order->getFirstMessage();
@@ -288,7 +291,6 @@ class MailAlerts extends Module
$customization_text = '';
if (isset($customized_datas[$product['product_id']][$product['product_attribute_id']]))
{
foreach ($customized_datas[$product['product_id']][$product['product_attribute_id']][$order->id_address_delivery] as $customization)
{
if (isset($customization['datas'][_CUSTOMIZE_TEXTFIELD_]))
@@ -339,11 +341,11 @@ class MailAlerts extends Module
'{delivery_block_txt}' => MailAlert::getFormatedAddress($delivery, "\n"),
'{invoice_block_txt}' => MailAlert::getFormatedAddress($invoice, "\n"),
'{delivery_block_html}' => MailAlert::getFormatedAddress($delivery, '<br />', array(
'firstname' => '<span style="color:'.Configuration::get('PS_MAIL_COLOR').'; font-weight:bold;">%s</span>',
'lastname' => '<span style="color:'.Configuration::get('PS_MAIL_COLOR').'; font-weight:bold;">%s</span>')),
'firstname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].'; font-weight:bold;">%s</span>',
'lastname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].'; font-weight:bold;">%s</span>')),
'{invoice_block_html}' => MailAlert::getFormatedAddress($invoice, '<br />', array(
'firstname' => '<span style="color:'.Configuration::get('PS_MAIL_COLOR').' font-weight:bold;">%s</span>',
'lastname' => '<span style="color:'.Configuration::get('PS_MAIL_COLOR').'; font-weight:bold;">%s</span>')),
'firstname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].' font-weight:bold;">%s</span>',
'lastname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].'; font-weight:bold;">%s</span>')),
'{delivery_company}' => $delivery->company,
'{delivery_firstname}' => $delivery->firstname,
'{delivery_lastname}' => $delivery->lastname,
@@ -353,9 +355,7 @@ class MailAlerts extends Module
'{delivery_postal_code}' => $delivery->postcode,
'{delivery_country}' => $delivery->country,
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
'{delivery_phone}' => $delivery->phone,
'{delivery_phone_mobile}' => $delivery->phone_mobile,
'{delivery_vat_number}' => $delivery->vat_number,
'{delivery_phone}' => $delivery->phone ? $delivery->phone : $delivery->phone_mobile,
'{delivery_other}' => $delivery->other,
'{invoice_company}' => $invoice->company,
'{invoice_firstname}' => $invoice->firstname,
@@ -366,21 +366,18 @@ class MailAlerts extends Module
'{invoice_postal_code}' => $invoice->postcode,
'{invoice_country}' => $invoice->country,
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
'{invoice_phone}' => $invoice->phone,
'{invoice_phone_mobile}' => $invoice->phone_mobile,
'{invoice_vat_number}' => $invoice->vat_number,
'{invoice_phone}' => $invoice->phone ? $invoice->phone : $invoice->phone_mobile,
'{invoice_other}' => $invoice->other,
'{order_name}' => sprintf('%06d', $order->id),
'{shop_name}' => Configuration::get('PS_SHOP_NAME'),
'{shop_name}' => $configuration['PS_SHOP_NAME'],
'{date}' => $order_date_text,
'{carrier}' => (($carrier->name == '0') ? Configuration::get('PS_SHOP_NAME') : $carrier->name),
'{carrier}' => (($carrier->name == '0') ? $configuration['PS_SHOP_NAME'] : $carrier->name),
'{payment}' => Tools::substr($order->payment, 0, 32),
'{items}' => $items_table,
'{total_paid}' => Tools::displayPrice($order->total_paid, $currency),
'{total_products}' => Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency),
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $currency),
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $currency),
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $currency, false),
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $currency),
'{currency}' => $currency->sign,
'{message}' => $message
@@ -390,19 +387,28 @@ class MailAlerts extends Module
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.txt') &&
file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.html'))
Mail::Send(
$id_lang,
$template,
sprintf(Mail::l('New order - #%06d', $id_lang), $order->id),
$template_vars,
explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails),
null,
$configuration['PS_SHOP_EMAIL'],
$configuration['PS_SHOP_NAME'],
null,
null,
dirname(__FILE__).'/mails/'
);
{
// Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients
$merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails);
foreach ($merchant_mails as $merchant_mail)
{
Mail::Send(
$id_lang,
$template,
sprintf(Mail::l('New order - #%06d', $id_lang), $order->id),
$template_vars,
$merchant_mail,
null,
$configuration['PS_SHOP_EMAIL'],
$configuration['PS_SHOP_NAME'],
null,
null,
dirname(__FILE__).'/mails/',
null,
$id_shop
);
}
}
}
public function hookActionProductOutOfStock($params)
@@ -410,18 +416,20 @@ class MailAlerts extends Module
if (!$this->_customer_qty || !Configuration::get('PS_STOCK_MANAGEMENT') || Product::isAvailableWhenOutOfStock($params['product']->out_of_stock))
return;
$context = Context::getContext();
$id_product = (int)$params['product']->id;
$id_product_attribute = 0;
$id_customer = (int)Context::getContext()->customer->id;
$id_customer = (int)$context->customer->id;
if (!(int)Context::getContext()->customer->isLogged())
if ((int)$context->customer->id <= 0)
$this->context->smarty->assign('email', 1);
else if (MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute))
elseif (MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute, (int)$context->shop->id))
return;
$this->context->smarty->assign(array(
'id_product' => $id_product,
'id_product_attribute' => $id_product_attribute));
'id_product' => $id_product,
'id_product_attribute' => $id_product_attribute
));
return $this->display(__FILE__, 'product.tpl');
}
@@ -431,33 +439,47 @@ class MailAlerts extends Module
$id_product = (int)$params['id_product'];
$id_product_attribute = (int)$params['id_product_attribute'];
$quantity = (int)$params['quantity'];
$id_shop = (int)Context::getContext()->shop->id;
$id_lang = (int)Context::getContext()->language->id;
$product = new Product($id_product, true, $id_lang, $id_shop, Context::getContext());
$ma_last_qties = (int)Configuration::get('MA_LAST_QTIES');
$context = Context::getContext();
$id_shop = (int)$context->shop->id;
$id_lang = (int)$context->language->id;
$product = new Product($id_product, true, $id_lang, $id_shop, $context);
$configuration = Configuration::getMultiple(array('MA_LAST_QTIES', 'PS_STOCK_MANAGEMENT', 'PS_SHOP_EMAIL', 'PS_SHOP_NAME'), $id_lang, null, $id_shop);
$ma_last_qties = (int)$configuration['MA_LAST_QTIES'];
if ($product->active == 1 && (int)$quantity <= $ma_last_qties && !(!$this->_merchant_oos || empty($this->_merchant_mails)) && Configuration::get('PS_STOCK_MANAGEMENT'))
if ($product->active == 1 && (int)$quantity <= $ma_last_qties && !(!$this->_merchant_oos || empty($this->_merchant_mails)) && $configuration['PS_STOCK_MANAGEMENT'])
{
$iso = Language::getIsoById($id_lang);
$product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang);
$template_vars = array(
'{qty}' => $quantity,
'{last_qty}' => $ma_last_qties,
'{product}' => $product_name);
'{qty}' => $quantity,
'{last_qty}' => $ma_last_qties,
'{product}' => $product_name
);
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.txt') &&
file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.html'))
Mail::Send($id_lang,
'productoutofstock',
Mail::l('Product out of stock', $id_lang),
$template_vars,
explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails),
null,
strval(Configuration::get('PS_SHOP_EMAIL')),
strval(Configuration::get('PS_SHOP_NAME')),
null,
null,
dirname(__FILE__).'/mails/');
{
// Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients
$merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails);
foreach ($merchant_mails as $merchant_mail)
{
Mail::Send(
$id_lang,
'productoutofstock',
Mail::l('Product out of stock', $id_lang),
$template_vars,
$merchant_mail,
null,
strval($configuration['PS_SHOP_EMAIL']),
strval($configuration['PS_SHOP_NAME']),
null,
null,
dirname(__FILE__).'/mails/',
false,
$id_shop
);
}
}
}
if ($this->_customer_qty && $quantity > 0)
@@ -541,31 +563,44 @@ class MailAlerts extends Module
$coverage = StockManagerFactory::getManager()->getProductCoverage($id_product, $id_product_attribute, $warning_coverage, $id_warehouse);
// if we need to send a notification
if ($product->active == 1 && $coverage !== -1 && ($coverage < $warning_coverage) && !empty($this->_merchant_mails) &&
if ($product->active == 1 &&
($coverage < $warning_coverage) && !empty($this->_merchant_mails) &&
Configuration::getGlobalValue('MA_MERCHANT_COVERAGE'))
{
$id_lang = (int)Context::getContext()->language->id;
$context = Context::getContext();
$id_lang = (int)$context->language->id;
$id_shop = (int)$context->shop->id;
$iso = Language::getIsoById($id_lang);
$product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang);
$template_vars = array(
'{current_coverage}' => $coverage,
'{warning_coverage}' => $warning_coverage,
'{product}' => pSQL($product_name));
'{current_coverage}' => $coverage,
'{warning_coverage}' => $warning_coverage,
'{product}' => pSQL($product_name)
);
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/productcoverage.txt') &&
file_exists(dirname(__FILE__).'/mails/'.$iso.'/productcoverage.html'))
{
Mail::Send($id_lang,
'productcoverage',
Mail::l('Stock coverage', $id_lang),
$template_vars,
explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails),
null,
strval(Configuration::get('PS_SHOP_EMAIL')),
strval(Configuration::get('PS_SHOP_NAME')),
null,
null,
dirname(__FILE__).'/mails/');
// Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients
$merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails);
foreach ($merchant_mails as $merchant_mail)
{
Mail::Send(
$id_lang,
'productcoverage',
Mail::l('Stock coverage', $id_lang),
$template_vars,
$merchant_mail,
null,
strval(Configuration::get('PS_SHOP_EMAIL')),
strval(Configuration::get('PS_SHOP_NAME')),
null,
null,
dirname(__FILE__).'/mails/',
null,
$id_shop
);
}
}
}
}
@@ -0,0 +1,29 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
function upgrade_module_2_5($object)
{
return Db::getInstance()->execute('
ALTER TABLE '._DB_PREFIX_.'mailalert_customer_oos
ADD '.mailalerts_stripslashes_field('id_lang').' INT( 10 ) UNSIGNED NOT NULL ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (
'.mailalerts_stripslashes_field('id_customer').' ,
'.mailalerts_stripslashes_field('customer_email').' ,
'.mailalerts_stripslashes_field('id_product').' ,
'.mailalerts_stripslashes_field('id_product_attribute').' ,
'.mailalerts_stripslashes_field('id_shop').'
)'
);
}
function mailalerts_stripslashes_field($field)
{
$quotes = array('"\\\'"', '"\'"');
$dquotes = array('\'\\\\"\'', '\'"\'');
$backslashes = array('"\\\\\\\\"', '"\\\\"');
return '`'.bqSQL($field).'` = replace(replace(replace(`'.bqSQL($field).'`, '.$quotes[0].', '.$quotes[1].'), '.$dquotes[0].', '.$dquotes[1].'), '.$backslashes[0].', '.$backslashes[1].')';
}