[-] BO: Fix #PSCFV-8179 shop domain used in emails sometimes was for the wrong shop

This commit is contained in:
Rémi Gaillard
2013-05-02 18:42:01 +02:00
parent 63fe5b8d4a
commit 4d4eb9df19
6 changed files with 41 additions and 9 deletions
+4 -1
View File
@@ -245,7 +245,7 @@ class MailCore
else
$template_vars['{shop_logo}'] = '';
}
ShopUrl::cacheMainDomainForShop((int)$id_shop);
/* don't attach the logo as */
if (isset($logo))
$template_vars['{shop_logo}'] = $message->attach(new Swift_Message_EmbeddedFile(new Swift_File($logo), null, ImageManager::getMimeTypeByExtension($logo)));
@@ -274,6 +274,9 @@ class MailCore
/* Send mail */
$send = $swift->send($message, $to, new Swift_Address($from, $from_name));
$swift->disconnect();
ShopUrl::resetMainDomainCache();
return $send;
}
catch (Swift_Exception $e) {
+2
View File
@@ -135,6 +135,8 @@ abstract class PaymentModuleCore extends Module
$this->context->customer = new Customer($this->context->cart->id_customer);
$this->context->language = new Language($this->context->cart->id_lang);
$this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop));
ShopUrl::resetMainDomainCache();
$id_currency = $currency_special ? (int)$currency_special : (int)$this->context->cart->id_currency;
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
+8
View File
@@ -85,6 +85,8 @@ class OrderHistoryCore extends ObjectModel
else
return;
ShopUrl::cacheMainDomainForShop($order->id_shop);
$new_os = new OrderState((int)$new_order_state, $order->id_lang);
$old_os = $order->getCurrentOrderState();
$is_validated = $this->isValidated();
@@ -326,6 +328,8 @@ class OrderHistoryCore extends ObjectModel
'newOrderStatus' => $new_os,
'id_order' => (int)$order->id,
));
ShopUrl::resetMainDomainCache();
}
/**
@@ -377,6 +381,8 @@ class OrderHistoryCore extends ObjectModel
WHERE oh.`id_order_history` = '.(int)$this->id.' AND os.`send_email` = 1');
if (isset($result['template']) && Validate::isEmail($result['email']))
{
ShopUrl::cacheMainDomainForShop($order->id_shop);
$topic = $result['osname'];
$data = array(
'{lastname}' => $result['lastname'],
@@ -400,6 +406,8 @@ class OrderHistoryCore extends ObjectModel
if (Validate::isLoadedObject($order))
Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'],
null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop);
ShopUrl::resetMainDomainCache();
}
return true;
+22 -8
View File
@@ -143,25 +143,39 @@ class ShopUrlCore extends ObjectModel
return Db::getInstance()->getValue($sql);
}
public static function getMainShopDomain()
public static function getMainShopDomain($id_shop = null)
{
if (!self::$main_domain)
if (!self::$main_domain || $id_shop !== null)
self::$main_domain = Db::getInstance()->getValue('SELECT domain
FROM '._DB_PREFIX_.'shop_url
WHERE main=1 AND id_shop = '.Context::getContext()->shop->id);
WHERE main=1 AND id_shop = '.($id_shop !== null ? (int)$id_shop : Context::getContext()->shop->id));
return self::$main_domain;
}
public static function getMainShopDomainSSL()
public static function cacheMainDomainForShop($id_shop)
{
if (!self::$main_domain_ssl)
{
if (!Validate::isUnsignedId($id_shop))
return false;
ShopUrl::getMainShopDomain($id_shop);
ShopUrl::getMainShopDomainSSL($id_shop);
}
public static function resetMainDomainCache()
{
self::$main_domain = null;
self::$main_domain_ssl = null;
}
public static function getMainShopDomainSSL($id_shop = null)
{
if (!self::$main_domain_ssl || $id_shop !== null)
$sql = 'SELECT domain_ssl
FROM '._DB_PREFIX_.'shop_url
WHERE main = 1
AND id_shop='.Context::getContext()->shop->id;
AND id_shop = '.($id_shop !== null ? (int)$id_shop : Context::getContext()->shop->id);
self::$main_domain_ssl = Db::getInstance()->getValue($sql);
}
return self::$main_domain_ssl;
}
}
@@ -373,6 +373,9 @@ class AdminCustomerThreadsControllerCore extends AdminController
if (Tools::isSubmit('submitReply'))
{
$ct = new CustomerThread($id_customer_thread);
ShopUrl::cacheMainDomainForShop((int)$ct->id_shop);
$cm = new CustomerMessage();
$cm->id_employee = (int)$this->context->employee->id;
$cm->id_customer_thread = $ct->id;
@@ -268,6 +268,8 @@ class AdminOrdersControllerCore extends AdminController
throw new PrestaShopException('Can\'t load Order object');
}
ShopUrl::cacheMainDomainForShop((int)$order->id_shop);
/* Update shipping number */
if (Tools::isSubmit('submitShippingNumber') && isset($order))
{