// Cookies subdomain & bug fix on stocks
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16110 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+20
-5
@@ -59,7 +59,7 @@ class CookieCore
|
|||||||
* @param $name Cookie name before encrypting
|
* @param $name Cookie name before encrypting
|
||||||
* @param $path
|
* @param $path
|
||||||
*/
|
*/
|
||||||
public function __construct($name, $path = '', $expire = null)
|
public function __construct($name, $path = '', $expire = null, $shared_urls = null)
|
||||||
{
|
{
|
||||||
$this->_content = array();
|
$this->_content = array();
|
||||||
$this->_expire = isset($expire) ? (int)($expire) : (time() + 1728000);
|
$this->_expire = isset($expire) ? (int)($expire) : (time() + 1728000);
|
||||||
@@ -71,7 +71,7 @@ class CookieCore
|
|||||||
$this->_path = str_replace('%7E', '~', $this->_path);
|
$this->_path = str_replace('%7E', '~', $this->_path);
|
||||||
$this->_key = _COOKIE_KEY_;
|
$this->_key = _COOKIE_KEY_;
|
||||||
$this->_iv = _COOKIE_IV_;
|
$this->_iv = _COOKIE_IV_;
|
||||||
$this->_domain = $this->getDomain();
|
$this->_domain = $this->getDomain($shared_urls);
|
||||||
if (Configuration::get('PS_CIPHER_ALGORITHM'))
|
if (Configuration::get('PS_CIPHER_ALGORITHM'))
|
||||||
$this->_cipherTool = new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_);
|
$this->_cipherTool = new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_);
|
||||||
else
|
else
|
||||||
@@ -79,7 +79,7 @@ class CookieCore
|
|||||||
$this->update();
|
$this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDomain()
|
protected function getDomain($shared_urls = null)
|
||||||
{
|
{
|
||||||
$r = '!(?:(\w+)://)?(?:(\w+)\:(\w+)@)?([^/:]+)?(?:\:(\d*))?([^#?]+)?(?:\?([^#]+))?(?:#(.+$))?!i';
|
$r = '!(?:(\w+)://)?(?:(\w+)\:(\w+)@)?([^/:]+)?(?:\:(\d*))?([^#?]+)?(?:\?([^#]+))?(?:#(.+$))?!i';
|
||||||
preg_match ($r, Tools::getHttpHost(false, false), $out);
|
preg_match ($r, Tools::getHttpHost(false, false), $out);
|
||||||
@@ -89,8 +89,23 @@ class CookieCore
|
|||||||
return false;
|
return false;
|
||||||
if (!strstr(Tools::getHttpHost(false, false), '.'))
|
if (!strstr(Tools::getHttpHost(false, false), '.'))
|
||||||
return false;
|
return false;
|
||||||
$domain = $out[4];
|
|
||||||
|
$domain = false;
|
||||||
|
if ($shared_urls !== null)
|
||||||
|
{
|
||||||
|
foreach ($shared_urls as $shared_url)
|
||||||
|
{
|
||||||
|
if ($shared_url == $out[4])
|
||||||
|
continue;
|
||||||
|
if (preg_match('/^(?:.*\.)?([^.]*(?:.{2,3})?\..{2,3})$/Ui', $shared_url, $res))
|
||||||
|
{
|
||||||
|
$domain = '.'.$res[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$domain)
|
||||||
|
$domain = $out[4];
|
||||||
return $domain;
|
return $domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -583,6 +583,24 @@ class ShopCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUrlsSharedCart()
|
||||||
|
{
|
||||||
|
if (!$this->getGroup()->share_order)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$query = new DbQuery();
|
||||||
|
$query->select('domain');
|
||||||
|
$query->from('shop_url');
|
||||||
|
$query->where('main = 1');
|
||||||
|
$query->where('active = 1');
|
||||||
|
$query .= $this->addSqlRestriction(Shop::SHARE_ORDER);
|
||||||
|
$domains = array();
|
||||||
|
foreach (Db::getInstance()->executeS($query) as $row)
|
||||||
|
$domains[] = $row['domain'];
|
||||||
|
|
||||||
|
return $domains;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a collection of shops
|
* Get a collection of shops
|
||||||
|
|||||||
@@ -343,15 +343,17 @@ class StockAvailableCore extends ObjectModel
|
|||||||
if ($this->id_product_attribute == 0)
|
if ($this->id_product_attribute == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
$id_shop = (Shop::getContext() != Shop::CONTEXT_GROUP ? $this->id_shop : null);
|
||||||
|
|
||||||
$total_quantity = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
$total_quantity = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||||
SELECT SUM(quantity) as quantity
|
SELECT SUM(quantity) as quantity
|
||||||
FROM '._DB_PREFIX_.'stock_available
|
FROM '._DB_PREFIX_.'stock_available
|
||||||
WHERE id_product = '.(int)$this->id_product.'
|
WHERE id_product = '.(int)$this->id_product.'
|
||||||
AND id_product_attribute <> 0 '.
|
AND id_product_attribute <> 0 '.
|
||||||
StockAvailable::addSqlShopRestriction(null, $this->id_shop)
|
StockAvailable::addSqlShopRestriction(null, $id_shop)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->setQuantity($this->id_product, 0, $total_quantity, $this->id_shop);
|
$this->setQuantity($this->id_product, 0, $total_quantity, $id_shop);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,10 +116,9 @@ if (defined('_PS_ADMIN_DIR_'))
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Context::getContext()->shop->getGroup()->share_order)
|
if (Context::getContext()->shop->getGroup()->share_order)
|
||||||
$cookie = new Cookie('ps-sg'.Context::getContext()->shop->getGroup()->id, '', $cookieLifetime);
|
$cookie = new Cookie('ps-sg'.Context::getContext()->shop->getGroup()->id, '', $cookieLifetime, Context::getContext()->shop->getUrlsSharedCart());
|
||||||
else
|
else
|
||||||
$cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookieLifetime);
|
$cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookieLifetime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::getContext()->cookie = $cookie;
|
Context::getContext()->cookie = $cookie;
|
||||||
|
|||||||
Reference in New Issue
Block a user