// Improve multishop API

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13566 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2012-02-23 15:39:44 +00:00
parent ec8f05c3ca
commit b24dcffc9c
71 changed files with 377 additions and 425 deletions
+1 -1
View File
@@ -503,7 +503,7 @@ if (Tools::isSubmit('saveHook'))
$hooks_list = explode(',', Tools::getValue('hooks_list')); $hooks_list = explode(',', Tools::getValue('hooks_list'));
$id_shop = (int)Tools::getValue('id_shop'); $id_shop = (int)Tools::getValue('id_shop');
if (!$id_shop) if (!$id_shop)
$id_shop = Context::getContext()->shop->getId(true); $id_shop = Context::getContext()->shop->id;
$res = true; $res = true;
$hookableList = array(); $hookableList = array();
+14 -24
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -400,13 +400,12 @@ function generateShopList()
$context = Context::getContext(); $context = Context::getContext();
// Get default value // Get default value
list($shopID, $shopGroupID) = Shop::getContext(); if (Shop::getContext() == Shop::CONTEXT_ALL)
if ($shopID) $value = '';
$value = 's-'.$shopID; else if (Shop::getContext() == Shop::CONTEXT_GROUP)
else if ($shopGroupID) $value = 'g-'.Shop::getContextGroupShopID();
$value = 'g-'.$shopGroupID; else
else $value = 's-'.Shop::getContextShopID();
$value = '';
// Generate HTML // Generate HTML
$url = $_SERVER['REQUEST_URI'].(($_SERVER['QUERY_STRING']) ? '&' : '?').'setShopContext='; $url = $_SERVER['REQUEST_URI'].(($_SERVER['QUERY_STRING']) ? '&' : '?').'setShopContext=';
@@ -419,19 +418,10 @@ function generateShopList()
foreach ($tree as $gID => $group_data) foreach ($tree as $gID => $group_data)
{ {
$disabled = ($group_data['totalShops'] != count($group_data['shops'])) ? 'disabled="disabled"' : ''; $disabled = ($group_data['totalShops'] != count($group_data['shops'])) ? 'disabled="disabled"' : '';
$html .= '<option class="group" value="g-'.$gID.'" '.(($value == 'g-'.$gID) ? 'selected="selected"' : '').' '.$disabled.'>'.translate('Group:').' '.htmlspecialchars($group_data['name']).'</option>';
if ($context->controller->multishop_context & Shop::CONTEXT_GROUP) foreach ($group_data['shops'] as $sID => $shopData)
$html .= '<option class="group" value="g-'.$gID.'" '.(($value == 'g-'.$gID) ? 'selected="selected"' : '').' '.$disabled.'>'.translate('Group:').' '.htmlspecialchars($group_data['name']).'</option>'; if ($shopData['active'])
else $html .= '<option value="s-'.$sID.'" class="shop" '.(($value == 's-'.$sID) ? 'selected="selected"' : '').'>&raquo; '.$shopData['name'].'</option>';
$html .= '<optgroup class="group" label="'.translate('Group:').' '.htmlspecialchars($group_data['name']).'">';
if ($context->controller->multishop_context & Shop::CONTEXT_SHOP)
foreach ($group_data['shops'] as $sID => $shopData)
if ($shopData['active'])
$html .= '<option value="s-'.$sID.'" class="shop" '.(($value == 's-'.$sID || $context->shop->id == $sID) ? 'selected="selected"' : '').'>&raquo; '.$shopData['name'].'</option>';
if (!($context->controller->multishop_context & Shop::CONTEXT_GROUP))
$html .= '</optgroup>';
} }
$html .= '</select>'; $html .= '</select>';
@@ -511,12 +501,12 @@ function runAdminTab($tab, $ajaxMode = false)
<a href="?token='.Tools::getAdminToken($tab.intval(Tab::getIdFromClassName($tab)).(int)Context::getContext()->employee->id).'">'.translate('Back Office').'</a> <a href="?token='.Tools::getAdminToken($tab.intval(Tab::getIdFromClassName($tab)).(int)Context::getContext()->employee->id).'">'.translate('Back Office').'</a>
'.$bread.'</div>'; '.$bread.'</div>';
if (!$ajaxMode && Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL) if (!$ajaxMode && Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL)
{ {
echo '<div class="multishop_info">'; echo '<div class="multishop_info">';
if (Context::shop() == Shop::CONTEXT_GROUP) if (Shop::getContext() == Shop::CONTEXT_GROUP)
printf(translate('You are configuring your store for group shop %s'), '<b>'.Context::getContext()->shop->getGroup()->name.'</b>'); printf(translate('You are configuring your store for group shop %s'), '<b>'.Context::getContext()->shop->getGroup()->name.'</b>');
elseif (Context::shop() == Shop::CONTEXT_SHOP) elseif (Shop::getContext() == Shop::CONTEXT_SHOP)
printf(translate('You are configuring your store for shop %s'), '<b>'.Context::getContext()->shop->name.'</b>'); printf(translate('You are configuring your store for shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
echo '</div>'; echo '</div>';
} }
+3 -3
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -147,9 +147,9 @@ echo '
'; ';
if (Shop::isFeatureActive()) if (Shop::isFeatureActive())
{ {
if (Context::shop() == Shop::CONTEXT_ALL) if (Shop::getContext() == Shop::CONTEXT_ALL)
$youEditFieldFor = translate('A modification of this field will be applied for all shops'); $youEditFieldFor = translate('A modification of this field will be applied for all shops');
else if (Context::shop() == Shop::CONTEXT_GROUP) else if (Shop::getContext() == Shop::CONTEXT_GROUP)
$youEditFieldFor = sprintf(translate('A modification of this field will be applied for all shops of group %s'), '<b>'.Context::getContext()->shop->getGroup()->name.'</b>'); $youEditFieldFor = sprintf(translate('A modification of this field will be applied for all shops of group %s'), '<b>'.Context::getContext()->shop->getGroup()->name.'</b>');
else else
$youEditFieldFor = sprintf(translate('A modification of this field will be applied for the shop %s'), '<b>'.Context::getContext()->shop->name.'</b>'); $youEditFieldFor = sprintf(translate('A modification of this field will be applied for the shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
+1 -1
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
+2 -2
View File
@@ -39,9 +39,9 @@
var helpboxes = {$help_box}; var helpboxes = {$help_box};
var roundMode = {$round_mode}; var roundMode = {$round_mode};
{if isset($shop_context)} {if isset($shop_context)}
{if $shop_context == 'all'} {if $shop_context == Shop::CONTEXT_ALL}
var youEditFieldFor = "{l s='A modification of this field will be applied for all shops' slashes=1 }"; var youEditFieldFor = "{l s='A modification of this field will be applied for all shops' slashes=1 }";
{elseif $shop_context == 'group'} {elseif $shop_context == Shop::CONTEXT_GROUP}
var youEditFieldFor = "{l s='A modification of this field will be applied for all shops of group ' slashes=1 }<b>{$shop_name}</b>"; var youEditFieldFor = "{l s='A modification of this field will be applied for all shops of group ' slashes=1 }<b>{$shop_name}</b>";
{else} {else}
var youEditFieldFor = "{l s='A modification of this field will be applied for the shop ' slashes=1 }<b>{$shop_name}</b>"; var youEditFieldFor = "{l s='A modification of this field will be applied for the shop ' slashes=1 }<b>{$shop_name}</b>";
+9 -9
View File
@@ -995,7 +995,7 @@ abstract class AdminTabCore
{ {
foreach ($fields as $key => $options) foreach ($fields as $key => $options)
{ {
if (isset($options['visibility']) && $options['visibility'] > Context::getContext()->shop->getContextType()) if (isset($options['visibility']) && $options['visibility'] > Shop::getContext())
continue; continue;
if (Shop::isFeatureActive() && isset($_POST['configUseDefault'][$key])) if (Shop::isFeatureActive() && isset($_POST['configUseDefault'][$key]))
@@ -1315,13 +1315,13 @@ abstract class AdminTabCore
$filterKey = $assos[$this->table]['type']; $filterKey = $assos[$this->table]['type'];
$idenfierShop = $this->context->shop->getListOfID(); $idenfierShop = $this->context->shop->getListOfID();
} }
else if (Context::shop() == Shop::CONTEXT_GROUP) else if (Shop::getContext() == Shop::CONTEXT_GROUP)
{ {
$assos = GroupShop::getAssoTables(); $assos = GroupShop::getAssoTables();
if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'group_shop') if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'group_shop')
{ {
$filterKey = $assos[$this->table]['type']; $filterKey = $assos[$this->table]['type'];
$idenfierShop = array($this->context->shop->getGroupID()); $idenfierShop = array(Shop::getContextGroupShopID());
} }
} }
@@ -1333,7 +1333,7 @@ abstract class AdminTabCore
else if (!preg_match('#(\s|,)\s*a\.`?'.pSQL($this->identifier).'`?(\s|,|$)#', $this->_group)) else if (!preg_match('#(\s|,)\s*a\.`?'.pSQL($this->identifier).'`?(\s|,|$)#', $this->_group))
$this->_group .= ', a.'.pSQL($this->identifier); $this->_group .= ', a.'.pSQL($this->identifier);
if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && !preg_match('#`?'.preg_quote(_DB_PREFIX_.$this->table.'_'.$filterKey).'`? *sa#', $this->_join)) if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && !preg_match('#`?'.preg_quote(_DB_PREFIX_.$this->table.'_'.$filterKey).'`? *sa#', $this->_join))
$filterShop = 'JOIN `'._DB_PREFIX_.$this->table.'_'.$filterKey.'` sa ON (sa.'.$this->identifier.' = a.'.$this->identifier.' AND sa.id_'.$filterKey.' IN ('.implode(', ', $idenfierShop).'))'; $filterShop = 'JOIN `'._DB_PREFIX_.$this->table.'_'.$filterKey.'` sa ON (sa.'.$this->identifier.' = a.'.$this->identifier.' AND sa.id_'.$filterKey.' IN ('.implode(', ', $idenfierShop).'))';
} }
/////////////////////// ///////////////////////
@@ -1869,12 +1869,12 @@ abstract class AdminTabCore
$isDisabled = $isInvisible = false; $isDisabled = $isInvisible = false;
if (Shop::isFeatureActive()) if (Shop::isFeatureActive())
{ {
if (isset($field['visibility']) && $field['visibility'] > $this->context->shop->getContextType()) if (isset($field['visibility']) && $field['visibility'] > Shop::getContext())
{ {
$isDisabled = true; $isDisabled = true;
$isInvisible = true; $isInvisible = true;
} }
else if (Context::shop() != Shop::CONTEXT_ALL && !Configuration::isOverridenByCurrentContext($key)) else if (Shop::getContext() != Shop::CONTEXT_ALL && !Configuration::isOverridenByCurrentContext($key))
$isDisabled = true; $isDisabled = true;
} }
@@ -1903,7 +1903,7 @@ abstract class AdminTabCore
$this->$method($key, $field, $value); $this->$method($key, $field, $value);
// Multishop default value // Multishop default value
if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && !$isInvisible) if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && !$isInvisible)
echo '<div class="preference_default_multishop"> echo '<div class="preference_default_multishop">
<label> <label>
<input type="checkbox" name="configUseDefault['.$key.']" value="1" '.(($isDisabled) ? 'checked="checked"' : '').' onclick="checkMultishopDefaultValue(this, \''.$key.'\')" /> '.$this->l('Use default value').' <input type="checkbox" name="configUseDefault['.$key.']" value="1" '.(($isDisabled) ? 'checked="checked"' : '').' onclick="checkMultishopDefaultValue(this, \''.$key.'\')" /> '.$this->l('Use default value').'
@@ -2166,7 +2166,7 @@ abstract class AdminTabCore
public function getFieldValue($obj, $key, $id_lang = NULL, $id_shop = null) public function getFieldValue($obj, $key, $id_lang = NULL, $id_shop = null)
{ {
if (!$id_shop && $obj->isLangMultishop()) if (!$id_shop && $obj->isLangMultishop())
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->id;
if ($id_lang) if ($id_lang)
$defaultValue = ($obj->id && isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : ''; $defaultValue = ($obj->id && isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : '';
@@ -2332,7 +2332,7 @@ abstract class AdminTabCore
protected function displayAssoShop($type = 'shop') protected function displayAssoShop($type = 'shop')
{ {
if (!Shop::isFeatureActive() || (!$this->_object && $this->context->shop->getContextType() != Shop::CONTEXT_ALL)) if (!Shop::isFeatureActive() || (!$this->_object && Shop::getContext() != Shop::CONTEXT_ALL))
return; return;
if ($type != 'shop' && $type != 'group_shop') if ($type != 'shop' && $type != 'group_shop')
+1 -1
View File
@@ -171,7 +171,7 @@ class AttributeCore extends ObjectModel
if (!$shop) if (!$shop)
$shop = Context::getContext()->shop; $shop = Context::getContext()->shop;
$result = StockAvailable::getQuantityAvailableByProduct(null, (int)$id_product_attribute, $shop->getID()); $result = StockAvailable::getQuantityAvailableByProduct(null, (int)$id_product_attribute, $shop->id);
return ($result && $qty <= $result); return ($result && $qty <= $result);
} }
+28 -44
View File
@@ -213,7 +213,7 @@ class CarrierCore extends ObjectModel
* @param integer $id_zone Zone id (for customer delivery address) * @param integer $id_zone Zone id (for customer delivery address)
* @return float Delivery price * @return float Delivery price
*/ */
public function getDeliveryPriceByWeight($total_weight, $id_zone, Shop $shop = null) public function getDeliveryPriceByWeight($total_weight, $id_zone)
{ {
$cache_key = $this->id.'_'.$total_weight.'_'.$id_zone; $cache_key = $this->id.'_'.$total_weight.'_'.$id_zone;
if (!isset(self::$price_by_weight[$cache_key])) if (!isset(self::$price_by_weight[$cache_key]))
@@ -225,7 +225,7 @@ class CarrierCore extends ObjectModel
AND '.(float)$total_weight.' >= w.`delimiter1` AND '.(float)$total_weight.' >= w.`delimiter1`
AND '.(float)$total_weight.' < w.`delimiter2` AND '.(float)$total_weight.' < w.`delimiter2`
AND d.`id_carrier` = '.(int)$this->id.' AND d.`id_carrier` = '.(int)$this->id.'
'.Carrier::sqlDeliveryRangeShop('range_weight', $shop).' '.Carrier::sqlDeliveryRangeShop('range_weight').'
ORDER BY w.`delimiter1` ASC'; ORDER BY w.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (!isset($result['price'])) if (!isset($result['price']))
@@ -236,7 +236,7 @@ class CarrierCore extends ObjectModel
return self::$price_by_weight[$cache_key]; return self::$price_by_weight[$cache_key];
} }
public static function checkDeliveryPriceByWeight($id_carrier, $total_weight, $id_zone, Shop $shop = null) public static function checkDeliveryPriceByWeight($id_carrier, $total_weight, $id_zone)
{ {
$cache_key = $id_carrier.'_'.$total_weight.'_'.$id_zone; $cache_key = $id_carrier.'_'.$total_weight.'_'.$id_zone;
if (!isset(self::$price_by_weight2[$cache_key])) if (!isset(self::$price_by_weight2[$cache_key]))
@@ -248,7 +248,7 @@ class CarrierCore extends ObjectModel
AND '.(float)$total_weight.' >= w.`delimiter1` AND '.(float)$total_weight.' >= w.`delimiter1`
AND '.(float)$total_weight.' < w.`delimiter2` AND '.(float)$total_weight.' < w.`delimiter2`
AND d.`id_carrier` = '.(int)$id_carrier.' AND d.`id_carrier` = '.(int)$id_carrier.'
'.Carrier::sqlDeliveryRangeShop('range_weight', $shop).' '.Carrier::sqlDeliveryRangeShop('range_weight').'
ORDER BY w.`delimiter1` ASC'; ORDER BY w.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
self::$price_by_weight2[$cache_key] = (isset($result['price'])); self::$price_by_weight2[$cache_key] = (isset($result['price']));
@@ -256,14 +256,14 @@ class CarrierCore extends ObjectModel
return self::$price_by_weight2[$cache_key]; return self::$price_by_weight2[$cache_key];
} }
public function getMaxDeliveryPriceByWeight($id_zone, Shop $shop = null) public function getMaxDeliveryPriceByWeight($id_zone)
{ {
$sql = 'SELECT d.`price` $sql = 'SELECT d.`price`
FROM `'._DB_PREFIX_.'delivery` d FROM `'._DB_PREFIX_.'delivery` d
INNER JOIN `'._DB_PREFIX_.'range_weight` w ON d.`id_range_weight` = w.`id_range_weight` INNER JOIN `'._DB_PREFIX_.'range_weight` w ON d.`id_range_weight` = w.`id_range_weight`
WHERE d.`id_zone` = '.(int)$id_zone.' WHERE d.`id_zone` = '.(int)$id_zone.'
AND d.`id_carrier` = '.(int)$this->id.' AND d.`id_carrier` = '.(int)$this->id.'
'.Carrier::sqlDeliveryRangeShop('range_weight', $shop).' '.Carrier::sqlDeliveryRangeShop('range_weight').'
ORDER BY w.`delimiter2` DESC LIMIT 1'; ORDER BY w.`delimiter2` DESC LIMIT 1';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!isset($result[0]['price'])) if (!isset($result[0]['price']))
@@ -278,7 +278,7 @@ class CarrierCore extends ObjectModel
* @param integer $id_zone Zone id (for customer delivery address) * @param integer $id_zone Zone id (for customer delivery address)
* @return float Delivery price * @return float Delivery price
*/ */
public function getDeliveryPriceByPrice($order_total, $id_zone, $id_currency = null, Shop $shop = null) public function getDeliveryPriceByPrice($order_total, $id_zone, $id_currency = null)
{ {
$cache_key = $this->id.'_'.$order_total.'_'.$id_zone.'_'.$id_currency; $cache_key = $this->id.'_'.$order_total.'_'.$id_zone.'_'.$id_currency;
if (!isset(self::$price_by_price[$cache_key])) if (!isset(self::$price_by_price[$cache_key]))
@@ -293,7 +293,7 @@ class CarrierCore extends ObjectModel
AND '.(float)$order_total.' >= r.`delimiter1` AND '.(float)$order_total.' >= r.`delimiter1`
AND '.(float)$order_total.' < r.`delimiter2` AND '.(float)$order_total.' < r.`delimiter2`
AND d.`id_carrier` = '.(int)$this->id.' AND d.`id_carrier` = '.(int)$this->id.'
'.Carrier::sqlDeliveryRangeShop('range_price', $shop).' '.Carrier::sqlDeliveryRangeShop('range_price').'
ORDER BY r.`delimiter1` ASC'; ORDER BY r.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (!isset($result['price'])) if (!isset($result['price']))
@@ -313,7 +313,7 @@ class CarrierCore extends ObjectModel
* @param integer $id_currency * @param integer $id_currency
* @return float Delivery price * @return float Delivery price
*/ */
public static function checkDeliveryPriceByPrice($id_carrier, $order_total, $id_zone, $id_currency = null, Shop $shop = null) public static function checkDeliveryPriceByPrice($id_carrier, $order_total, $id_zone, $id_currency = null)
{ {
$cache_key = $id_carrier.'_'.$order_total.'_'.$id_zone.'_'.$id_currency; $cache_key = $id_carrier.'_'.$order_total.'_'.$id_zone.'_'.$id_currency;
if (!isset(self::$price_by_price2[$cache_key])) if (!isset(self::$price_by_price2[$cache_key]))
@@ -328,7 +328,7 @@ class CarrierCore extends ObjectModel
AND '.(float)$order_total.' >= r.`delimiter1` AND '.(float)$order_total.' >= r.`delimiter1`
AND '.(float)$order_total.' < r.`delimiter2` AND '.(float)$order_total.' < r.`delimiter2`
AND d.`id_carrier` = '.(int)$id_carrier.' AND d.`id_carrier` = '.(int)$id_carrier.'
'.Carrier::sqlDeliveryRangeShop('range_price', $shop).' '.Carrier::sqlDeliveryRangeShop('range_price').'
ORDER BY r.`delimiter1` ASC'; ORDER BY r.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
self::$price_by_price2[$cache_key] = (isset($result['price'])); self::$price_by_price2[$cache_key] = (isset($result['price']));
@@ -336,14 +336,14 @@ class CarrierCore extends ObjectModel
return self::$price_by_price2[$cache_key]; return self::$price_by_price2[$cache_key];
} }
public function getMaxDeliveryPriceByPrice($id_zone, Shop $shop = null) public function getMaxDeliveryPriceByPrice($id_zone)
{ {
$sql = 'SELECT d.`price` $sql = 'SELECT d.`price`
FROM `'._DB_PREFIX_.'delivery` d FROM `'._DB_PREFIX_.'delivery` d
INNER JOIN `'._DB_PREFIX_.'range_price` r ON d.`id_range_price` = r.`id_range_price` INNER JOIN `'._DB_PREFIX_.'range_price` r ON d.`id_range_price` = r.`id_range_price`
WHERE d.`id_zone` = '.(int)$id_zone.' WHERE d.`id_zone` = '.(int)$id_zone.'
AND d.`id_carrier` = '.(int)$this->id.' AND d.`id_carrier` = '.(int)$this->id.'
'.Carrier::sqlDeliveryRangeShop('range_price', $shop).' '.Carrier::sqlDeliveryRangeShop('range_price').'
ORDER BY r.`delimiter2` DESC LIMIT 1'; ORDER BY r.`delimiter2` DESC LIMIT 1';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!isset($result[0]['price'])) if (!isset($result[0]['price']))
@@ -357,7 +357,7 @@ class CarrierCore extends ObjectModel
* @param string $rangeTable Table name (price or weight) * @param string $rangeTable Table name (price or weight)
* @return array Delivery prices * @return array Delivery prices
*/ */
public static function getDeliveryPriceByRanges($range_table, $id_carrier, Shop $shop = null) public static function getDeliveryPriceByRanges($range_table, $id_carrier)
{ {
$range_table = pSQL($range_table); $range_table = pSQL($range_table);
$sql = 'SELECT d.id_'.$range_table.', d.id_carrier, d.id_zone, d.price $sql = 'SELECT d.id_'.$range_table.', d.id_carrier, d.id_zone, d.price
@@ -366,7 +366,7 @@ class CarrierCore extends ObjectModel
WHERE d.id_carrier = '.(int)$id_carrier.' WHERE d.id_carrier = '.(int)$id_carrier.'
AND d.id_'.$range_table.' IS NOT NULL AND d.id_'.$range_table.' IS NOT NULL
AND d.id_'.$range_table.' != 0 AND d.id_'.$range_table.' != 0
'.Carrier::sqlDeliveryRangeShop($range_table, $shop).' '.Carrier::sqlDeliveryRangeShop($range_table).'
ORDER BY r.delimiter1'; ORDER BY r.delimiter1';
return Db::getInstance()->executeS($sql); return Db::getInstance()->executeS($sql);
} }
@@ -695,20 +695,16 @@ class CarrierCore extends ObjectModel
* @param string $rangeTable Table name to clean (weight or price according to shipping method) * @param string $rangeTable Table name to clean (weight or price according to shipping method)
* @return boolean Deletion result * @return boolean Deletion result
*/ */
public function deleteDeliveryPrice($range_table, Shop $shop = null) public function deleteDeliveryPrice($range_table)
{ {
$where = '`id_carrier` = '.(int)$this->id.' AND (`id_'.$range_table.'` IS NOT NULL OR `id_'.$range_table.'` = 0) '; $where = '`id_carrier` = '.(int)$this->id.' AND (`id_'.$range_table.'` IS NOT NULL OR `id_'.$range_table.'` = 0) ';
if (!$shop) if (Shop::getContext() == Shop::CONTEXT_ALL)
$shop = Context::getContext()->shop;
$shop_id = $shop->getID();
$shop_group_id = $shop->getGroupID();
if (!$shop_id && !$shop_group_id)
$where .= 'AND id_shop IS NULL AND id_group_shop IS NULL'; $where .= 'AND id_shop IS NULL AND id_group_shop IS NULL';
else if (!$shop_id) else if (Shop::getContext() == Shop::CONTEXT_GROUP)
$where .= 'AND id_shop IS NULL AND id_group_shop = '.$shop_group_id; $where .= 'AND id_shop IS NULL AND id_group_shop = '.(int)Shop::getContextGroupShopID();
else else
$where .= 'AND id_shop = '.$shop_id; $where .= 'AND id_shop = '.(int)Shop::getContextShopID();
return Db::getInstance()->delete('delivery', $where); return Db::getInstance()->delete('delivery', $where);
} }
@@ -717,10 +713,9 @@ class CarrierCore extends ObjectModel
* Add new delivery prices * Add new delivery prices
* *
* @param array $priceList Prices list in multiple arrays (changed to array since 1.5.0) * @param array $priceList Prices list in multiple arrays (changed to array since 1.5.0)
* @param Shop $shop Optionnal
* @return boolean Insertion result * @return boolean Insertion result
*/ */
public function addDeliveryPrice($price_list, Shop $shop = null) public function addDeliveryPrice($price_list)
{ {
if (!$price_list) if (!$price_list)
return false; return false;
@@ -731,18 +726,13 @@ class CarrierCore extends ObjectModel
if (!in_array('id_group_shop', $keys)) if (!in_array('id_group_shop', $keys))
$keys[] = 'id_group_shop'; $keys[] = 'id_group_shop';
if (!$shop)
$shop = Context::getContext()->shop;
$shop_id = $shop->getID();
$shop_group_id = $shop->getGroupID();
$sql = 'INSERT INTO `'._DB_PREFIX_.'delivery` ('.implode(', ', $keys).') VALUES '; $sql = 'INSERT INTO `'._DB_PREFIX_.'delivery` ('.implode(', ', $keys).') VALUES ';
foreach ($price_list as $values) foreach ($price_list as $values)
{ {
if (!isset($values['id_shop'])) if (!isset($values['id_shop']))
$values['id_shop'] = ($shop_id) ? $shop_id : null; $values['id_shop'] = (Shop::getContext() == Shop::CONTEXT_SHOP) ? Shop::getContextShopID() : null;
if (!isset($values['id_group_shop'])) if (!isset($values['id_group_shop']))
$values['id_group_shop'] = ($shop_group_id) ? $shop_group_id : null; $values['id_group_shop'] = (Shop::getContext() != Shop::CONTEXT_ALL) ? Shop::getContextGroupShopID() : null;
$sql .= '('; $sql .= '(';
foreach ($values as $v) foreach ($values as $v)
@@ -951,22 +941,16 @@ class CarrierCore extends ObjectModel
* *
* @since 1.5.0 * @since 1.5.0
* @param string $rangeTable * @param string $rangeTable
* @param Shop $shop
* @return string * @return string
*/ */
public static function sqlDeliveryRangeShop($range_table, Shop $shop = null, $alias = 'd') public static function sqlDeliveryRangeShop($range_table, $alias = 'd')
{ {
if (!$shop) if (Shop::getContext() == Shop::CONTEXT_ALL)
$shop = Context::getContext()->shop;
$shop_id = $shop->getID();
$shop_group_id = $shop->getGroupID();
$where = '';
if (!$shop_id && !$shop_group_id)
$where = 'AND d2.id_shop IS NULL AND d2.id_group_shop IS NULL'; $where = 'AND d2.id_shop IS NULL AND d2.id_group_shop IS NULL';
else if (!$shop_id) else if (Shop::getContext() == Shop::CONTEXT_GROUP)
$where = 'AND ((d2.id_group_shop IS NULL OR d2.id_group_shop = '.$shop_group_id.') AND d2.id_shop IS NULL)'; $where = 'AND ((d2.id_group_shop IS NULL OR d2.id_group_shop = '.Shop::getContextGroupShopID().') AND d2.id_shop IS NULL)';
else else
$where = 'AND (d2.id_shop = '.$shop_id.' OR (d2.id_group_shop = '.$shop_group_id.' $where = 'AND (d2.id_shop = '.Shop::getContextShopID().' OR (d2.id_group_shop = '.Shop::getContextGroupShopID().'
AND d2.id_shop IS NULL) OR (d2.id_group_shop IS NULL AND d2.id_shop IS NULL))'; AND d2.id_shop IS NULL) OR (d2.id_group_shop IS NULL AND d2.id_shop IS NULL))';
$sql = 'AND '.$alias.'.id_delivery = ( $sql = 'AND '.$alias.'.id_delivery = (
@@ -1075,7 +1059,7 @@ class CarrierCore extends ObjectModel
public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null) public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null)
{ {
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
if (is_null($cart)) if (is_null($cart))
$cart = Context::getContext()->cart; $cart = Context::getContext()->cart;
+2 -2
View File
@@ -758,7 +758,7 @@ class CartCore extends ObjectModel
$quantity = (int)$quantity; $quantity = (int)$quantity;
$id_product = (int)$id_product; $id_product = (int)$id_product;
$id_product_attribute = (int)$id_product_attribute; $id_product_attribute = (int)$id_product_attribute;
$product = new Product($id_product, false, Configuration::get('PS_LANG_DEFAULT'), $shop->getID()); $product = new Product($id_product, false, Configuration::get('PS_LANG_DEFAULT'), $shop->id);
/* If we have a product combination, the minimal quantity is set with the one of this combination */ /* If we have a product combination, the minimal quantity is set with the one of this combination */
if (!empty($id_product_attribute)) if (!empty($id_product_attribute))
@@ -857,7 +857,7 @@ class CartCore extends ObjectModel
'id_product_attribute' => (int)$id_product_attribute, 'id_product_attribute' => (int)$id_product_attribute,
'id_cart' => (int)$this->id, 'id_cart' => (int)$this->id,
'id_address_delivery' => (int)$id_address_delivery, 'id_address_delivery' => (int)$id_address_delivery,
'id_shop' => $shop->getID(true), 'id_shop' => $shop->id,
'quantity' => (int)$quantity, 'quantity' => (int)$quantity,
'date_add' => date('Y-m-d H:i:s') 'date_add' => date('Y-m-d H:i:s')
)); ));
+3 -3
View File
@@ -739,7 +739,7 @@ class CategoryCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').') LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.') LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
WHERE `id_lang` = '.(int)$id_lang.' WHERE `id_lang` = '.(int)$id_lang.'
AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true).' AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
AND c.`id_parent` = '.(int)$id_parent.' AND c.`id_parent` = '.(int)$id_parent.'
'.($active ? 'AND `active` = 1' : '').' '.($active ? 'AND `active` = 1' : '').'
ORDER BY cs.`position` ASC'); ORDER BY cs.`position` ASC');
@@ -798,7 +798,7 @@ class CategoryCore extends ObjectModel
WHERE `id_lang` = '.(int)$id_lang; WHERE `id_lang` = '.(int)$id_lang;
if (Context::getContext()->shop() == Shop::CONTEXT_SHOP && $use_shop_context) if (Context::getContext()->shop() == Shop::CONTEXT_SHOP && $use_shop_context)
$sql .= ' $sql .= '
AND cs.`id_shop` = '.(int)$shop->getID(true); AND cs.`id_shop` = '.(int)$shop->id;
$sql .= ' $sql .= '
AND c.`id_parent` = '.(int)$id_parent.' AND c.`id_parent` = '.(int)$id_parent.'
ORDER BY `position` ASC'; ORDER BY `position` ASC';
@@ -983,7 +983,7 @@ class CategoryCore extends ObjectModel
WHERE c.`id_category` = '.(int)$id_current; WHERE c.`id_category` = '.(int)$id_current;
if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP) if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP)
$sql .= ' $sql .= '
AND cs.`id_shop` = '.(int)$context->shop->getID(true); AND cs.`id_shop` = '.(int)$context->shop->id;
$root_category = Category::getRootCategory(); $root_category = Category::getRootCategory();
if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP && if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP &&
(!Tools::isSubmit('id_category') || (!Tools::isSubmit('id_category') ||
+53 -17
View File
@@ -377,11 +377,23 @@ class ConfigurationCore extends ObjectModel
*/ */
public static function deleteFromContext($key) public static function deleteFromContext($key)
{ {
list($shopID, $shopGroupID) = Shop::getContext(); if (Shop::getContext() == Shop::CONTEXT_ALL)
if (!$shopID && !$shopGroupID) $id_shop = $id_group_shop = null;
else if (Shop::getContext() == Shop::CONTEXT_GROUP)
{
$id_group_shop = Shop::getContextGroupShopID();
$id_shop = null;
}
else
{
$id_group_shop = Shop::getContextGroupShopID();
$id_shop = Shop::getContextShopID();
}
if (!$id_shop && !$id_group_shop)
return; return;
$id = Configuration::getIdByName($key, $shopGroupID, $shopID); $id = Configuration::getIdByName($key, $id_group_shop, $id_shop);
$sql = 'DELETE FROM '._DB_PREFIX_.'configuration $sql = 'DELETE FROM '._DB_PREFIX_.'configuration
WHERE id_configuration = '.$id; WHERE id_configuration = '.$id;
Db::getInstance()->execute($sql); Db::getInstance()->execute($sql);
@@ -395,17 +407,29 @@ class ConfigurationCore extends ObjectModel
* Check if configuration var is defined in given context * Check if configuration var is defined in given context
* *
* @param string $key * @param string $key
* @param int $langID * @param int $id_lang
* @param int $context * @param int $context
*/ */
public static function hasContext($key, $langID, $context) public static function hasContext($key, $id_lang, $context)
{ {
list($shopID, $shopGroupID) = Shop::getContext(); if (Shop::getContext() == Shop::CONTEXT_ALL)
if ($context == Shop::CONTEXT_SHOP && Configuration::hasKey($key, $langID, null, $shopID)) $id_shop = $id_group_shop = null;
else if (Shop::getContext() == Shop::CONTEXT_GROUP)
{
$id_group_shop = Shop::getContextGroupShopID();
$id_shop = null;
}
else
{
$id_group_shop = Shop::getContextGroupShopID();
$id_shop = Shop::getContextShopID();
}
if ($context == Shop::CONTEXT_SHOP && Configuration::hasKey($key, $id_lang, null, $id_shop))
return true; return true;
else if ($context == Shop::CONTEXT_GROUP && Configuration::hasKey($key, $langID, $shopGroupID)) else if ($context == Shop::CONTEXT_GROUP && Configuration::hasKey($key, $id_lang, $id_group_shop))
return true; return true;
else if ($context == Shop::CONTEXT_ALL && Configuration::hasKey($key, $langID)) else if ($context == Shop::CONTEXT_ALL && Configuration::hasKey($key, $id_lang))
return true; return true;
return false; return false;
} }
@@ -416,17 +440,17 @@ class ConfigurationCore extends ObjectModel
{ {
$testContext = false; $testContext = false;
foreach (Language::getLanguages(false) as $lang) foreach (Language::getLanguages(false) as $lang)
if ((Context::shop() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_SHOP)) if ((Shop::getContext() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_SHOP))
|| (Context::shop() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_GROUP))) || (Shop::getContext() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_GROUP)))
$testContext = true; $testContext = true;
} }
else else
{ {
$testContext = ((Context::shop() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, null, Shop::CONTEXT_SHOP)) $testContext = ((Shop::getContext() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, null, Shop::CONTEXT_SHOP))
|| (Context::shop() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, null, Shop::CONTEXT_GROUP))) ? true : false; || (Shop::getContext() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, null, Shop::CONTEXT_GROUP))) ? true : false;
} }
return (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && $testContext); return (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && $testContext);
} }
/** /**
@@ -451,11 +475,23 @@ class ConfigurationCore extends ObjectModel
if (!Shop::isFeatureActive()) if (!Shop::isFeatureActive())
return; return;
list($shopID, $shopGroupID) = Shop::getContext(); if (Shop::getContext() == Shop::CONTEXT_ALL)
$shop_id = $group_shop_id = null;
else if (Shop::getContext() == Shop::CONTEXT_GROUP)
{
$group_shop_id = Shop::getContextGroupShopID();
$shop_id = null;
}
else
{
$group_shop_id = Shop::getContextGroupShopID();
$shop_id = Shop::getContextShopID();
}
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = $shopID; $id_shop = $shop_id;
if (is_null($id_group_shop)) if (is_null($id_group_shop))
$id_group_shop = $shopGroupID; $id_group_shop = $group_shop_id;
$id_shop = (int)$id_shop; $id_shop = (int)$id_shop;
$id_group_shop = (int)$id_group_shop; $id_group_shop = (int)$id_group_shop;
+4 -4
View File
@@ -72,9 +72,9 @@ class ConnectionCore extends ObjectModel
public function getFields() public function getFields()
{ {
if (!$this->id_shop) if (!$this->id_shop)
$this->id_shop = Context::getContext()->shop->getId(true); $this->id_shop = Context::getContext()->shop->id;
if (!$this->id_group_shop) if (!$this->id_group_shop)
$this->id_group_shop = Context::getContext()->shop->getGroupID(); $this->id_group_shop = Context::getContext()->shop->id_group_shop;
$fields = parent::getFields(); $fields = parent::getFields();
return $fields; return $fields;
@@ -147,8 +147,8 @@ class ConnectionCore extends ObjectModel
$connection->id_guest = (int)$cookie->id_guest; $connection->id_guest = (int)$cookie->id_guest;
$connection->id_page = Page::getCurrentId(); $connection->id_page = Page::getCurrentId();
$connection->ip_address = Tools::getRemoteAddr() ? ip2long(Tools::getRemoteAddr()) : ''; $connection->ip_address = Tools::getRemoteAddr() ? ip2long(Tools::getRemoteAddr()) : '';
$connection->id_shop = Context::getContext()->shop->getID(); $connection->id_shop = Context::getContext()->shop->id;
$connection->id_group_shop = Context::getContext()->shop->getGroupID(); $connection->id_group_shop = Context::getContext()->shop->id_group_shop;
$connection->date_add = $cookie->date_add; $connection->date_add = $cookie->date_add;
if (Validate::isAbsoluteUrl($referer)) if (Validate::isAbsoluteUrl($referer))
$connection->http_referer = $referer; $connection->http_referer = $referer;
-10
View File
@@ -116,14 +116,4 @@ class ContextCore
{ {
return clone($this); return clone($this);
} }
/**
* @return int Shop context type (Shop::CONTEXT_ALL, etc.)
*/
public static function shop()
{
if (!self::$instance->shop->getContextType())
return Shop::CONTEXT_ALL;
return self::$instance->shop->getContextType();
}
} }
+3 -3
View File
@@ -216,7 +216,7 @@ class CurrencyCore extends ObjectModel
public static function getPaymentCurrenciesSpecial($id_module, $id_shop = null) public static function getPaymentCurrenciesSpecial($id_module, $id_shop = null)
{ {
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->id;
$sql = 'SELECT * $sql = 'SELECT *
FROM '._DB_PREFIX_.'module_currency FROM '._DB_PREFIX_.'module_currency
@@ -228,7 +228,7 @@ class CurrencyCore extends ObjectModel
public static function getPaymentCurrencies($id_module, $id_shop = null) public static function getPaymentCurrencies($id_module, $id_shop = null)
{ {
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->id;
$sql = 'SELECT c.* $sql = 'SELECT c.*
FROM `'._DB_PREFIX_.'module_currency` mc FROM `'._DB_PREFIX_.'module_currency` mc
@@ -244,7 +244,7 @@ class CurrencyCore extends ObjectModel
public static function checkPaymentCurrencies($id_module, $id_shop = null) public static function checkPaymentCurrencies($id_module, $id_shop = null)
{ {
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
$sql = 'SELECT * $sql = 'SELECT *
FROM `'._DB_PREFIX_.'module_currency` FROM `'._DB_PREFIX_.'module_currency`
+2 -2
View File
@@ -193,8 +193,8 @@ class CustomerCore extends ObjectModel
public function add($autodate = true, $null_values = true) public function add($autodate = true, $null_values = true)
{ {
$this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->getID(); $this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->id;
$this->id_group_shop = ($this->id_group_shop) ? $this->id_group_shop : Context::getContext()->shop->getGroupID(); $this->id_group_shop = ($this->id_group_shop) ? $this->id_group_shop : Context::getContext()->shop->id_group_shop;
$this->birthday = (empty($this->years) ? $this->birthday : (int)$this->years.'-'.(int)$this->months.'-'.(int)$this->days); $this->birthday = (empty($this->years) ? $this->birthday : (int)$this->years.'-'.(int)$this->months.'-'.(int)$this->days);
$this->secure_key = md5(uniqid(rand(), true)); $this->secure_key = md5(uniqid(rand(), true));
$this->last_passwd_gen = date('Y-m-d H:i:s', strtotime('-'.Configuration::get('PS_PASSWD_TIME_FRONT').'minutes')); $this->last_passwd_gen = date('Y-m-d H:i:s', strtotime('-'.Configuration::get('PS_PASSWD_TIME_FRONT').'minutes'));
+1 -1
View File
@@ -89,7 +89,7 @@ class CustomerThreadCore extends ObjectModel
SELECT cm.id_customer_thread SELECT cm.id_customer_thread
FROM '._DB_PREFIX_.'customer_thread cm FROM '._DB_PREFIX_.'customer_thread cm
WHERE cm.email = \''.pSQL($email).'\' WHERE cm.email = \''.pSQL($email).'\'
AND cm.id_shop = '.(int)Context::getContext()->shop->getId(true).' AND cm.id_shop = '.(int)Context::getContext()->shop->id.'
AND cm.id_order = '.(int)$id_order AND cm.id_order = '.(int)$id_order
); );
} }
+7 -7
View File
@@ -254,10 +254,10 @@ class EmployeeCore extends ObjectModel
{ {
$context = Context::getContext(); $context = Context::getContext();
switch ($type = $context->shop->getContextType()) switch (Shop::getContext())
{ {
case 1: case Shop::CONTEXT_SHOP:
if ($context->shop->checkIfShopExist($context->shop->id)) if ($context->shop->checkIfShopExist(Shop::getContextShopID()))
{ {
if (!in_array($context->shop->id, Employee::getEmployeeShopById($id_employee))) if (!in_array($context->shop->id, Employee::getEmployeeShopById($id_employee)))
return false; return false;
@@ -266,10 +266,10 @@ class EmployeeCore extends ObjectModel
return false; return false;
break; break;
case 2: case Shop::CONTEXT_GROUP:
if ($context->shop->checkIfGroupShopExist($context->shop->getGroupID())) if ($context->shop->checkIfGroupShopExist(Shop::getContextGroupShopID()))
{ {
$shops = $context->shop->getIdShopsByIdGroupShop($context->shop->getGroupID()); $shops = $context->shop->getIdShopsByIdGroupShop(Shop::getContextGroupShopID());
foreach ($shops as $shop) foreach ($shops as $shop)
if (!in_array($shop, Employee::getEmployeeShopById($id_employee))) if (!in_array($shop, Employee::getEmployeeShopById($id_employee)))
return false; return false;
@@ -278,7 +278,7 @@ class EmployeeCore extends ObjectModel
return false; return false;
break; break;
case 3: case Shop::CONTEXT_ALL:
if ($context->employee->id_profile == _PS_ADMIN_PROFILE_ || if ($context->employee->id_profile == _PS_ADMIN_PROFILE_ ||
$context->shop->getTotalShopsWhoExists() == Employee::getTotalEmployeeShopById($id_employee)) $context->shop->getTotalShopsWhoExists() == Employee::getTotalEmployeeShopById($id_employee))
return true; return true;
+2 -2
View File
@@ -161,10 +161,10 @@ class MetaCore extends ObjectModel
SELECT id_meta SELECT id_meta
FROM `'._DB_PREFIX_.'meta_lang` FROM `'._DB_PREFIX_.'meta_lang`
WHERE url_rewrite = \''.pSQL($url_rewrite).'\' AND id_lang = '.(int)$id_lang.' WHERE url_rewrite = \''.pSQL($url_rewrite).'\' AND id_lang = '.(int)$id_lang.'
AND id_shop = '.Context::getContext()->shop->getID(true).' AND id_shop = '.Context::getContext()->shop->id.'
) )
AND id_lang = '.(int)$new_id_lang.' AND id_lang = '.(int)$new_id_lang.'
AND id_shop = '.Context::getContext()->shop->getID(true)); AND id_shop = '.Context::getContext()->shop->id);
} }
} }
+3 -3
View File
@@ -1249,8 +1249,8 @@ abstract class ModuleCore
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook` LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` = \''.pSQL($hookPayment).'\' WHERE h.`name` = \''.pSQL($hookPayment).'\'
AND mc.id_country = '.(int)$billing->id_country.' AND mc.id_country = '.(int)$billing->id_country.'
AND mc.id_shop = '.(int)$context->shop->getID(true).' AND mc.id_shop = '.(int)$context->shop->id.'
AND mg.id_shop = '.(int)$context->shop->getID(true).' AND mg.id_shop = '.(int)$context->shop->id.'
AND (SELECT COUNT(*) FROM '._DB_PREFIX_.'module_shop ms WHERE ms.id_module = m.id_module AND ms.id_shop IN('.implode(', ', $list).')) = '.count($list).' AND (SELECT COUNT(*) FROM '._DB_PREFIX_.'module_shop ms WHERE ms.id_module = m.id_module AND ms.id_shop IN('.implode(', ', $list).')) = '.count($list).'
AND hm.id_shop IN('.implode(', ', $list).') AND hm.id_shop IN('.implode(', ', $list).')
AND (mg.`id_group` IN('.implode(', ', $groups).')) AND (mg.`id_group` IN('.implode(', ', $groups).'))
@@ -1690,7 +1690,7 @@ abstract class ModuleCore
FROM `'._DB_PREFIX_.'hook_module` FROM `'._DB_PREFIX_.'hook_module`
WHERE `id_hook` = '.(int)($id_hook).' WHERE `id_hook` = '.(int)($id_hook).'
AND `id_module` = '.(int)($this->id).' AND `id_module` = '.(int)($this->id).'
AND `id_shop` = '.(int)Context::getContext()->shop->getId(true)); AND `id_shop` = '.(int)Context::getContext()->shop->id);
return $result['position']; return $result['position'];
} }
+5 -5
View File
@@ -162,7 +162,7 @@ abstract class ObjectModelCore
} }
if ($this->isLangMultishop() && !$this->id_shop) if ($this->isLangMultishop() && !$this->id_shop)
$this->id_shop = Context::getContext()->shop->getID(true); $this->id_shop = Context::getContext()->shop->id;
if (!Validate::isTableOrIdentifier($this->def['primary']) || !Validate::isTableOrIdentifier($this->def['table'])) if (!Validate::isTableOrIdentifier($this->def['primary']) || !Validate::isTableOrIdentifier($this->def['table']))
throw new PrestaShopException('Identifier or table format not valid for class '.get_class($this)); throw new PrestaShopException('Identifier or table format not valid for class '.get_class($this));
@@ -423,11 +423,11 @@ abstract class ObjectModelCore
if (!Shop::isFeatureActive()) if (!Shop::isFeatureActive())
{ {
if (isset($assos[$this->def['table']]) && $assos[$this->def['table']]['type'] == 'shop') if (isset($assos[$this->def['table']]) && $assos[$this->def['table']]['type'] == 'shop')
$result &= $this->associateTo(Context::getContext()->shop->getID(true), 'shop'); $result &= $this->associateTo(Context::getContext()->shop->id, 'shop');
$assos = GroupShop::getAssoTables(); $assos = GroupShop::getAssoTables();
if (isset($assos[$this->def['table']]) && $assos[$this->def['table']]['type'] == 'group_shop') if (isset($assos[$this->def['table']]) && $assos[$this->def['table']]['type'] == 'group_shop')
$result &= $this->associateTo(Context::getContext()->shop->getGroupID(), 'group_shop'); $result &= $this->associateTo(Context::getContext()->shop->id_group_shop, 'group_shop');
} }
// @hook actionObject*AddAfter // @hook actionObject*AddAfter
@@ -954,7 +954,7 @@ abstract class ObjectModelCore
public function isAssociatedToShop($id_shop = null) public function isAssociatedToShop($id_shop = null)
{ {
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->id;
$sql = 'SELECT id_shop $sql = 'SELECT id_shop
FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_shop` FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_shop`
@@ -1003,7 +1003,7 @@ abstract class ObjectModelCore
public function isAssociatedToGroupShop($id_group_shop = null) public function isAssociatedToGroupShop($id_group_shop = null)
{ {
if (is_null($id_group_shop)) if (is_null($id_group_shop))
$id_group_shop = Context::getContext()->shop->getGroupID(); $id_group_shop = Context::getContext()->shop->id_group_shop;
$sql = 'SELECT id_group_shop $sql = 'SELECT id_group_shop
FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_group_shop` FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_group_shop`
+3 -3
View File
@@ -113,7 +113,7 @@ class PageCore extends ObjectModel
SET `counter` = `counter` + 1 SET `counter` = `counter` + 1
WHERE `id_date_range` = '.(int)$id_date_range.' WHERE `id_date_range` = '.(int)$id_date_range.'
AND `id_page` = '.(int)$id_page.' AND `id_page` = '.(int)$id_page.'
AND `id_shop` = '.(int)$context->shop->getID(); AND `id_shop` = '.(int)$context->shop->id;
Db::getInstance()->execute($sql); Db::getInstance()->execute($sql);
// If no one has seen the page in this date range, it is added // If no one has seen the page in this date range, it is added
@@ -122,8 +122,8 @@ class PageCore extends ObjectModel
'id_date_range' => (int)$id_date_range, 'id_date_range' => (int)$id_date_range,
'id_page' => (int)$id_page, 'id_page' => (int)$id_page,
'counter' => 1, 'counter' => 1,
'id_shop' => (int)$context->shop->getID(), 'id_shop' => (int)$context->shop->id,
'id_group_shop' => (int)$context->shop->getGroupID(), 'id_group_shop' => (int)$context->shop->id_group_shop,
)); ));
} }
} }
+2 -2
View File
@@ -151,8 +151,8 @@ abstract class PaymentModuleCore extends Module
$order->id_cart = (int)$cart->id; $order->id_cart = (int)$cart->id;
$order->reference = $reference; $order->reference = $reference;
$order->id_shop = (int)($shop->getID() ? $shop->getID() : $cart->id_shop); $order->id_shop = (int)(Shop::getContext() == Shop::CONTEXT_SHOP ? $shop->id : $cart->id_shop);
$order->id_group_shop = (int)($shop->getID() ? $shop->getGroupID() : $cart->id_group_shop); $order->id_group_shop = (int)(Shop::getContext() == Shop::CONTEXT_SHOP ? $shop->id_group_shop : $cart->id_group_shop);
$customer = new Customer($order->id_customer); $customer = new Customer($order->id_customer);
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($customer->secure_key)); $order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($customer->secure_key));
+6 -6
View File
@@ -1881,7 +1881,7 @@ class ProductCore extends ObjectModel
$id_country = (int)($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT')); $id_country = (int)($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
return SpecificPrice::getProductIdByDate( return SpecificPrice::getProductIdByDate(
$context->shop->getID(), $context->shop->id,
$context->currency->id, $context->currency->id,
$id_country, $id_country,
$context->customer->id_default_group, $context->customer->id_default_group,
@@ -2293,7 +2293,7 @@ class ProductCore extends ObjectModel
$id_customer = $context->customer->id; $id_customer = $context->customer->id;
return Product::priceCalculation( return Product::priceCalculation(
$context->shop->getID(), $context->shop->id,
$id_product, $id_product,
$id_product_attribute, $id_product_attribute,
$id_country, $id_country,
@@ -2514,7 +2514,7 @@ class ProductCore extends ObjectModel
$ids = Address::getCountryAndState((int)$context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $ids = Address::getCountryAndState((int)$context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$id_country = (int)($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT')); $id_country = (int)($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
return (bool)SpecificPrice::getSpecificPrice((int)$id_product, $context->shop->getID(), $id_currency, $id_country, $id_group, $quantity); return (bool)SpecificPrice::getSpecificPrice((int)$id_product, $context->shop->id, $id_currency, $id_country, $id_group, $quantity);
} }
/** /**
@@ -2649,7 +2649,7 @@ class ProductCore extends ObjectModel
else if (is_string($product_attribute)) else if (is_string($product_attribute))
$sql->where('stock.id_product_attribute = IFNULL('.pSQL($product_attribute).'.id_product_attribute, 0)'); $sql->where('stock.id_product_attribute = IFNULL('.pSQL($product_attribute).'.id_product_attribute, 0)');
} }
$sql = StockAvailable::addSqlShopRestriction($sql, $shop->getID(true), 'stock'); $sql = StockAvailable::addSqlShopRestriction($sql, $shop->id, 'stock');
} }
else else
{ {
@@ -2667,7 +2667,7 @@ class ProductCore extends ObjectModel
$sql .= ' AND stock.id_product_attribute = IFNULL('.pSQL($product_attribute).'.id_product_attribute, 0)'; $sql .= ' AND stock.id_product_attribute = IFNULL('.pSQL($product_attribute).'.id_product_attribute, 0)';
} }
$sql .= StockAvailable::addSqlShopRestriction(null, $shop->getID(true), 'stock').' )'; $sql .= StockAvailable::addSqlShopRestriction(null, $shop->id, 'stock').' )';
} }
return $sql; return $sql;
@@ -4662,7 +4662,7 @@ class ProductCore extends ObjectModel
$manager = StockManagerFactory::getManager(); $manager = StockManagerFactory::getManager();
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && Product::usesAdvancedStockManagement($id_product) && if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && Product::usesAdvancedStockManagement($id_product) &&
StockAvailable::dependsOnStock($id_product, $id_shop)) StockAvailable::dependsOnStock($id_product, $id_shop))
+4 -4
View File
@@ -178,7 +178,7 @@ class SearchCore
FROM '._DB_PREFIX_.'search_word sw FROM '._DB_PREFIX_.'search_word sw
LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word
WHERE sw.id_lang = '.(int)$id_lang.' WHERE sw.id_lang = '.(int)$id_lang.'
AND sw.id_shop = '.$context->shop->getID(true).' AND sw.id_shop = '.$context->shop->id.'
AND sw.word LIKE AND sw.word LIKE
'.($word[0] == '-' '.($word[0] == '-'
? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' ? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
@@ -201,7 +201,7 @@ class SearchCore
FROM '._DB_PREFIX_.'search_word sw FROM '._DB_PREFIX_.'search_word sw
LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word
WHERE sw.id_lang = '.(int)$id_lang.' WHERE sw.id_lang = '.(int)$id_lang.'
AND sw.id_shop = '.$context->shop->getID(true).' AND sw.id_shop = '.$context->shop->id.'
AND si.id_product = p.id_product AND si.id_product = p.id_product
AND ('.implode(' OR ', $score_array).') AND ('.implode(' OR ', $score_array).')
) position'; ) position';
@@ -608,7 +608,7 @@ class SearchCore
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.') LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`) LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)
WHERE p.`active` = 1 WHERE p.`active` = 1
AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID().' AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN ( AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
SELECT id_group FROM '._DB_PREFIX_.'customer_group SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.')').' WHERE id_customer = '.(int)$id_customer.')').'
@@ -645,7 +645,7 @@ class SearchCore
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cg.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.') LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cg.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
'.Product::sqlStock('p', 0).' '.Product::sqlStock('p', 0).'
WHERE p.`active` = 1 WHERE p.`active` = 1
AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID().' AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN ( AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
SELECT id_group FROM '._DB_PREFIX_.'customer_group SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.')').' WHERE id_customer = '.(int)$id_customer.')').'
+25 -25
View File
@@ -884,7 +884,7 @@ class AdminControllerCore extends Controller
foreach ($fields as $field => $values) foreach ($fields as $field => $values)
{ {
// We don't validate fields with no visibility // We don't validate fields with no visibility
if (Shop::isFeatureActive() && isset($values['visibility']) && ($values['visibility'] > Context::getContext()->shop->getContextType())) if (Shop::isFeatureActive() && isset($values['visibility']) && ($values['visibility'] > Shop::getContext()))
continue; continue;
// Check if field is required // Check if field is required
@@ -919,7 +919,7 @@ class AdminControllerCore extends Controller
{ {
foreach ($fields as $key => $options) foreach ($fields as $key => $options)
{ {
if (Shop::isFeatureActive() && isset($options['visibility']) && ($options['visibility'] > Context::getContext()->shop->getContextType())) if (Shop::isFeatureActive() && isset($options['visibility']) && ($options['visibility'] > Shop::getContext()))
continue; continue;
if (Shop::isFeatureActive() && isset($_POST['configUseDefault'][$key])) if (Shop::isFeatureActive() && isset($_POST['configUseDefault'][$key]))
@@ -1201,7 +1201,7 @@ class AdminControllerCore extends Controller
$quick_access = QuickAccess::getQuickAccesses($this->context->language->id); $quick_access = QuickAccess::getQuickAccesses($this->context->language->id);
foreach ($quick_access as $index => $quick) foreach ($quick_access as $index => $quick)
{ {
if ($quick['link'] == '../' && Context::shop() == Shop::CONTEXT_SHOP) if ($quick['link'] == '../' && Shop::getContext() == Shop::CONTEXT_SHOP)
$quick_access[$index]['link'] = $this->context->shop->getBaseURL(); $quick_access[$index]['link'] = $this->context->shop->getBaseURL();
else else
{ {
@@ -1312,26 +1312,14 @@ class AdminControllerCore extends Controller
// Shop context // Shop context
if ($is_multishop) if ($is_multishop)
{ {
if (Context::shop() == Shop::CONTEXT_ALL) if (Shop::getContext() == Shop::CONTEXT_SHOP)
{
$shop_context = 'all';
$shop_name = '';
}
else if (Context::shop() == Shop::CONTEXT_GROUP)
{
$shop_context = 'group';
$shop_name = $this->context->shop->getGroup()->name;
}
else
{
$shop_context = 'shop';
$shop_name = $this->context->shop->name; $shop_name = $this->context->shop->name;
} else
$shop_name = 'PrestaShop';
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'shop_name' => $shop_name, 'shop_name' => $shop_name,
'shop_context' => $shop_context, ));
));
} }
} }
@@ -1669,12 +1657,22 @@ class AdminControllerCore extends Controller
} }
else if (!Shop::isFeatureActive()) else if (!Shop::isFeatureActive())
$this->context->cookie->shopContext = 's-1'; $this->context->cookie->shopContext = 's-1';
$shop_id = ''; $shop_id = '';
Shop::setContext(Shop::CONTEXT_ALL);
if ($this->context->cookie->shopContext) if ($this->context->cookie->shopContext)
{ {
$split = explode('-', $this->context->cookie->shopContext); $split = explode('-', $this->context->cookie->shopContext);
if (count($split) == 2 && $split[0] == 's') if (count($split) == 2)
$shop_id = (int)$split[1]; {
if ($split[0] == 'g')
Shop::setContext(Shop::CONTEXT_GROUP, $split[1]);
else
{
Shop::setContext(Shop::CONTEXT_SHOP, $split[1]);
$shop_id = $split[1];
}
}
} }
else if ($this->context->employee->id_profile == _PS_ADMIN_PROFILE_) else if ($this->context->employee->id_profile == _PS_ADMIN_PROFILE_)
$shop_id = ''; $shop_id = '';
@@ -1688,7 +1686,9 @@ class AdminControllerCore extends Controller
Employee::getEmployeeShopAccess((int)$this->context->employee->id); Employee::getEmployeeShopAccess((int)$this->context->employee->id);
// Replace existing shop if necessary // Replace existing shop if necessary
if ($this->context->shop->id != $shop_id) if (!$shop_id)
$this->context->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
else if ($this->context->shop->id != $shop_id)
$this->context->shop = new Shop($shop_id); $this->context->shop = new Shop($shop_id);
if ($this->ajax && method_exists($this, 'ajaxPreprocess')) if ($this->ajax && method_exists($this, 'ajaxPreprocess'))
@@ -1955,7 +1955,7 @@ class AdminControllerCore extends Controller
else if (isset($assos_group[$this->table]) && $assos_group[$this->table]['type'] == 'group_shop') else if (isset($assos_group[$this->table]) && $assos_group[$this->table]['type'] == 'group_shop')
{ {
$filter_key = $assos_group[$this->table]['type']; $filter_key = $assos_group[$this->table]['type'];
$idenfier_shop = array($this->context->shop->getGroupID()); $idenfier_shop = array(Shop::getContextGroupShopID());
} }
} }
@@ -1968,7 +1968,7 @@ class AdminControllerCore extends Controller
$this->_group .= ', a.'.pSQL($this->identifier); $this->_group .= ', a.'.pSQL($this->identifier);
$test_join = !preg_match('#`?'.preg_quote(_DB_PREFIX_.$this->table.'_'.$filter_key).'`? *sa#', $this->_join); $test_join = !preg_match('#`?'.preg_quote(_DB_PREFIX_.$this->table.'_'.$filter_key).'`? *sa#', $this->_join);
if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && $test_join) if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && $test_join)
{ {
$filter_shop = ' JOIN `'._DB_PREFIX_.$this->table.'_'.$filter_key.'` sa '; $filter_shop = ' JOIN `'._DB_PREFIX_.$this->table.'_'.$filter_key.'` sa ';
$filter_shop .= 'ON (sa.'.$this->identifier.' = a.'.$this->identifier.' AND sa.id_'.$filter_key.' IN ('.implode(', ', $idenfier_shop).'))'; $filter_shop .= 'ON (sa.'.$this->identifier.' = a.'.$this->identifier.' AND sa.id_'.$filter_key.' IN ('.implode(', ', $idenfier_shop).'))';
+4 -4
View File
@@ -230,8 +230,8 @@ class FrontControllerCore extends Controller
$cart->id_lang = (int)($this->context->cookie->id_lang); $cart->id_lang = (int)($this->context->cookie->id_lang);
$cart->id_currency = (int)($this->context->cookie->id_currency); $cart->id_currency = (int)($this->context->cookie->id_currency);
$cart->id_guest = (int)($this->context->cookie->id_guest); $cart->id_guest = (int)($this->context->cookie->id_guest);
$cart->id_group_shop = (int)$this->context->shop->getGroupID(); $cart->id_group_shop = (int)$this->context->shop->id_group_shop;
$cart->id_shop = $this->context->shop->getID(true); $cart->id_shop = $this->context->shop->id;
if ($this->context->cookie->id_customer) if ($this->context->cookie->id_customer)
{ {
$cart->id_customer = (int)($this->context->cookie->id_customer); $cart->id_customer = (int)($this->context->cookie->id_customer);
@@ -308,7 +308,7 @@ class FrontControllerCore extends Controller
'come_from' => Tools::getHttpHost(true, true).Tools::htmlentitiesUTF8(str_replace('\'', '', urldecode($_SERVER['REQUEST_URI']))), 'come_from' => Tools::getHttpHost(true, true).Tools::htmlentitiesUTF8(str_replace('\'', '', urldecode($_SERVER['REQUEST_URI']))),
'cart_qties' => (int)$cart->nbProducts(), 'cart_qties' => (int)$cart->nbProducts(),
'currencies' => Currency::getCurrencies(), 'currencies' => Currency::getCurrencies(),
'languages' => Language::getLanguages(true, $this->context->shop->getID()), 'languages' => Language::getLanguages(true, $this->context->shop->id),
'priceDisplay' => Product::getTaxCalculationMethod(), 'priceDisplay' => Product::getTaxCalculationMethod(),
'add_prod_display' => (int)Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'add_prod_display' => (int)Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'shop_name' => Configuration::get('PS_SHOP_NAME'), 'shop_name' => Configuration::get('PS_SHOP_NAME'),
@@ -694,7 +694,7 @@ class FrontControllerCore extends Controller
'ad' => $ad, 'ad' => $ad,
'live_edit' => true, 'live_edit' => true,
'hook_list' => Hook::$executed_hooks, 'hook_list' => Hook::$executed_hooks,
'id_shop' => $this->context->shop->getId(true) 'id_shop' => $this->context->shop->id
)); ));
return $this->context->smarty->createTemplate(_PS_ALL_THEMES_DIR_.'live_edit.tpl', $data)->fetch(); return $this->context->smarty->createTemplate(_PS_ALL_THEMES_DIR_.'live_edit.tpl', $data)->fetch();
} }
+6 -6
View File
@@ -209,21 +209,21 @@ class HelperFormCore extends Helper
} }
else else
{ {
switch (Context::shop()) switch (Shop::getContext())
{ {
case Shop::CONTEXT_SHOP : case Shop::CONTEXT_SHOP :
$assos[$this->context->shop->id] = $this->context->shop->id; $assos[Shop::getContextShopID()] = Shop::getContextShopID();
break; break;
case Shop::CONTEXT_GROUP : case Shop::CONTEXT_GROUP :
foreach (Shop::getShops(false, $this->context->shop->getGroupID(), true) as $id_shop) foreach (Shop::getShops(false, Shop::getContextGroupShopID(), true) as $id_shop)
$assos[$id_shop] = $id_shop; $assos[$id_shop] = $id_shop;
break; break;
default : default :
foreach (Shop::getShops(false, null, true) as $id_shop) foreach (Shop::getShops(false, null, true) as $id_shop)
$assos[$id_shop] = $id_shop; $assos[$id_shop] = $id_shop;
break; break;
} }
} }
+3 -3
View File
@@ -71,12 +71,12 @@ class HelperOptionsCore extends Helper
$isDisabled = $isInvisible = false; $isDisabled = $isInvisible = false;
if (Shop::isFeatureActive()) if (Shop::isFeatureActive())
{ {
if (isset($field['visibility']) && $field['visibility'] > $this->context->shop->getContextType()) if (isset($field['visibility']) && $field['visibility'] > Shop::getContext())
{ {
$isDisabled = true; $isDisabled = true;
$isInvisible = true; $isInvisible = true;
} }
else if (Context::shop() != Shop::CONTEXT_ALL && !Configuration::isOverridenByCurrentContext($key)) else if (Shop::getContext() != Shop::CONTEXT_ALL && !Configuration::isOverridenByCurrentContext($key))
$isDisabled = true; $isDisabled = true;
} }
$field['is_disabled'] = $isDisabled; $field['is_disabled'] = $isDisabled;
@@ -126,7 +126,7 @@ class HelperOptionsCore extends Helper
} }
// Multishop default value // Multishop default value
$field['multishop_default'] = (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && !$isInvisible); $field['multishop_default'] = (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && !$isInvisible);
// Assign the modifications back to parent array // Assign the modifications back to parent array
$category_data['fields'][$key] = $field; $category_data['fields'][$key] = $field;
+2 -2
View File
@@ -227,7 +227,7 @@ class OrderDetailCore extends ObjectModel
$this->context = $context; $this->context = $context;
$id_shop = null; $id_shop = null;
if ($this->context != null && isset($this->context->shop)) if ($this->context != null && isset($this->context->shop))
$id_shop = $this->context->shop->getID(); $id_shop = $this->context->shop->id;
parent::__construct($id, $id_lang, $id_shop); parent::__construct($id, $id_lang, $id_shop);
} }
@@ -458,7 +458,7 @@ class OrderDetailCore extends ObjectModel
$this->group_reduction = (float)(Group::getReduction((int)($order->id_customer))); $this->group_reduction = (float)(Group::getReduction((int)($order->id_customer)));
if (isset($this->context->shop)) if (isset($this->context->shop))
$shop_id = $this->context->shop->getID(); $shop_id = $this->context->shop->id;
else else
$shop_id = $cart->id_shop; $shop_id = $cart->id_shop;
+48 -90
View File
@@ -105,6 +105,10 @@ class ShopCore extends ObjectModel
), ),
); );
protected static $context;
protected static $context_id_shop;
protected static $context_id_group_shop;
/** /**
* There are 3 kinds of shop context : shop, group shop and general * There are 3 kinds of shop context : shop, group shop and general
*/ */
@@ -369,32 +373,10 @@ class ShopCore extends ObjectModel
public function getGroup() public function getGroup()
{ {
if (!$this->group) if (!$this->group)
$this->group = new GroupShop($this->getGroupID()); $this->group = new GroupShop($this->id_group_shop);
return $this->group; return $this->group;
} }
/**
* Get current shop ID
*
* @return int
*/
public function getID($use_default = false)
{
return (!$this->id && $use_default) ? (int)Configuration::get('PS_SHOP_DEFAULT') : (int)$this->id;
}
/**
* Get current shop group ID
*
* @return int
*/
public function getGroupID()
{
if (defined('_PS_ADMIN_DIR_'))
return Shop::getContextGroupID();
return (isset($this->id_group_shop)) ? (int)$this->id_group_shop : null;
}
/** /**
* Get root category of current shop * Get root category of current shop
* *
@@ -637,13 +619,10 @@ class ShopCore extends ObjectModel
*/ */
public function getListOfID($share = false) public function getListOfID($share = false)
{ {
$shop_id = $this->getID(); if (Shop::getContext() == Shop::CONTEXT_SHOP)
$shop_group_id = $this->getGroupID(); $list = ($share) ? Shop::getSharedShops(Shop::getContextShopID(), $share) : array(Shop::getContextShopID());
else if (Shop::getContext() == Shop::CONTEXT_GROUP)
if ($shop_id) $list = Shop::getShops(true, Shop::getContextGroupShopID(), true);
$list = ($share) ? Shop::getSharedShops($shop_id, $share) : array($shop_id);
else if ($shop_group_id)
$list = Shop::getShops(true, $shop_group_id, true);
else else
$list = Shop::getShops(true, null, true); $list = Shop::getShops(true, null, true);
@@ -669,46 +648,45 @@ class ShopCore extends ObjectModel
return Db::getInstance()->executeS($sql); return Db::getInstance()->executeS($sql);
} }
/** public static function setContext($type, $id = null)
* Retrieve the current shop context in FO or BO
*
* @param string null|shop|group
* @return array(id_shop, id_group_shop)|int
*/
public static function getContext($type = null)
{ {
$context = Context::getContext(); switch ($type)
if (!isset($context->shop))
return ($type == 'shop' || $type == 'group') ? '' : array('', '');
$shop_id = $context->shop->id;
$shop_group_id = $context->shop->id_group_shop;
if (defined('_PS_ADMIN_DIR_'))
{ {
if (!isset($context->cookie) || !$context->cookie->shopContext) case self::CONTEXT_ALL :
return ($type == 'shop' || $type == 'group') ? '' : array('', ''); self::$context_id_shop = null;
self::$context_id_group_shop = null;
break;
// Parse shopContext cookie value (E.g. s-2, g-4) case self::CONTEXT_GROUP :
$split = explode('-', $context->cookie->shopContext); self::$context_id_shop = null;
if (count($split) == 2 && $split[0] == 'g') self::$context_id_group_shop = (int)$id;
$shop_group_id = (int)$split[1]; break;
case self::CONTEXT_SHOP :
self::$context_id_shop = (int)$id;
self::$context_id_group_shop = Shop::getGroupFromShop($id);
break;
default :
throw new PrestaShopException('Unknown context for shop');
} }
if ($type == 'shop') self::$context = $type;
return $shop_id;
else if ($type == 'group')
return $shop_group_id;
return array($shop_id, $shop_group_id);
} }
/** public static function getContext()
* Get ID shop from context
*
* @return int
*/
public static function getContextID()
{ {
return Shop::getContext('shop'); return self::$context;
}
public static function getContextShopID()
{
return self::$context_id_shop;
}
public static function getContextGroupShopID()
{
return self::$context_id_group_shop;
} }
/** /**
@@ -721,21 +699,6 @@ class ShopCore extends ObjectModel
return Shop::getContext('group'); return Shop::getContext('group');
} }
/**
* Check in which type of shop context we are
*
* @return int
*/
public function getContextType()
{
list($shop_id, $shop_group_id) = Shop::getContext();
if ($shop_id)
return Shop::CONTEXT_SHOP;
else if ($shop_group_id)
return Shop::CONTEXT_GROUP;
return Shop::CONTEXT_ALL;
}
/** /**
* Add an sql restriction for shops fields * Add an sql restriction for shops fields
* *
@@ -752,19 +715,14 @@ class ShopCore extends ObjectModel
$alias .= '.'; $alias .= '.';
$restriction = ''; $restriction = '';
$shop_id = $this->getID();
$shop_group_id = $this->getGroupID();
if ($type == 'group_shop') if ($type == 'group_shop')
{ {
if ($shop_id) if (Shop::getContext() != Shop::CONTEXT_ALL)
$restriction = ' AND '.$alias.'id_group_shop = '.Shop::getGroupFromShop($shop_id).' '; $restriction = ' AND '.$alias.'id_group_shop = '.Shop::getContextGroupShopID().' ';
else if ($shop_group_id)
$restriction = ' AND '.$alias.'id_group_shop = '.$shop_group_id.' ';
} }
else else
{ {
if ($shop_id || $shop_group_id) if (Shop::getContext() != Shop::CONTEXT_ALL)
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', $this->getListOfID($share)).') '; $restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', $this->getListOfID($share)).') ';
//else if ($share == Shop::SHARE_STOCK) //else if ($share == Shop::SHARE_STOCK)
// $restriction = ' AND '.$alias.'id_shop = '.$this->getID(true); // $restriction = ' AND '.$alias.'id_shop = '.$this->getID(true);
@@ -807,7 +765,7 @@ class ShopCore extends ObjectModel
*/ */
public function addSqlRestrictionOnLang($alias = null) public function addSqlRestrictionOnLang($alias = null)
{ {
return ' AND '.(($alias) ? $alias.'.' : '').'id_shop = '.$this->getID(true).' '; return ' AND '.(($alias) ? $alias.'.' : '').'id_shop = '.$this->id.' ';
} }
/** /**
@@ -888,12 +846,12 @@ class ShopCore extends ObjectModel
} }
/** /**
* @deprecated 1.5.0 Use shop->getID() * @deprecated 1.5.0 Use shop->id
*/ */
public static function getCurrentShop() public static function getCurrentShop()
{ {
Tools::displayAsDeprecated(); Tools::displayAsDeprecated();
return Context::getContext()->shop->getID(true); return Context::getContext()->shop->id;
} }
/** /**
@@ -938,7 +896,7 @@ class ShopCore extends ObjectModel
SELECT `id_category` SELECT `id_category`
FROM `'._DB_PREFIX_.'category_shop` FROM `'._DB_PREFIX_.'category_shop`
WHERE `id_category` = '.(int)$id_category.' WHERE `id_category` = '.(int)$id_category.'
AND `id_shop` = '.(int)Context::getContext()->shop->getID(true)); AND `id_shop` = '.(int)Context::getContext()->shop->id);
} }
/** /**
@@ -958,6 +916,6 @@ class ShopCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs LEFT JOIN `'._DB_PREFIX_.'category_shop` cs
ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.') ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
WHERE p.`id_product` = '.(int)$id_product.' WHERE p.`id_product` = '.(int)$id_product.'
AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true)); AND cs.`id_shop` = '.(int)Context::getContext()->shop->id);
} }
} }
+2 -2
View File
@@ -143,7 +143,7 @@ class ShopUrlCore extends ObjectModel
if (!self::$main_domain) if (!self::$main_domain)
self::$main_domain = Db::getInstance()->getValue('SELECT domain self::$main_domain = Db::getInstance()->getValue('SELECT domain
FROM '._DB_PREFIX_.'shop_url FROM '._DB_PREFIX_.'shop_url
WHERE main=1 AND id_shop = '.Context::getContext()->shop->getID(true)); WHERE main=1 AND id_shop = '.Context::getContext()->shop->id);
return self::$main_domain; return self::$main_domain;
} }
@@ -154,7 +154,7 @@ class ShopUrlCore extends ObjectModel
$sql = 'SELECT domain_ssl $sql = 'SELECT domain_ssl
FROM '._DB_PREFIX_.'shop_url FROM '._DB_PREFIX_.'shop_url
WHERE main = 1 WHERE main = 1
AND id_shop='.Context::getContext()->shop->getID(true); AND id_shop='.Context::getContext()->shop->id;
self::$main_domain_ssl = Db::getInstance()->getValue($sql); self::$main_domain_ssl = Db::getInstance()->getValue($sql);
} }
return self::$main_domain_ssl; return self::$main_domain_ssl;
+8 -8
View File
@@ -182,7 +182,7 @@ class StockAvailableCore extends ObjectModel
public static function setProductDependsOnStock($id_product, $depends_on_stock = true, $id_shop = null) public static function setProductDependsOnStock($id_product, $depends_on_stock = true, $id_shop = null)
{ {
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
$existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, 0, (int)$id_shop); $existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, 0, (int)$id_shop);
@@ -223,7 +223,7 @@ class StockAvailableCore extends ObjectModel
public static function setProductOutOfStock($id_product, $out_of_stock = false, $id_shop = null) public static function setProductOutOfStock($id_product, $out_of_stock = false, $id_shop = null)
{ {
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
$existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, 0, (int)$id_shop); $existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, 0, (int)$id_shop);
@@ -261,7 +261,7 @@ class StockAvailableCore extends ObjectModel
public static function getQuantityAvailableByProduct($id_product = null, $id_product_attribute = null, $id_shop = null) public static function getQuantityAvailableByProduct($id_product = null, $id_product_attribute = null, $id_shop = null)
{ {
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
// if null, it's a product without attributes // if null, it's a product without attributes
if (is_null($id_product_attribute)) if (is_null($id_product_attribute))
@@ -381,7 +381,7 @@ class StockAvailableCore extends ObjectModel
// if there is no $id_shop, gets the context one // if there is no $id_shop, gets the context one
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = (int)$context->shop->getID(true); $id_shop = (int)$context->shop->id;
$id_lang = Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
$depends_on_stock = StockAvailable::dependsOnStock($id_product); $depends_on_stock = StockAvailable::dependsOnStock($id_product);
@@ -503,7 +503,7 @@ class StockAvailableCore extends ObjectModel
public static function dependsOnStock($id_product, $id_shop = null) public static function dependsOnStock($id_product, $id_shop = null)
{ {
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
$query = new DbQuery(); $query = new DbQuery();
$query->select('depends_on_stock'); $query->select('depends_on_stock');
@@ -526,7 +526,7 @@ class StockAvailableCore extends ObjectModel
public static function outOfStock($id_product, $id_shop = null) public static function outOfStock($id_product, $id_shop = null)
{ {
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
$query = new DbQuery(); $query = new DbQuery();
$query->select('out_of_stock'); $query->select('out_of_stock');
@@ -557,7 +557,7 @@ class StockAvailableCore extends ObjectModel
// if there is no $id_shop, gets the context one // if there is no $id_shop, gets the context one
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = $context->shop->getID(); $id_shop = $context->shop->id;
// if we are in group_shop context // if we are in group_shop context
$group_shop = $context->shop->getGroup(); $group_shop = $context->shop->getGroup();
@@ -610,7 +610,7 @@ class StockAvailableCore extends ObjectModel
// if there is no $id_shop, gets the context one // if there is no $id_shop, gets the context one
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = $context->shop->getID(true); $id_shop = $context->shop->id;
$group_shop = $context->shop->getGroup(); $group_shop = $context->shop->getGroup();
+3 -3
View File
@@ -307,7 +307,7 @@ class WarehouseCore extends ObjectModel
public static function getProductWarehouseList($id_product, $id_product_attribute = 0, $id_shop = null) public static function getProductWarehouseList($id_product, $id_product_attribute = 0, $id_shop = null)
{ {
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
// if it's a pack, returns warehouses if and only if some products use the advanced stock management // if it's a pack, returns warehouses if and only if some products use the advanced stock management
if (Pack::isPack($id_product)) if (Pack::isPack($id_product))
@@ -344,7 +344,7 @@ class WarehouseCore extends ObjectModel
{ {
if (!$ignore_shop) if (!$ignore_shop)
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
$query = new DbQuery(); $query = new DbQuery();
$query->select('w.id_warehouse, CONCAT(reference, \' - \', name) as name'); $query->select('w.id_warehouse, CONCAT(reference, \' - \', name) as name');
@@ -497,7 +497,7 @@ class WarehouseCore extends ObjectModel
return false; return false;
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
// warehouses of the pack // warehouses of the pack
$pack_warehouses = WarehouseProductLocation::getCollection((int)$id_product); $pack_warehouses = WarehouseProductLocation::getCollection((int)$id_product);
+2 -2
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -115,7 +115,7 @@ $cookieLifetime = (time() + (((int)Configuration::get('PS_COOKIE_LIFETIME_BO') >
if (defined('_PS_ADMIN_DIR_')) if (defined('_PS_ADMIN_DIR_'))
$cookie = new Cookie('psAdmin', '', $cookieLifetime); $cookie = new Cookie('psAdmin', '', $cookieLifetime);
else else
$cookie = new Cookie('ps'.Context::getContext()->shop->getID(), '', $cookieLifetime); $cookie = new Cookie('ps'.Context::getContext()->shop->id, '', $cookieLifetime);
Context::getContext()->cookie = $cookie; Context::getContext()->cookie = $cookie;
/* Create employee if in BO, customer else */ /* Create employee if in BO, customer else */
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -46,7 +46,7 @@ class AdminAccountingManagementControllerCore extends AdminController
$this->initToolbar(); $this->initToolbar();
$zones = Zone::getZones(); $zones = Zone::getZones();
$id_shop = $this->context->shop->getID(); $id_shop = $this->context->shop->id;
// Set default zone value to the shop and sort it // Set default zone value to the shop and sort it
foreach ($zones as $zone) foreach ($zones as $zone)
@@ -105,7 +105,7 @@ class AdminAccountingManagementControllerCore extends AdminController
*/ */
protected function updateAccountNumber() protected function updateAccountNumber()
{ {
$id_shop = $this->context->shop->getID(); $id_shop = $this->context->shop->id;
// Update the current default shop account number // Update the current default shop account number
Configuration::updateValue( Configuration::updateValue(
@@ -153,7 +153,7 @@ class AdminCategoriesControllerCore extends AdminController
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (a.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (a.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')';
// we add restriction for shop // we add restriction for shop
if (Shop::CONTEXT_SHOP == Context::getContext()->shop() && $is_multishop) if (Shop::CONTEXT_SHOP == Context::getContext()->shop() && $is_multishop)
$this->_where = ' AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true); $this->_where = ' AND cs.`id_shop` = '.(int)Context::getContext()->shop->id;
$categories_tree = $this->_category->getParentsCategories(); $categories_tree = $this->_category->getParentsCategories();
if (empty($categories_tree) if (empty($categories_tree)
@@ -181,7 +181,7 @@ class AdminCategoriesControllerCore extends AdminController
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{ {
parent::getList($id_lang, 'cs.position', $order_way, $start, $limit, Context::getContext()->shop->getID(true)); parent::getList($id_lang, 'cs.position', $order_way, $start, $limit, Context::getContext()->shop->id);
// Check each row to see if there are combinations and get the correct action in consequence // Check each row to see if there are combinations and get the correct action in consequence
$nb_items = count($this->_list); $nb_items = count($this->_list);
@@ -271,7 +271,7 @@ class AdminCategoriesControllerCore extends AdminController
{ {
$this->initToolbar(); $this->initToolbar();
$obj = $this->loadObject(true); $obj = $this->loadObject(true);
$id_shop = Context::getContext()->shop->getID(true); $id_shop = Context::getContext()->shop->id;
$selected_cat = array((isset($obj->id_parent) && $obj->isParentCategoryAvailable($id_shop))? $obj->id_parent : Tools::getValue('id_parent', Category::getRootCategory()->id)); $selected_cat = array((isset($obj->id_parent) && $obj->isParentCategoryAvailable($id_shop))? $obj->id_parent : Tools::getValue('id_parent', Category::getRootCategory()->id));
$unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP')); $unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP'));
$guest = new Group(Configuration::get('PS_GUEST_GROUP')); $guest = new Group(Configuration::get('PS_GUEST_GROUP'));
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -513,7 +513,7 @@ class AdminCustomersControllerCore extends AdminController
public function beforeAdd($customer) public function beforeAdd($customer)
{ {
$customer->id_shop = $this->context->shop->getID(true); $customer->id_shop = $this->context->shop->id;
} }
public function renderView() public function renderView()
@@ -229,11 +229,11 @@ class AdminGroupShopControllerCore extends AdminController
'desc' => $this->l('Use this option to associate data (products, modules, etc.) the same way as the selected shop') 'desc' => $this->l('Use this option to associate data (products, modules, etc.) the same way as the selected shop')
); );
$default_group_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); $default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
$this->tpl_form_vars = array( $this->tpl_form_vars = array(
'disabled' => $disabled, 'disabled' => $disabled,
'checked' => (Tools::getValue('addgroup_shop') !== false) ? true : false, 'checked' => (Tools::getValue('addgroup_shop') !== false) ? true : false,
'defaultGroup' => $default_group_shop->getGroupID(), 'defaultGroup' => $default_shop->id_group_shop,
); );
if (isset($this->fields_import_form)) if (isset($this->fields_import_form))
$this->tpl_form_vars = array_merge($this->tpl_form_vars, array('form_import' => $this->fields_import_form)); $this->tpl_form_vars = array_merge($this->tpl_form_vars, array('form_import' => $this->fields_import_form));
+1 -1
View File
@@ -1139,7 +1139,7 @@ class AdminImportControllerCore extends AdminController
$specific_price = new SpecificPrice(); $specific_price = new SpecificPrice();
$specific_price->id_product = (int)$product->id; $specific_price->id_product = (int)$product->id;
// @todo multishop specific price import // @todo multishop specific price import
$specific_price->id_shop = $this->context->shop->getID(true); $specific_price->id_shop = $this->context->shop->id;
$specific_price->id_currency = 0; $specific_price->id_currency = 0;
$specific_price->id_country = 0; $specific_price->id_country = 0;
$specific_price->id_group = 0; $specific_price->id_group = 0;
+2 -2
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -216,7 +216,7 @@ class AdminMetaControllerCore extends AdminController
public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = false) public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = false)
{ {
parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, Context::getContext()->shop->getID(true)); parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, Context::getContext()->shop->id);
} }
/** /**
+4 -4
View File
@@ -633,7 +633,7 @@ class AdminModulesControllerCore extends AdminController
else else
{ {
// If we install a module, force temporary global context for multishop // If we install a module, force temporary global context for multishop
if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && $method != 'getContent') if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && $method != 'getContent')
{ {
Context::getContext()->tmpOldShop = clone(Context::getContext()->shop); Context::getContext()->tmpOldShop = clone(Context::getContext()->shop);
Context::getContext()->shop = new Shop(); Context::getContext()->shop = new Shop();
@@ -677,9 +677,9 @@ class AdminModulesControllerCore extends AdminController
$toolbar .= '<tr> $toolbar .= '<tr>
<th colspan="4"> <th colspan="4">
<input type="checkbox" name="activateModule" value="1" '.(($module->active) ? 'checked="checked"' : '').' '.$activateOnclick.' /> '.$this->l('Activate module for').' '; <input type="checkbox" name="activateModule" value="1" '.(($module->active) ? 'checked="checked"' : '').' '.$activateOnclick.' /> '.$this->l('Activate module for').' ';
if ($this->context->shop->getContextType() == Shop::CONTEXT_SHOP) if (Shop::getContext() == Shop::CONTEXT_SHOP)
$toolbar .= 'shop <b>'.$this->context->shop->name.'</b>'; $toolbar .= 'shop <b>'.$this->context->shop->name.'</b>';
elseif ($this->context->shop->getContextType() == Shop::CONTEXT_GROUP) elseif (Shop::getContext() == Shop::CONTEXT_GROUP)
$toolbar .= 'all shops of group shop <b>'.$this->context->shop->getGroup()->name.'</b>'; $toolbar .= 'all shops of group shop <b>'.$this->context->shop->getGroup()->name.'</b>';
else else
$toolbar .= 'all shops'; $toolbar .= 'all shops';
@@ -701,7 +701,7 @@ class AdminModulesControllerCore extends AdminController
$return = ($method == 'install' ? 12 : 13); $return = ($method == 'install' ? 12 : 13);
elseif ($echo === false) elseif ($echo === false)
$module_errors[] = array('name' => $name, 'message' => $module->getErrors()); $module_errors[] = array('name' => $name, 'message' => $module->getErrors());
if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && isset(Context::getContext()->tmpOldShop)) if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && isset(Context::getContext()->tmpOldShop))
{ {
Context::getContext()->shop = clone(Context::getContext()->tmpOldShop); Context::getContext()->shop = clone(Context::getContext()->tmpOldShop);
unset(Context::getContext()->tmpOldShop); unset(Context::getContext()->tmpOldShop);
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -278,14 +278,14 @@ class AdminModulesPositionsControllerCore extends AdminController
'modules' => $module_instances, 'modules' => $module_instances,
'url_show_invisible' => self::$currentIndex.'&token='.$this->token.'&show_modules='.(int)Tools::getValue('show_modules').'&hook_position=', 'url_show_invisible' => self::$currentIndex.'&token='.$this->token.'&show_modules='.(int)Tools::getValue('show_modules').'&hook_position=',
'hook_position' => Tools::getValue('hook_position'), 'hook_position' => Tools::getValue('hook_position'),
'live_edit' => Shop::isFeatureActive() && $this->context->shop->getContextType() != Shop::CONTEXT_SHOP, 'live_edit' => Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP,
'url_live_edit' => $this->context->link->getPageLink('index', false, null, 'url_live_edit' => $this->context->link->getPageLink('index', false, null,
'live_edit&ad='.$admin_dir.'&liveToken='.sha1($admin_dir._COOKIE_KEY_) 'live_edit&ad='.$admin_dir.'&liveToken='.sha1($admin_dir._COOKIE_KEY_)
.(Shop::isFeatureActive()?'&id_shop='.Context::getContext()->shop->getID() : '')), .(Shop::isFeatureActive()?'&id_shop='.Context::getContext()->shop->id : '')),
'display_key' => $this->display_key, 'display_key' => $this->display_key,
'hooks' => $hooks, 'hooks' => $hooks,
'url_submit' => self::$currentIndex.'&token='.$this->token, 'url_submit' => self::$currentIndex.'&token='.$this->token,
'can_move' => (Shop::isFeatureActive() && $this->context->shop->getContextType() != Shop::CONTEXT_SHOP) ? false : true, 'can_move' => (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) ? false : true,
)); ));
return $this->createTemplate('list_modules.tpl')->fetch(); return $this->createTemplate('list_modules.tpl')->fetch();
+4 -4
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -321,7 +321,7 @@ class AdminOrdersControllerCore extends AdminController
$customer_thread = new CustomerThread(); $customer_thread = new CustomerThread();
$customer_thread->id_contact = 0; $customer_thread->id_contact = 0;
$customer_thread->id_customer = (int)$order->id_customer; $customer_thread->id_customer = (int)$order->id_customer;
$customer_thread->id_shop = (int)$this->context->shop->getId(true); $customer_thread->id_shop = (int)$this->context->shop->id;
$customer_thread->id_order = (int)$order->id; $customer_thread->id_order = (int)$order->id;
$customer_thread->id_lang = (int)$this->context->language->id; $customer_thread->id_lang = (int)$this->context->language->id;
$customer_thread->email = $customer->email; $customer_thread->email = $customer->email;
@@ -1151,7 +1151,7 @@ class AdminOrdersControllerCore extends AdminController
$productObj = new Product((int)$product['id_product'], false, (int)$this->context->language->id); $productObj = new Product((int)$product['id_product'], false, (int)$this->context->language->id);
$combinations = array(); $combinations = array();
$attributes = $productObj->getAttributesGroups((int)$this->context->language->id); $attributes = $productObj->getAttributesGroups((int)$this->context->language->id);
$product['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], 0, (int)$this->context->shop->getID()); $product['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], 0, (int)$this->context->shop->id);
// Tax rate for this customer // Tax rate for this customer
if (Tools::isSubmit('id_address')) if (Tools::isSubmit('id_address'))
$product['tax_rate'] = $productObj->getTaxesRate(new Address(Tools::getValue('id_address'))); $product['tax_rate'] = $productObj->getTaxesRate(new Address(Tools::getValue('id_address')));
@@ -1174,7 +1174,7 @@ class AdminOrdersControllerCore extends AdminController
$combinations[$attribute['id_product_attribute']]['formatted_price'] = Tools::displayPrice(Tools::convertPrice($price_tax_incl, $currency), $currency); $combinations[$attribute['id_product_attribute']]['formatted_price'] = Tools::displayPrice(Tools::convertPrice($price_tax_incl, $currency), $currency);
} }
if (!isset($combinations[$attribute['id_product_attribute']]['qty_in_stock'])) if (!isset($combinations[$attribute['id_product_attribute']]['qty_in_stock']))
$combinations[$attribute['id_product_attribute']]['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], $attribute['id_product_attribute'], (int)$this->context->shop->getID()); $combinations[$attribute['id_product_attribute']]['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], $attribute['id_product_attribute'], (int)$this->context->shop->id);
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int)$product['advanced_stock_management'] == 1) if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int)$product['advanced_stock_management'] == 1)
$product['warehouse_list'][$attribute['id_product_attribute']] = Warehouse::getProductWarehouseList($product['id_product'], $attribute['id_product_attribute']); $product['warehouse_list'][$attribute['id_product_attribute']] = Warehouse::getProductWarehouseList($product['id_product'], $attribute['id_product_attribute']);
+5 -5
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -31,7 +31,7 @@ class AdminPaymentControllerCore extends AdminController
public function __construct() public function __construct()
{ {
$shop_id = Context::getContext()->shop->getID(true); $shop_id = Context::getContext()->shop->id;
/* Get all modules then select only payment ones */ /* Get all modules then select only payment ones */
$modules = Module::getModulesOnDisk(true); $modules = Module::getModulesOnDisk(true);
@@ -108,11 +108,11 @@ class AdminPaymentControllerCore extends AdminController
protected function saveRestrictions($type) protected function saveRestrictions($type)
{ {
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'module_'.bqSQL($type).'` WHERE id_shop = '.Context::getContext()->shop->getID(true)); Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'module_'.bqSQL($type).'` WHERE id_shop = '.Context::getContext()->shop->id);
foreach ($this->payment_modules as $module) foreach ($this->payment_modules as $module)
if ($module->active && isset($_POST[$module->name.'_'.$type.''])) if ($module->active && isset($_POST[$module->name.'_'.$type.'']))
foreach ($_POST[$module->name.'_'.$type.''] as $selected) foreach ($_POST[$module->name.'_'.$type.''] as $selected)
$values[] = '('.(int)$module->id.', '.Context::getContext()->shop->getID(true).', '.(int)$selected.')'; $values[] = '('.(int)$module->id.', '.Context::getContext()->shop->id.', '.(int)$selected.')';
if (count($values)) if (count($values))
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'module_'.$type.' (`id_module`, `id_shop`, `id_'.$type.'`) VALUES '.implode(',', $values)); Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'module_'.$type.' (`id_module`, `id_shop`, `id_'.$type.'`) VALUES '.implode(',', $values));
@@ -130,7 +130,7 @@ class AdminPaymentControllerCore extends AdminController
$this->toolbar_title = $this->l('Paiement'); $this->toolbar_title = $this->l('Paiement');
unset($this->toolbar_btn['back']); unset($this->toolbar_btn['back']);
$shop_context = (!Shop::isFeatureActive() || $this->context->shop->getContextType() == Shop::CONTEXT_SHOP); $shop_context = (!Shop::isFeatureActive() || Shop::getContext() == Shop::CONTEXT_SHOP);
if (!$shop_context) if (!$shop_context)
{ {
$this->tpl_view_vars = array('shop_context' => $shop_context); $this->tpl_view_vars = array('shop_context' => $shop_context);
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
* *
@@ -1521,7 +1521,7 @@ class AdminProductsControllerCore extends AdminController
// Save and preview // Save and preview
if (Tools::isSubmit('submitAddProductAndPreview')) if (Tools::isSubmit('submitAddProductAndPreview'))
{ {
$preview_url = $this->context->link->getProductLink($this->getFieldValue($object, 'id'), $this->getFieldValue($object, 'link_rewrite', $this->context->language->id), Category::getLinkRewrite($this->getFieldValue($object, 'id_category_default'), $this->context->language->id), null, null, Context::getContext()->shop->getID()); $preview_url = $this->context->link->getProductLink($this->getFieldValue($object, 'id'), $this->getFieldValue($object, 'link_rewrite', $this->context->language->id), Category::getLinkRewrite($this->getFieldValue($object, 'id_category_default'), $this->context->language->id), null, null, Context::getContext()->shop->id);
if (!$object->active) if (!$object->active)
{ {
$admin_dir = dirname($_SERVER['PHP_SELF']); $admin_dir = dirname($_SERVER['PHP_SELF']);
@@ -1909,7 +1909,7 @@ class AdminProductsControllerCore extends AdminController
{ {
if ($id_category = (int)Tools::getValue('id_category')) if ($id_category = (int)Tools::getValue('id_category'))
self::$currentIndex .= '&id_category='.(int)$id_category; self::$currentIndex .= '&id_category='.(int)$id_category;
$this->getList($this->context->language->id, !$this->context->cookie->__get($this->table.'Orderby') ? 'position' : null, !$this->context->cookie->__get($this->table.'Orderway') ? 'ASC' : null, 0, null, $this->context->shop->getID(true)); $this->getList($this->context->language->id, !$this->context->cookie->__get($this->table.'Orderby') ? 'position' : null, !$this->context->cookie->__get($this->table.'Orderway') ? 'ASC' : null, 0, null, $this->context->shop->id);
$id_category = (int)Tools::getValue('id_category', 1); $id_category = (int)Tools::getValue('id_category', 1);
$this->tpl_list_vars['is_category_filter'] = Tools::getValue('id_category') ? true : false; $this->tpl_list_vars['is_category_filter'] = Tools::getValue('id_category') ? true : false;
@@ -2172,7 +2172,7 @@ class AdminProductsControllerCore extends AdminController
$preview_url = $this->context->link->getProductLink( $preview_url = $this->context->link->getProductLink(
$product, $product,
$this->getFieldValue($product, 'link_rewrite', $this->context->language->id), $this->getFieldValue($product, 'link_rewrite', $this->context->language->id),
Category::getLinkRewrite($product->id_category_default, $this->context->language->id), null, null, Context::getContext()->shop->getID()); Category::getLinkRewrite($product->id_category_default, $this->context->language->id), null, null, Context::getContext()->shop->id);
if (!$product->active) if (!$product->active)
{ {
$preview_url = $this->context->link->getProductLink($product, $this->getFieldValue($product, 'link_rewrite', $this->default_form_language), Category::getLinkRewrite($this->getFieldValue($product, 'id_category_default'), $this->context->language->id)); $preview_url = $this->context->link->getProductLink($product, $this->getFieldValue($product, 'link_rewrite', $this->default_form_language), Category::getLinkRewrite($this->getFieldValue($product, 'id_category_default'), $this->context->language->id));
@@ -2195,7 +2195,7 @@ class AdminProductsControllerCore extends AdminController
{ {
if (Validate::isLoadedObject(($product = new Product((int)Tools::getValue('id_product'))))) if (Validate::isLoadedObject(($product = new Product((int)Tools::getValue('id_product')))))
{ {
$id_shop = $this->context->shop->getID(); $id_shop = $this->context->shop->id;
// If zone still exist, then update the database with the new value // If zone still exist, then update the database with the new value
if (count($zones = Zone::getZones())) if (count($zones = Zone::getZones()))
@@ -2466,7 +2466,7 @@ class AdminProductsControllerCore extends AdminController
else else
{ {
$zones = Zone::getZones(); $zones = Zone::getZones();
$id_shop = $this->context->shop->getID(); $id_shop = $this->context->shop->id;
// Set default zone value to the shop and sort it // Set default zone value to the shop and sort it
foreach ($zones as $zone) foreach ($zones as $zone)
@@ -3468,7 +3468,7 @@ class AdminProductsControllerCore extends AdminController
else else
{ {
// if quantities are shared between shops of the group, it's not possible to manage them for a given shop // if quantities are shared between shops of the group, it's not possible to manage them for a given shop
if ($group_shop->share_stock && $group_shop->getTotalShops() > 1) if ($group_shop->share_stock)
$show_quantities = false; $show_quantities = false;
} }
@@ -3830,7 +3830,7 @@ class AdminProductsControllerCore extends AdminController
{ {
$id_module = Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = \''.pSQL($this->tab_display_module).'\''); $id_module = Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = \''.pSQL($this->tab_display_module).'\'');
$this->tpl_form_vars['custom_form'] = Hook::exec('displayAdminProductsExtra', array(), (int)$id_module); $this->tpl_form_vars['custom_form'] = Hook::exec('displayAdminProductsExtra', array(), (int)$id_module);
} }
+6 -6
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -467,7 +467,7 @@ class AdminThemesControllerCore extends AdminController
*/ */
public function updateOptionPsLogo() public function updateOptionPsLogo()
{ {
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->id;
if (isset($_FILES['PS_LOGO']['tmp_name']) && $_FILES['PS_LOGO']['tmp_name']) if (isset($_FILES['PS_LOGO']['tmp_name']) && $_FILES['PS_LOGO']['tmp_name'])
{ {
if ($error = ImageManager::validateUpload($_FILES['PS_LOGO'], 300000)) if ($error = ImageManager::validateUpload($_FILES['PS_LOGO'], 300000))
@@ -494,7 +494,7 @@ class AdminThemesControllerCore extends AdminController
*/ */
public function updateOptionPsLogoMail() public function updateOptionPsLogoMail()
{ {
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->id;
if (isset($_FILES['PS_LOGO_MAIL']['tmp_name']) && $_FILES['PS_LOGO_MAIL']['tmp_name']) if (isset($_FILES['PS_LOGO_MAIL']['tmp_name']) && $_FILES['PS_LOGO_MAIL']['tmp_name'])
{ {
if ($error = ImageManager::validateUpload($_FILES['PS_LOGO_MAIL'], 300000)) if ($error = ImageManager::validateUpload($_FILES['PS_LOGO_MAIL'], 300000))
@@ -520,7 +520,7 @@ class AdminThemesControllerCore extends AdminController
*/ */
public function updateOptionPsLogoInvoice() public function updateOptionPsLogoInvoice()
{ {
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->id;
if (isset($_FILES['PS_LOGO_INVOICE']['tmp_name']) && $_FILES['PS_LOGO_INVOICE']['tmp_name']) if (isset($_FILES['PS_LOGO_INVOICE']['tmp_name']) && $_FILES['PS_LOGO_INVOICE']['tmp_name'])
{ {
if ($error = ImageManager::validateUpload($_FILES['PS_LOGO_INVOICE'], 300000)) if ($error = ImageManager::validateUpload($_FILES['PS_LOGO_INVOICE'], 300000))
@@ -546,7 +546,7 @@ class AdminThemesControllerCore extends AdminController
*/ */
public function updateOptionPsStoresIcon() public function updateOptionPsStoresIcon()
{ {
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->id;
if (isset($_FILES['PS_STORES_ICON']['tmp_name']) && $_FILES['PS_STORES_ICON']['tmp_name']) if (isset($_FILES['PS_STORES_ICON']['tmp_name']) && $_FILES['PS_STORES_ICON']['tmp_name'])
{ {
if ($error = ImageManager::validateUpload($_FILES['PS_STORES_ICON'], 300000)) if ($error = ImageManager::validateUpload($_FILES['PS_STORES_ICON'], 300000))
@@ -572,7 +572,7 @@ class AdminThemesControllerCore extends AdminController
*/ */
public function updateOptionPsFavicon() public function updateOptionPsFavicon()
{ {
$id_shop = Context::getContext()->shop->getID(); $id_shop = Context::getContext()->shop->id;
if ($id_shop == Configuration::get('PS_SHOP_DEFAULT')) if ($id_shop == Configuration::get('PS_SHOP_DEFAULT'))
$this->uploadIco('PS_FAVICON', _PS_IMG_DIR_.'favicon.ico'); $this->uploadIco('PS_FAVICON', _PS_IMG_DIR_.'favicon.ico');
if ($this->uploadIco('PS_FAVICON', _PS_IMG_DIR_.'favicon-'.(int)$id_shop.'.ico')) if ($this->uploadIco('PS_FAVICON', _PS_IMG_DIR_.'favicon-'.(int)$id_shop.'.ico'))
+6 -6
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -72,7 +72,7 @@ class ContactControllerCore extends FrontController
$id_customer_thread = (int)Tools::getValue('id_customer_thread') $id_customer_thread = (int)Tools::getValue('id_customer_thread')
&& (int)Db::getInstance()->getValue(' && (int)Db::getInstance()->getValue('
SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm
WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->getID(true).' AND token = \''.pSQL(Tools::getValue('token')).'\'') WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->id.' AND token = \''.pSQL(Tools::getValue('token')).'\'')
) || ( ) || (
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, (int)Tools::getValue('id_order')) $id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, (int)Tools::getValue('id_order'))
))) )))
@@ -80,7 +80,7 @@ class ContactControllerCore extends FrontController
$fields = Db::getInstance()->executeS(' $fields = Db::getInstance()->executeS('
SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email
FROM '._DB_PREFIX_.'customer_thread cm FROM '._DB_PREFIX_.'customer_thread cm
WHERE email = \''.pSQL($from).'\' AND cm.id_shop = '.(int)$this->context->shop->getID(true).' AND ('. WHERE email = \''.pSQL($from).'\' AND cm.id_shop = '.(int)$this->context->shop->id.' AND ('.
($customer->id ? 'id_customer = '.(int)($customer->id).' OR ' : '').' ($customer->id ? 'id_customer = '.(int)($customer->id).' OR ' : '').'
id_order = '.(int)(Tools::getValue('id_order')).')'); id_order = '.(int)(Tools::getValue('id_order')).')');
$score = 0; $score = 0;
@@ -107,7 +107,7 @@ class ContactControllerCore extends FrontController
$old_message = Db::getInstance()->getValue(' $old_message = Db::getInstance()->getValue('
SELECT cm.message FROM '._DB_PREFIX_.'customer_message cm SELECT cm.message FROM '._DB_PREFIX_.'customer_message cm
LEFT JOIN '._DB_PREFIX_.'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread) LEFT JOIN '._DB_PREFIX_.'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread)
WHERE cc.id_customer_thread = '.(int)($id_customer_thread).' AND cc.id_shop = '.(int)$this->context->shop->getID(true).' WHERE cc.id_customer_thread = '.(int)($id_customer_thread).' AND cc.id_shop = '.(int)$this->context->shop->id.'
ORDER BY cm.date_add DESC'); ORDER BY cm.date_add DESC');
if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8')) if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8'))
{ {
@@ -151,7 +151,7 @@ class ContactControllerCore extends FrontController
$ct = new CustomerThread(); $ct = new CustomerThread();
if (isset($customer->id)) if (isset($customer->id))
$ct->id_customer = (int)($customer->id); $ct->id_customer = (int)($customer->id);
$ct->id_shop = (int)$this->context->shop->getID(true); $ct->id_shop = (int)$this->context->shop->id;
if ($id_order = (int)Tools::getValue('id_order')) if ($id_order = (int)Tools::getValue('id_order'))
$ct->id_order = $id_order; $ct->id_order = $id_order;
if ($id_product = (int)Tools::getValue('id_product')) if ($id_product = (int)Tools::getValue('id_product'))
@@ -218,7 +218,7 @@ class ContactControllerCore extends FrontController
{ {
$customerThread = Db::getInstance()->getRow(' $customerThread = Db::getInstance()->getRow('
SELECT cm.* FROM '._DB_PREFIX_.'customer_thread cm SELECT cm.* FROM '._DB_PREFIX_.'customer_thread cm
WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->getID(true).' AND token = \''.pSQL($token).'\''); WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->id.' AND token = \''.pSQL($token).'\'');
$this->context->smarty->assign('customerThread', $customerThread); $this->context->smarty->assign('customerThread', $customerThread);
} }
$this->context->smarty->assign(array('contacts' => Contact::getContacts($this->context->language->id), $this->context->smarty->assign(array('contacts' => Contact::getContacts($this->context->language->id),
+2 -2
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -105,7 +105,7 @@ class ManufacturerControllerCore extends FrontController
{ {
if (Configuration::get('PS_DISPLAY_SUPPLIERS')) if (Configuration::get('PS_DISPLAY_SUPPLIERS'))
{ {
$id_current_group_shop = $this->context->shop->getGroupID(); $id_current_group_shop = Shop::getContextGroupShopID();
$data = Manufacturer::getManufacturers(true, $this->context->language->id, true, false, false, false, $id_current_group_shop); $data = Manufacturer::getManufacturers(true, $this->context->language->id, true, false, false, false, $id_current_group_shop);
$nbProducts = count($data); $nbProducts = count($data);
$this->pagination($nbProducts); $this->pagination($nbProducts);
+2 -2
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -73,7 +73,7 @@ class OrderDetailControllerCore extends FrontController
$ct = new CustomerThread(); $ct = new CustomerThread();
$ct->id_contact = 0; $ct->id_contact = 0;
$ct->id_customer = (int)$order->id_customer; $ct->id_customer = (int)$order->id_customer;
$ct->id_shop = (int)$this->context->shop->getId(true); $ct->id_shop = (int)$this->context->shop->id;
if ($id_product = (int)Tools::getValue('id_product') && $order->orderContainProduct((int)$id_product)) if ($id_product = (int)Tools::getValue('id_product') && $order->orderContainProduct((int)$id_product))
$ct->id_product = $id_product; $ct->id_product = $id_product;
$ct->id_order = (int)$order->id; $ct->id_order = (int)$order->id;
+2 -2
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2012 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -260,7 +260,7 @@ class ProductControllerCore extends FrontController
$id_currency = (int)$this->context->cookie->id_currency; $id_currency = (int)$this->context->cookie->id_currency;
$id_product = (int)$this->product->id; $id_product = (int)$this->product->id;
$id_shop = $this->context->shop->getID(true); $id_shop = $this->context->shop->id;
$quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true); $quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true);
foreach ($quantity_discounts as &$quantity_discount) foreach ($quantity_discounts as &$quantity_discount)
@@ -67,7 +67,7 @@ class BlockAdvertising extends Module
$this->displayName = $this->l('Block advertising'); $this->displayName = $this->l('Block advertising');
$this->description = $this->l('Adds a block to display an advertisement.'); $this->description = $this->l('Adds a block to display an advertisement.');
if ($this->context->shop->getContextType() == Shop::CONTEXT_SHOP) if (Shop::getContext() == Shop::CONTEXT_SHOP)
{ {
if (defined('_PS_ADMIN_DIR_') || file_exists(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'-'.(int)$this->context->shop->id.'.'.Configuration::get('BLOCKADVERT_IMG_EXT'))) if (defined('_PS_ADMIN_DIR_') || file_exists(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'-'.(int)$this->context->shop->id.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
{ {
+4 -4
View File
@@ -156,7 +156,7 @@ class BlockCategories extends Module
public function hookLeftColumn($params) public function hookLeftColumn($params)
{ {
$id_current_shop = $this->context->shop->getID(); $id_current_shop = $this->context->shop->id;
$id_customer = (int)($params['cookie']->id_customer); $id_customer = (int)($params['cookie']->id_customer);
// Get all groups for this customer and concatenate them as a string: "1,2,3..." // Get all groups for this customer and concatenate them as a string: "1,2,3..."
@@ -176,7 +176,7 @@ class BlockCategories extends Module
FROM `'._DB_PREFIX_.'category` c FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').') LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`) LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category` AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true).') LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category` AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.')
WHERE (c.`active` = 1 OR c.`id_category` = 1) WHERE (c.`active` = 1 OR c.`id_category` = 1)
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').' '.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
AND cg.`id_group` IN ('.pSQL($groups).') AND cg.`id_group` IN ('.pSQL($groups).')
@@ -191,7 +191,7 @@ class BlockCategories extends Module
WHERE (c.`active` = 1 OR c.`id_category` = 1) WHERE (c.`active` = 1 OR c.`id_category` = 1)
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').' '.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
AND cg.`id_group` IN ('.pSQL($groups).') AND cg.`id_group` IN ('.pSQL($groups).')
AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true).' AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
GROUP BY id_category GROUP BY id_category
ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'))) ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC')))
@@ -241,7 +241,7 @@ class BlockCategories extends Module
public function hookFooter($params) public function hookFooter($params)
{ {
$id_current_shop = $this->context->shop->getID(); $id_current_shop = $this->context->shop->id;
$id_customer = (int)($params['cookie']->id_customer); $id_customer = (int)($params['cookie']->id_customer);
// Get all groups for this customer and concatenate them as a string: "1,2,3..." // Get all groups for this customer and concatenate them as a string: "1,2,3..."
+5 -5
View File
@@ -258,7 +258,7 @@ class BlockCMSModel extends ObjectModel
public static function getCMSTitlesFooter() public static function getCMSTitlesFooter()
{ {
$context = Context::getContext(); $context = Context::getContext();
$footerCms = Configuration::get('FOOTER_CMS', null, $context->shop->getGroupID(), $context->shop->getID()); $footerCms = Configuration::get('FOOTER_CMS');
if (empty($footerCms)) if (empty($footerCms))
return array(); return array();
@@ -339,7 +339,7 @@ class BlockCMSModel extends ObjectModel
WHERE bc.`location` = '.(int)($location).' WHERE bc.`location` = '.(int)($location).'
AND ccl.`id_lang` = '.(int)$context->language->id.' AND ccl.`id_lang` = '.(int)$context->language->id.'
AND bcl.`id_lang` = '.(int)$context->language->id.' AND bcl.`id_lang` = '.(int)$context->language->id.'
AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->getID()).' AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->id).'
ORDER BY `position`'; ORDER BY `position`';
return Db::getInstance()->executeS($sql); return Db::getInstance()->executeS($sql);
@@ -347,7 +347,7 @@ class BlockCMSModel extends ObjectModel
public static function getCMSPages($id_cms_category, $id_shop = false) public static function getCMSPages($id_cms_category, $id_shop = false)
{ {
$id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->getID(); $id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id;
$sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite` $sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
FROM `'._DB_PREFIX_.'cms` c FROM `'._DB_PREFIX_.'cms` c
@@ -467,7 +467,7 @@ class BlockCMSModel extends ObjectModel
WHERE ccl.`id_lang` = '.(int)Context::getContext()->language->id.' WHERE ccl.`id_lang` = '.(int)Context::getContext()->language->id.'
AND bcl.`id_lang` = '.(int)Context::getContext()->language->id.' AND bcl.`id_lang` = '.(int)Context::getContext()->language->id.'
AND bc.`location` = '.(int)$location.' AND bc.`location` = '.(int)$location.'
AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->getID()).' AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->id).'
ORDER BY bc.`position`'; ORDER BY bc.`position`';
return Db::getInstance()->executeS($sql); return Db::getInstance()->executeS($sql);
@@ -493,7 +493,7 @@ class BlockCMSModel extends ObjectModel
public static function getAllCMSStructure($id_shop = false) public static function getAllCMSStructure($id_shop = false)
{ {
$categories = BlockCMSModel::getCMSCategories(); $categories = BlockCMSModel::getCMSCategories();
$id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->getID(); $id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id;
foreach ($categories as $key => $value) foreach ($categories as $key => $value)
$categories[$key]['cms_pages'] = BlockCMSModel::getCMSPages($value['id_cms_category'], $id_shop); $categories[$key]['cms_pages'] = BlockCMSModel::getCMSPages($value['id_cms_category'], $id_shop);
+15 -18
View File
@@ -55,9 +55,9 @@ class BlockCms extends Module
if (!parent::install() || if (!parent::install() ||
!$this->registerHooks() || !$this->registerHooks() ||
!BlockCMSModel::createTables() || !BlockCMSModel::createTables() ||
!Configuration::updateValue('FOOTER_CMS', '', false, $this->context->shop->getGroupID(), $this->context->shop->getID()) || !Configuration::updateValue('FOOTER_CMS', '') ||
!Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1, false, $this->context->shop->getGroupID(), $this->context->shop->getID()) || !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) ||
!Configuration::updateValue('FOOTER_POWEREDBY', 1, false, $this->context->shop->getGroupID(), $this->context->shop->getID())) !Configuration::updateValue('FOOTER_POWEREDBY', 1))
return false; return false;
// Install fixtures for blockcms // Install fixtures for blockcms
@@ -244,19 +244,19 @@ class BlockCms extends Module
); );
$this->context->controller->getLanguages(); $this->context->controller->getLanguages();
$tmp = Configuration::get('FOOTER_CMS', null, $this->context->shop->getGroupID(), $this->context->shop->getID()); $tmp = Configuration::get('FOOTER_CMS');
$footer_boxes = explode('|', $tmp); $footer_boxes = explode('|', $tmp);
if ($footer_boxes && is_array($footer_boxes)) if ($footer_boxes && is_array($footer_boxes))
foreach ($footer_boxes as $key => $value) foreach ($footer_boxes as $key => $value)
$this->fields_value[$value] = true; $this->fields_value[$value] = true;
$this->fields_value['cms_footer_on'] = Configuration::get('FOOTER_BLOCK_ACTIVATION', null, $this->context->shop->getGroupID(), $this->context->shop->getID()); $this->fields_value['cms_footer_on'] = Configuration::get('FOOTER_BLOCK_ACTIVATION');
$this->fields_value['cms_footer_powered_by_on'] = Configuration::get('FOOTER_POWEREDBY', null, $this->context->shop->getGroupID(), $this->context->shop->getID()); $this->fields_value['cms_footer_powered_by_on'] = Configuration::get('FOOTER_POWEREDBY');
foreach ($this->context->controller->_languages as $language) foreach ($this->context->controller->_languages as $language)
{ {
$footer_text = Configuration::get('FOOTER_CMS_TEXT_'.$language['id_lang'], null, $this->context->shop->getGroupID(), $this->context->shop->getID()); $footer_text = Configuration::get('FOOTER_CMS_TEXT_'.$language['id_lang']);
$this->fields_value['footer_text'][$language['id_lang']] = $footer_text; $this->fields_value['footer_text'][$language['id_lang']] = $footer_text;
} }
@@ -556,7 +556,7 @@ class BlockCms extends Module
foreach ($this->context->controller->_languages as $language) foreach ($this->context->controller->_languages as $language)
BlockCMSModel::insertCMSBlockLang($id_cms_block, $language['id_lang']); BlockCMSModel::insertCMSBlockLang($id_cms_block, $language['id_lang']);
BlockCMSModel::insertCMSBlockShop($id_cms_block, $this->context->shop->getGroupID(), $this->context->shop->getID()); BlockCMSModel::insertCMSBlockShop($id_cms_block, Shop::getContextGroupShopID(), Shop::getContextShopID());
} }
$this->_errors[] = $this->l('New block cannot be created !'); $this->_errors[] = $this->l('New block cannot be created !');
@@ -622,9 +622,9 @@ class BlockCms extends Module
$footer_boxes = Tools::getValue('footerBox') ? implode('|', Tools::getValue('footerBox')) : ''; $footer_boxes = Tools::getValue('footerBox') ? implode('|', Tools::getValue('footerBox')) : '';
$block_activation = (Tools::getValue('cms_footer_on') == 1) ? 1 : 0; $block_activation = (Tools::getValue('cms_footer_on') == 1) ? 1 : 0;
Configuration::updateValue('FOOTER_CMS', rtrim($footer_boxes, '|'), false, $this->context->shop->getGroupID(), $this->context->shop->getID()); Configuration::updateValue('FOOTER_CMS', rtrim($footer_boxes, '|'));
Configuration::updateValue('FOOTER_POWEREDBY', $powered_by, false, $this->context->shop->getGroupID(), $this->context->shop->getID()); Configuration::updateValue('FOOTER_POWEREDBY', $powered_by);
Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', $block_activation, false, $this->context->shop->getGroupID(), $this->context->shop->getID()); Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', $block_activation);
$this->_html .= $this->displayConfirmation($this->l('Footer\'s informations updated')); $this->_html .= $this->displayConfirmation($this->l('Footer\'s informations updated'));
} }
@@ -688,17 +688,14 @@ class BlockCms extends Module
public function hookFooter() public function hookFooter()
{ {
$context = Context::getContext(); $block_activation = Configuration::get('FOOTER_BLOCK_ACTIVATION');
$shop_id = $context->shop->getID();
$shop_group_id = $context->shop->getGroupID();
$block_activation = Configuration::get('FOOTER_BLOCK_ACTIVATION', null, $shop_group_id, $shop_id);
if ($block_activation) if ($block_activation)
{ {
$cms_titles = BlockCMSModel::getCMSTitlesFooter(); $cms_titles = BlockCMSModel::getCMSTitlesFooter();
$display_footer = Configuration::get('PS_STORES_DISPLAY_FOOTER', null, $shop_group_id, $shop_id); $display_footer = Configuration::get('PS_STORES_DISPLAY_FOOTER');
$display_poweredby = Configuration::get('FOOTER_POWEREDBY', null, $shop_group_id, $shop_id); $display_poweredby = Configuration::get('FOOTER_POWEREDBY');
$footer_text = Configuration::get('FOOTER_CMS_TEXT_'.(int)$context->language->id); $footer_text = Configuration::get('FOOTER_CMS_TEXT_'.(int)$this->context->language->id);
$this->smarty->assign( $this->smarty->assign(
array( array(
+1 -1
View File
@@ -57,7 +57,7 @@ class BlockLanguages extends Module
*/ */
public function hookTop($params) public function hookTop($params)
{ {
$languages = Language::getLanguages(true, $this->context->shop->getID()); $languages = Language::getLanguages(true, $this->context->shop->id);
if (!count($languages)) if (!count($languages))
return; return;
$link = new Link(); $link = new Link();
+6 -6
View File
@@ -1327,7 +1327,7 @@ class BlockLayered extends Module
} }
} }
else else
$shop_list = array(Context::getContext()->shop->getID(true)); $shop_list = array(Context::getContext()->shop->id);
} }
else else
$shop_list = array(0); $shop_list = array(0);
@@ -2221,7 +2221,7 @@ class BlockLayered extends Module
if (version_compare(_PS_VERSION_,'1.5','>')) if (version_compare(_PS_VERSION_,'1.5','>'))
{ {
$queryFiltersWhere .= ' AND sa.quantity '.(!$selectedFilters['quantity'][0] ? '<=' : '>').' 0 '; $queryFiltersWhere .= ' AND sa.quantity '.(!$selectedFilters['quantity'][0] ? '<=' : '>').' 0 ';
$queryFiltersFrom .= 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sa ON (sa.id_product = p.id_product AND sa.id_shop = '.(int)Context::getContext()->shop->getID(true).') '; $queryFiltersFrom .= 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sa ON (sa.id_product = p.id_product AND sa.id_shop = '.(int)Context::getContext()->shop->id.') ';
} }
else else
$queryFiltersWhere .= ' AND p.quantity '.(!$selectedFilters['quantity'][0] ? '<=' : '>').' 0 '; $queryFiltersWhere .= ' AND p.quantity '.(!$selectedFilters['quantity'][0] ? '<=' : '>').' 0 ';
@@ -2376,7 +2376,7 @@ class BlockLayered extends Module
$parent = new Category((int)$id_parent); $parent = new Category((int)$id_parent);
if (version_compare(_PS_VERSION_,'1.5','>')) if (version_compare(_PS_VERSION_,'1.5','>'))
$id_shop = (int) Context::getContext()->shop->getId(true); $id_shop = (int) Context::getContext()->shop->id;
else else
$id_shop = 0; $id_shop = 0;
@@ -2426,7 +2426,7 @@ class BlockLayered extends Module
AND c.active = 1) '; AND c.active = 1) ';
if (version_compare(_PS_VERSION_,'1.5','>')) if (version_compare(_PS_VERSION_,'1.5','>'))
$sqlQuery['join'] .= 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sa $sqlQuery['join'] .= 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sa
ON (sa.id_product = p.id_product AND sa.id_shop = '.(int)$this->context->shop->getID(true).') '; ON (sa.id_product = p.id_product AND sa.id_shop = '.(int)$this->context->shop->id.') ';
$sqlQuery['where'] = 'WHERE p.`active` = 1 '; $sqlQuery['where'] = 'WHERE p.`active` = 1 ';
$sqlQuery['group'] = ' GROUP BY p.id_product '; $sqlQuery['group'] = ' GROUP BY p.id_product ';
break; break;
@@ -3176,7 +3176,7 @@ class BlockLayered extends Module
if (version_compare(_PS_VERSION_,'1.5','>')) if (version_compare(_PS_VERSION_,'1.5','>'))
{ {
$queryFilters = ' AND sav.quantity '.(!$filterValue[0] ? '<=' : '>').' 0 '; $queryFilters = ' AND sav.quantity '.(!$filterValue[0] ? '<=' : '>').' 0 ';
$queryFiltersJoin = 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sav ON (sav.id_product = p.id_product AND sav.id_shop = '.(int)Context::getContext()->shop->getID(true).') '; $queryFiltersJoin = 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sav ON (sav.id_product = p.id_product AND sav.id_shop = '.(int)Context::getContext()->shop->id.') ';
} }
else else
$queryFilters = ' AND p.quantity '.(!$filterValue[0] ? '<=' : '>').' 0 '; $queryFilters = ' AND p.quantity '.(!$filterValue[0] ? '<=' : '>').' 0 ';
@@ -3543,7 +3543,7 @@ class BlockLayered extends Module
if (version_compare(_PS_VERSION_,'1.5','>') && !empty($id_layered_filter)) if (version_compare(_PS_VERSION_,'1.5','>') && !empty($id_layered_filter))
{ {
if (Shop::isFeatureActive() && $this->context->shop->getContextType() != Shop::CONTEXT_ALL) if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL)
{ {
$helper = new HelperForm(); $helper = new HelperForm();
$helper->id = (int)$id_layered_filter; $helper->id = (int)$id_layered_filter;
+7 -7
View File
@@ -164,7 +164,7 @@ class Blocknewsletter extends Module
$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->id;
if (Db::getInstance()->getRow($sql)) if (Db::getInstance()->getRow($sql))
return self::GUEST_REGISTERED; return self::GUEST_REGISTERED;
@@ -172,7 +172,7 @@ class Blocknewsletter extends Module
$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->id;
if (!$registered = Db::getInstance()->getRow($sql)) if (!$registered = Db::getInstance()->getRow($sql))
return self::GUEST_NOT_REGISTERED; return self::GUEST_NOT_REGISTERED;
@@ -199,13 +199,13 @@ class Blocknewsletter extends Module
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->id))
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->id))
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');
} }
@@ -298,7 +298,7 @@ class Blocknewsletter extends Module
$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->id;
return Db::getInstance()->execute($sql); return Db::getInstance()->execute($sql);
} }
@@ -314,8 +314,8 @@ class Blocknewsletter extends Module
{ {
$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->id.',
'.$this->context->shop->getGroupID().', '.$this->context->shop->id_group_shop.',
\''.pSQL($email).'\', \''.pSQL($email).'\',
NOW(), NOW(),
\''.pSQL(Tools::getRemoteAddr()).'\', \''.pSQL(Tools::getRemoteAddr()).'\',
+1 -1
View File
@@ -86,7 +86,7 @@ class BlockStore extends Module
return $this->displayError($this->l('an error occurred on uploading file')); return $this->displayError($this->l('an error occurred on uploading file'));
else else
{ {
if (Configuration::hasContext('BLOCKSTORE_IMG', null, $this->context->shop->getContextType()) && Configuration::get('BLOCKSTORE_IMG') != $_FILES['store_img']['name']) if (Configuration::hasContext('BLOCKSTORE_IMG', null, Shop::getContext()) && Configuration::get('BLOCKSTORE_IMG') != $_FILES['store_img']['name'])
@unlink(dirname(__FILE__).'/'.Configuration::get('BLOCKSTORE_IMG')); @unlink(dirname(__FILE__).'/'.Configuration::get('BLOCKSTORE_IMG'));
Configuration::updateValue('BLOCKSTORE_IMG', $_FILES['store_img']['name']); Configuration::updateValue('BLOCKSTORE_IMG', $_FILES['store_img']['name']);
return $this->displayConfirmation($this->l('Settings are updated')); return $this->displayConfirmation($this->l('Settings are updated'));
+2 -2
View File
@@ -127,7 +127,7 @@ class blocktopmenu extends Module
$this->_html .= ' $this->_html .= '
<fieldset> <fieldset>
<div class="multishop_info"> <div class="multishop_info">
'.$this->l('The modifications will be applied to').' '.(Context::shop() == Shop::CONTEXT_SHOP ? $this->l('shop:').' '.$this->context->shop->name : $this->l('all shops')).'. '.$this->l('The modifications will be applied to').' '.(Shop::getContext() == Shop::CONTEXT_SHOP ? $this->l('shop:').' '.$this->context->shop->name : $this->l('all shops')).'.
</div> </div>
<legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend> <legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" id="form"> <form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" id="form">
@@ -334,7 +334,7 @@ class blocktopmenu extends Module
foreach ($items as $item) foreach ($items as $item)
{ {
$id = (int)substr($item, 3, strlen($item)); $id = (int)substr($item, 3, strlen($item));
$disabled = ((Context::shop() == Shop::CONTEXT_SHOP && $type == 'global') ? ' disabled="disabled"': ''); $disabled = ((Shop::getContext() == Shop::CONTEXT_SHOP && $type == 'global') ? ' disabled="disabled"': '');
switch(substr($item, 0, 3)) switch(substr($item, 0, 3))
{ {
case'CAT': case'CAT':
+2 -2
View File
@@ -87,7 +87,7 @@ class FavoriteProduct extends ObjectModel
FROM `'._DB_PREFIX_.'favorite_product` FROM `'._DB_PREFIX_.'favorite_product`
WHERE `id_customer` = '.(int)$id_customer.' WHERE `id_customer` = '.(int)$id_customer.'
AND `id_product` = '.(int)$id_product.' AND `id_product` = '.(int)$id_product.'
AND `id_shop` = '.(int)$shop->getID(true) AND `id_shop` = '.(int)$shop->id
); );
if ($id_favorite_product) if ($id_favorite_product)
@@ -105,6 +105,6 @@ class FavoriteProduct extends ObjectModel
FROM `'._DB_PREFIX_.'favorite_product` FROM `'._DB_PREFIX_.'favorite_product`
WHERE `id_customer` = '.(int)$id_customer.' WHERE `id_customer` = '.(int)$id_customer.'
AND `id_product` = '.(int)$id_product.' AND `id_product` = '.(int)$id_product.'
AND `id_shop` = '.(int)$shop->getID(true)); AND `id_shop` = '.(int)$shop->id);
} }
} }
@@ -80,7 +80,7 @@ class FavoriteproductsActionsModuleFrontController extends ModuleFrontController
$favorite_product = new FavoriteProduct(); $favorite_product = new FavoriteProduct();
$favorite_product->id_product = $product->id; $favorite_product->id_product = $product->id;
$favorite_product->id_customer = (int)Context::getContext()->cookie->id_customer; $favorite_product->id_customer = (int)Context::getContext()->cookie->id_customer;
$favorite_product->id_shop = (int)Context::getContext()->shop->getID(true); $favorite_product->id_shop = (int)Context::getContext()->shop->id;
if ($favorite_product->add()) if ($favorite_product->add())
die('0'); die('0');
die(1); die(1);
@@ -56,7 +56,7 @@ if (Tools::getValue('action') && Tools::getValue('id_product') && Context::getCo
$favorite_product = new FavoriteProduct(); $favorite_product = new FavoriteProduct();
$favorite_product->id_product = $product->id; $favorite_product->id_product = $product->id;
$favorite_product->id_customer = (int)Context::getContext()->cookie->id_customer; $favorite_product->id_customer = (int)Context::getContext()->cookie->id_customer;
$favorite_product->id_shop = (int)Context::getContext()->shop->getID(); $favorite_product->id_shop = (int)Context::getContext()->shop->id;
if ($favorite_product->add()) if ($favorite_product->add())
die('0'); die('0');
} }
+2 -2
View File
@@ -63,7 +63,7 @@ class HomeSlide extends ObjectModel
public function add($autodate = true, $null_values = false) public function add($autodate = true, $null_values = false)
{ {
$context = Context::getContext(); $context = Context::getContext();
$id_shop = $context->shop->getID(); $id_shop = $context->shop->id;
$res = parent::add($autodate, $null_values); $res = parent::add($autodate, $null_values);
$res &= Db::getInstance()->execute(' $res &= Db::getInstance()->execute('
@@ -100,7 +100,7 @@ class HomeSlide extends ObjectModel
{ {
$id_slide = $this->id; $id_slide = $this->id;
$context = Context::getContext(); $context = Context::getContext();
$id_shop = $context->shop->getID(); $id_shop = $context->shop->id;
$max = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' $max = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT MAX(hss.`position`) as position SELECT MAX(hss.`position`) as position
+2 -2
View File
@@ -686,7 +686,7 @@ class HomeSlider extends Module
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT MAX(hss.`position`) AS `next_position` SELECT MAX(hss.`position`) AS `next_position`
FROM `'._DB_PREFIX_.'homeslider_slides` hss, `'._DB_PREFIX_.'homeslider` hs FROM `'._DB_PREFIX_.'homeslider_slides` hss, `'._DB_PREFIX_.'homeslider` hs
WHERE hss.`id_homeslider_slides` = hs.`id_homeslider_slides` AND hs.`id_shop` = '.(int)$this->context->shop->getId() WHERE hss.`id_homeslider_slides` = hs.`id_homeslider_slides` AND hs.`id_shop` = '.(int)$this->context->shop->id
); );
return (++$row['next_position']); return (++$row['next_position']);
@@ -695,7 +695,7 @@ class HomeSlider extends Module
public function getSlides($active = null) public function getSlides($active = null)
{ {
$this->context = Context::getContext(); $this->context = Context::getContext();
$id_shop = $this->context->shop->getID(); $id_shop = $this->context->shop->id;
$id_lang = $this->context->language->id; $id_lang = $this->context->language->id;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
+1 -1
View File
@@ -174,7 +174,7 @@ class Pagesnotfound extends Module
if (empty($http_referer) || Validate::isAbsoluteUrl($http_referer)) if (empty($http_referer) || Validate::isAbsoluteUrl($http_referer))
Db::getInstance()->execute(' Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'pagenotfound` (`request_uri`, `http_referer`, `date_add`, `id_shop`, `id_group_shop`) INSERT INTO `'._DB_PREFIX_.'pagenotfound` (`request_uri`, `http_referer`, `date_add`, `id_shop`, `id_group_shop`)
VALUES (\''.pSQL($request_uri).'\', \''.pSQL($http_referer).'\', NOW(), '.$this->context->shop->getID().', '.$this->context->shop->getGroupID().') VALUES (\''.pSQL($request_uri).'\', \''.pSQL($http_referer).'\', NOW(), '.(int)$this->context->shop->id.', '.(int)$this->context->shop->id_group_shop.')
'); ');
} }
} }
+1 -1
View File
@@ -89,7 +89,7 @@ class SEKeywords extends ModuleGraph
if ($keywords = $this->getKeywords($_SERVER['HTTP_REFERER'])) if ($keywords = $this->getKeywords($_SERVER['HTTP_REFERER']))
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'sekeyword` (`keyword`, `date_add`, `id_shop`, `id_group_shop`) Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'sekeyword` (`keyword`, `date_add`, `id_shop`, `id_group_shop`)
VALUES (\''.pSQL(Tools::strtolower(trim($keywords))).'\', NOW(), '.$this->context->shop->getID().', '.$this->context->shop->getGroupID().')'); VALUES (\''.pSQL(Tools::strtolower(trim($keywords))).'\', NOW(), '.(int)$this->context->shop->id.', '.(int)$this->context->shop->id_group_shop.')');
} }
public function hookAdminStatsModules() public function hookAdminStatsModules()
@@ -123,7 +123,7 @@ class StatsBestCategories extends ModuleGrid
// If a shop is selected, get all children categories for the shop // If a shop is selected, get all children categories for the shop
$categories = array(); $categories = array();
if ($this->context->shop->getContextType() != Shop::CONTEXT_ALL) if (Shop::getContext() != Shop::CONTEXT_ALL)
{ {
$sql = 'SELECT c.nleft, c.nright $sql = 'SELECT c.nleft, c.nright
FROM '._DB_PREFIX_.'category c FROM '._DB_PREFIX_.'category c
-3
View File
@@ -96,9 +96,6 @@ class StatsCheckUp extends Module
$employee = Context::getContext()->employee; $employee = Context::getContext()->employee;
$prop30 = ((strtotime($employee->stats_date_to.' 23:59:59') - strtotime($employee->stats_date_from.' 00:00:00')) / 60 / 60 / 24) / 30; $prop30 = ((strtotime($employee->stats_date_to.' 23:59:59') - strtotime($employee->stats_date_from.' 00:00:00')) / 60 / 60 / 24) / 30;
$shopID = $this->context->shop->getID();
$shopGroupID = $this->context->shop->getGroupID();
// Get languages // Get languages
$sql = 'SELECT l.* $sql = 'SELECT l.*
FROM '._DB_PREFIX_.'lang l' FROM '._DB_PREFIX_.'lang l'
+1 -1
View File
@@ -87,7 +87,7 @@ class StatsSearch extends ModuleGraph
public function hookSearch($params) public function hookSearch($params)
{ {
$sql = 'INSERT INTO `'._DB_PREFIX_.'statssearch` (`id_shop`, `id_group_shop`, `keywords`, `results`, `date_add`) $sql = 'INSERT INTO `'._DB_PREFIX_.'statssearch` (`id_shop`, `id_group_shop`, `keywords`, `results`, `date_add`)
VALUES ('.$this->context->shop->getID(true).', '.$this->context->shop->getGroupID().', \''.pSQL($params['expr']).'\', '.(int)$params['total'].', NOW())'; VALUES ('.(int)$this->context->shop->id.', '.(int)$this->context->shop->id_group_shop.', \''.pSQL($params['expr']).'\', '.(int)$params['total'].', NOW())';
Db::getInstance()->execute($sql); Db::getInstance()->execute($sql);
} }
@@ -440,7 +440,7 @@ class ThemeInstallator extends Module
$hookedModule = array(); $hookedModule = array();
$position = array(); $position = array();
$msg = ''; $msg = '';
$shopID = $this->context->shop->getID(); $shopID = $this->context->shop->id;
foreach ($this->xml->modules->hooks->hook as $row) foreach ($this->xml->modules->hooks->hook as $row)
{ {
+4 -4
View File
@@ -128,12 +128,12 @@ class Watermark extends Module
Configuration::updateValue('WATERMARK_X_ALIGN', Tools::getValue('xalign')); Configuration::updateValue('WATERMARK_X_ALIGN', Tools::getValue('xalign'));
Configuration::updateValue('WATERMARK_TRANSPARENCY', Tools::getValue('transparency')); Configuration::updateValue('WATERMARK_TRANSPARENCY', Tools::getValue('transparency'));
if (Context::getContext()->shop->getContextType() == Shop::CONTEXT_SHOP) if (Shop::getContext() == Shop::CONTEXT_SHOP)
$str_shop = '-'.(int)$this->context->shop->id; $str_shop = '-'.(int)$this->context->shop->id;
else else
$str_shop = ''; $str_shop = '';
//submited watermark //submited watermark
if (isset($_FILES['PS_WATERMARK']) AND !empty($_FILES['PS_WATERMARK']['tmp_name'])) if (isset($_FILES['PS_WATERMARK']) && !empty($_FILES['PS_WATERMARK']['tmp_name']))
{ {
/* Check watermark validity */ /* Check watermark validity */
if ($error = ImageManager::validateUpload($_FILES['PS_WATERMARK'])) if ($error = ImageManager::validateUpload($_FILES['PS_WATERMARK']))
@@ -154,7 +154,7 @@ class Watermark extends Module
{ {
$imageTypes = ImageType::getImagesTypes('products'); $imageTypes = ImageType::getImagesTypes('products');
$str_shop = '-'.(int)$this->context->shop->id; $str_shop = '-'.(int)$this->context->shop->id;
if (Context::getContext()->shop->getContextType() != Shop::CONTEXT_SHOP || !Tools::file_exists_cache(dirname(__FILE__).'/watermark'.$str_shop.'.gif')) if (Shop::getContext() != Shop::CONTEXT_SHOP || !Tools::file_exists_cache(dirname(__FILE__).'/watermark'.$str_shop.'.gif'))
$str_shop = ''; $str_shop = '';
$this->_html .= $this->_html .=
@@ -239,7 +239,7 @@ class Watermark extends Module
$file = _PS_PROD_IMG_DIR_.$image->getExistingImgPath().'-watermark.jpg'; $file = _PS_PROD_IMG_DIR_.$image->getExistingImgPath().'-watermark.jpg';
$str_shop = '-'.(int)$this->context->shop->id; $str_shop = '-'.(int)$this->context->shop->id;
if (Context::getContext()->shop->getContextType() != Shop::CONTEXT_SHOP || !Tools::file_exists_cache(dirname(__FILE__).'/watermark'.$str_shop.'.gif')) if (Shop::getContext() != Shop::CONTEXT_SHOP || !Tools::file_exists_cache(dirname(__FILE__).'/watermark'.$str_shop.'.gif'))
$str_shop = ''; $str_shop = '';
//first make a watermark image //first make a watermark image