// Context part 10

This commit is contained in:
rMalie
2011-07-18 15:27:32 +00:00
parent bc5d36821d
commit e16a8ab8d3
24 changed files with 375 additions and 304 deletions
+2 -1
View File
@@ -95,4 +95,5 @@ $context->link = $link;
$context->language = $language;
$context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$context->country = $defaultCountry;
$context->shop = new Shop(Shop::getContext('shop', true));
$context->smarty = $smarty;
$context->shop = new Shop(Shop::getContextID());
+7 -7
View File
@@ -52,20 +52,20 @@ class AdminCatalog extends AdminTab
$id_category = abs(Tools::getValue('id_category'));
$shop = Context::getContext()->shop;
if (!$id_category)
$id_category = $shop->id_category;
else if ($id_category != $shop->id_category)
$id_category = $shop->getCategory();
else if ($id_category != $shop->getCategory())
{
// Check if current category is "inside" shop default category
$sql = 'SELECT nleft, nright FROM '._DB_PREFIX_.'category
WHERE id_category = '.$shop->id_category;
if ($interval = Category::getInterval($shop->id_category))
WHERE id_category = '.$shop->getCategory();
if ($interval = Category::getInterval($shop->getCategory()))
{
$sql = 'SELECT id_category FROM '._DB_PREFIX_.'category
WHERE id_category = '.(int)$id_category.'
AND nleft >= '.$interval['nleft'].'
AND nright <= '.$interval['nright'];
if (!Db::getInstance()->getValue($sql))
$id_category = $shop->id_category;
$id_category = $shop->getCategory();
}
}
@@ -139,7 +139,7 @@ class AdminCatalog extends AdminTab
if (((Tools::isSubmit('submitAddcategory') OR Tools::isSubmit('submitAddcategoryAndStay')) AND sizeof($this->adminCategories->_errors)) OR isset($_GET['updatecategory']) OR isset($_GET['addcategory']))
{
$this->adminCategories->displayForm($this->token);
echo '<br /><br /><a href="'.self::currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
echo '<br /><br /><a href="'.self::$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
}
elseif (((Tools::isSubmit('submitAddproduct') OR Tools::isSubmit('submitAddproductAndPreview') OR Tools::isSubmit('submitAddproductAndStay') OR Tools::isSubmit('submitSpecificPricePriorities') OR Tools::isSubmit('submitPriceAddition') OR Tools::isSubmit('submitPricesModification')) AND sizeof($this->adminProducts->_errors)) OR Tools::isSubmit('updateproduct') OR Tools::isSubmit('addproduct'))
{
@@ -174,7 +174,7 @@ class AdminCatalog extends AdminTab
if (!$id_category)
{
$home = true;
$id_category = Context::getContext()->shop->id_category;
$id_category = Context::getContext()->shop->getCategory();
}
$catalog_tabs = array('category', 'product');
// Cleaning links
+3 -3
View File
@@ -75,7 +75,7 @@ class AdminCategories extends AdminTab
{
$context = Context::getContext();
$this->getList((int)($context->language->id), !$context->cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$context->cookie->__get($this->table.'Orderway') ? 'ASC' : NULL, 0, NULL, $context->shop->getID());
$this->getList((int)($context->language->id), !$context->cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$context->cookie->__get($this->table.'Orderway') ? 'ASC' : NULL, 0, NULL, $context->shop->getID(true));
echo '<h3>'.(!$this->_listTotal ? ($this->l('There are no subcategories')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('subcategories') : $this->l('subcategory')))).' '.$this->l('in category').' "'.stripslashes($this->_category->getName()).'"</h3>';
if ($this->tabAccess['add'] === '1')
echo '<a href="'.__PS_BASE_URI__.substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)).'?tab=AdminCatalog&add'.$this->table.'&id_parent='.$this->_category->id.'&token='.($token!=NULL ? $token : $this->token).'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add a new subcategory').'</a>';
@@ -93,7 +93,7 @@ class AdminCategories extends AdminTab
{
if ($id_category = (int)(Tools::getValue('id_category')))
{
if (!Category::checkBeforeMove($id_category, $this->_category->id))
if (!Category::checkBeforeMove($id_category, $this->_category->id_parent))
{
$this->_errors[] = Tools::displayError('Category cannot be moved here');
return false;
@@ -221,7 +221,7 @@ class AdminCategories extends AdminTab
$active = $this->getFieldValue($obj, 'active');
$customer_groups = $obj->getGroups();
if ($context->shop->getContextType() == Shop::CONTEXT_SHOP)
$id_category = $context->shop->id_category;
$id_category = $context->shop->getCategory();
else
$id_category = (int)Tools::getValue('id_parent');
+1 -1
View File
@@ -366,7 +366,7 @@ class AdminPreferences extends AdminTab
echo '<div class="margin-form" style="padding-top:5px;">';
}
$isDisabled = (isset($field['visibility']) && $field['visibility'] > $context->shop->getContextType()) ? true : false;
$isDisabled = (Tools::isMultiShopActivated() && isset($field['visibility']) && $field['visibility'] > $context->shop->getContextType()) ? true : false;
/* Display the appropriate input type for each field */
switch ($field['type'])
+13 -12
View File
@@ -59,14 +59,14 @@ class AdminProducts extends AdminTab
/* Join categories table */
$this->_category = AdminCatalog::getCurrentCategory();
$this->_join = '
LEFT JOIN '._DB_PREFIX_.'stock stock ON stock.id_product = a.id_product AND stock.id_product_attribute = 0 '.Shop::sqlSharedStock('stock').'
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product` AND i.`cover` = 1)
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (a.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)$context->country->id.' AND tr.`id_state` = 0)
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)';
$this->_join = Product::sqlStock('a').'
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product` AND i.`cover` = 1)
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (a.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)$context->country->id.' AND tr.`id_state` = 0)
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)';
$this->_filter = 'AND cp.`id_category` = '.(int)($this->_category->id);
$this->_select = 'cp.`position`, i.`id_image`, (a.`price` * ((100 + (t.`rate`))/100)) AS price_final, stock.quantity AS quantity';
$this->_select = 'cp.`position`, i.`id_image`, (a.`price` * ((100 + (t.`rate`))/100)) AS price_final, SUM(stock.quantity) AS quantity';
$this->_group = 'GROUP BY stock.id_product';
parent::__construct();
}
@@ -1395,11 +1395,12 @@ class AdminProducts extends AdminTab
public function display($token = NULL)
{
$context = Context::getContext();
$id_shop = $context->shop->getID();
if (($id_category = (int)Tools::getValue('id_category')))
$currentIndex .= '&id_category='.$id_category;
$this->getList($context->language->id, !$context->cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$context->cookie->__get($this->table.'Orderway') ? 'ASC' : NULL, 0, NULL, $id_shop);
$id_category = (Tools::getValue('id_category',1));
if ($id_category = (int)Tools::getValue('id_category'))
AdminTab::$currentIndex .= '&id_category='.$id_category;
$this->getList($context->language->id, !$context->cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$context->cookie->__get($this->table.'Orderway') ? 'ASC' : NULL, 0, NULL, $context->shop->getID(true));
$id_category = Tools::getValue('id_category', 1);
if (!$id_category)
$id_category = 1;
echo '<h3>'.(!$this->_listTotal ? ($this->l('No products found')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('products') : $this->l('product')))).' '.
+2 -2
View File
@@ -47,8 +47,8 @@ class AdminStockMvt extends AdminTab
$context = Context::getContext();
$this->_select = 'CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) product_name, CONCAT(e.lastname, \' \', e.firstname) employee, mrl.name reason';
$this->_join = 'INNER JOIN '._DB_PREFIX_.'stock stock ON a.id_stock = stock.id_stock '.Shop::sqlSharedStock('stock', Shop::getCurrentShop(), Shop::getCurrentGroupShop()).'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (stock.id_product = pl.id_product AND pl.id_lang = '.(int)$context->language->id.')
$this->_join = 'INNER JOIN '._DB_PREFIX_.'stock stock ON a.id_stock = stock.id_stock '.Shop::sqlSharedStock('stock').'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (stock.id_product = pl.id_product AND pl.id_lang = '.(int)$context->language->id.' AND pl.id_shop = '.$context->shop->getID(true).')
LEFT JOIN `'._DB_PREFIX_.'stock_mvt_reason_lang` mrl ON (a.id_stock_mvt_reason = mrl.id_stock_mvt_reason AND mrl.id_lang = '.(int)$context->language->id.')
LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.id_employee = a.id_employee)
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.id_product_attribute = stock.id_product_attribute)
+5 -2
View File
@@ -102,7 +102,7 @@ class AdminTaxRulesGroup extends AdminTab
if (Tools::isMultiShopActivated())
{
echo '<label>'.$this->l('Shop association:').'</label><div class="margin-form">';
$this->displayAssoShop();
$this->displayAssoGroupShop();
echo '</div>';
}
echo '
@@ -507,6 +507,9 @@ class AdminTaxRulesGroup extends AdminTab
$result = $object->update();
$this->afterUpdate($object);
}
if ($object->id)
$this->updateAssoGroupShop($object->id);
if (!$result)
$this->_errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b> ('.Db::getInstance()->getMsgError().')';
elseif ($this->postImage($object->id) AND !sizeof($this->_errors))
@@ -549,7 +552,7 @@ class AdminTaxRulesGroup extends AdminTab
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&update'.$this->table.'&token='.$token);
$this->updateAssoGroupShop($object->id);
$id_product = (int)Tools::getValue('id_product');
if ($id_product)
Tools::redirectAdmin('?tab=AdminCatalog&id_product='.$id_product.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)));