// Remove $display_multishop_toolbar and add instead $multishop_context to manage shop context per admin controller

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13530 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2012-02-22 14:25:28 +00:00
parent 12735c9f50
commit 4e6628cbfd
15 changed files with 46 additions and 27 deletions

View File

@@ -419,10 +419,19 @@ function generateShopList()
foreach ($tree as $gID => $group_data)
{
$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>';
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 .= '<option class="group" value="g-'.$gID.'" '.(($value == 'g-'.$gID) ? 'selected="selected"' : '').' '.$disabled.'>'.translate('Group:').' '.htmlspecialchars($group_data['name']).'</option>';
else
$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>';

View File

@@ -218,7 +218,7 @@
</div>
{/if}
{if $display_header && $is_multishop && $display_multishop_toolbar}
{if $display_header && $is_multishop && ($multishop_context & Shop::CONTEXT_GROUP || $multishop_context & Shop::CONTEXT_SHOP)}
<div class="multishop_toolbar">
<span class="text_multishop">{l s='Multishop configuration for'}</span>
{$shop_list}

View File

@@ -255,10 +255,7 @@ class AdminControllerCore extends Controller
*/
public $controller_name;
/**
* @var bool Display or not the multishop toolbar for this controller
*/
public $display_multishop_toolbar = true;
public $multishop_context;
public function __construct()
{
@@ -268,6 +265,8 @@ class AdminControllerCore extends Controller
parent::__construct();
$this->multishop_context = Shop::CONTEXT_ALL | Shop::CONTEXT_GROUP | Shop::CONTEXT_SHOP;
$this->bo_theme = ((Validate::isLoadedObject($this->context->employee) && $this->context->employee->bo_theme) ? $this->context->employee->bo_theme : 'default');
$this->context->smarty->setTemplateDir(_PS_BO_ALL_THEMES_DIR_.$this->bo_theme.'/template');
@@ -1303,7 +1302,7 @@ class AdminControllerCore extends Controller
'tabs' => $tabs,
'install_dir_exists' => file_exists(_PS_ADMIN_DIR_.'/../install'),
'is_multishop' => $is_multishop,
'display_multishop_toolbar' => $this->display_multishop_toolbar,
'multishop_context' => $this->multishop_context,
'pic_dir' => _THEME_PROD_PIC_DIR_,
'controller_name' => Tools::getValue('controller'),
));
@@ -1939,7 +1938,7 @@ class AdminControllerCore extends Controller
$where_shop = $this->context->shop->addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
}
if ($this->display_multishop_toolbar)
if ($this->multishop_context)
{
$assos = Shop::getAssoTables();
$assos_group = GroupShop::getAssoTables();

View File

@@ -110,7 +110,7 @@ class ShopCore extends ObjectModel
*/
const CONTEXT_SHOP = 1;
const CONTEXT_GROUP = 2;
const CONTEXT_ALL = 3;
const CONTEXT_ALL = 4;
/**
* Some data can be shared between shops, like customers or orders

View File

@@ -27,8 +27,6 @@
class AdminCurrenciesControllerCore extends AdminController
{
public $display_multishop_toolbar = false;
public function __construct()
{
$this->table = 'currency';
@@ -82,6 +80,8 @@ class AdminCurrenciesControllerCore extends AdminController
)
);
parent::__construct();
$this->multishop_context = Shop::CONTEXT_ALL;
}
public function renderList()

View File

@@ -27,8 +27,6 @@
class AdminGroupShopControllerCore extends AdminController
{
public $display_multishop_toolbar = false;
public function __construct()
{
$this->table = 'group_shop';
@@ -69,6 +67,8 @@ class AdminGroupShopControllerCore extends AdminController
);
parent::__construct();
$this->multishop_context = null;
}
public function renderForm()

View File

@@ -29,7 +29,11 @@ class AdminHomeControllerCore extends AdminController
{
const TIPS_TIMEOUT = 5;
public $display_multishop_toolbar = false;
public function __construct()
{
parent::__construct();
$this->multishop_context = null;
}
protected function _displayOptimizationTips()
{

View File

@@ -28,8 +28,6 @@
class AdminShopControllerCore extends AdminController
{
public $display_multishop_toolbar = false;
public function __construct()
{
$this->context = Context::getContext();
@@ -92,7 +90,10 @@ class AdminShopControllerCore extends AdminController
'submit' => array()
)
);
parent::__construct();
$this->multishop_context ^= Shop::CONTEXT_SHOP;
}
public function initToolbar()

View File

@@ -27,8 +27,6 @@
class AdminShopUrlControllerCore extends AdminController
{
public $display_multishop_toolbar = false;
public function __construct()
{
$this->table = 'shop_url';
@@ -90,6 +88,8 @@ class AdminShopUrlControllerCore extends AdminController
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
parent::__construct();
$this->multishop_context = null;
}
public function renderList()

View File

@@ -39,7 +39,6 @@ class AdminStockConfigurationControllerCore extends AdminController
$this->table = 'stock_mvt_reason';
$this->className = 'StockMvtReason';
$this->lang = true;
$this->display_multishop_toolbar = false;
// defines fields
$this->fieldsDisplay = array(
@@ -122,6 +121,8 @@ class AdminStockConfigurationControllerCore extends AdminController
);
parent::__construct();
$this->multishop_context = null;
}
public function init()

View File

@@ -40,7 +40,6 @@ class AdminStockCoverControllerCore extends AdminController
$this->className = 'Product';
$this->lang = true;
$this->colorOnBackground = true;
$this->display_multishop_toolbar = false;
$this->fieldsDisplay = array(
'reference' => array(
@@ -104,6 +103,8 @@ class AdminStockCoverControllerCore extends AdminController
array_unshift($this->stock_cover_warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
parent::__construct();
$this->multishop_context = null;
}
/**

View File

@@ -38,7 +38,6 @@ class AdminStockInstantStateControllerCore extends AdminController
$this->table = 'stock';
$this->className = 'Stock';
$this->lang = false;
$this->display_multishop_toolbar = false;
$this->fieldsDisplay = array(
'reference' => array(
@@ -103,6 +102,8 @@ class AdminStockInstantStateControllerCore extends AdminController
array_unshift($this->stock_instant_state_warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
parent::__construct();
$this->multishop_context = null;
}
/**

View File

@@ -36,7 +36,6 @@ class AdminStockManagementControllerCore extends AdminController
$this->table = 'product';
$this->className = 'Product';
$this->lang = true;
$this->display_multishop_toolbar = false;
$this->fieldsDisplay = array(
'reference' => array(
@@ -72,6 +71,8 @@ class AdminStockManagementControllerCore extends AdminController
parent::__construct();
$this->multishop_context = null;
// overrides confirmation messages specifically for this controller
$this->_conf = array(
1 => $this->l('The product was successfully added to stock'),

View File

@@ -37,7 +37,6 @@ class AdminStockMvtControllerCore extends AdminController
$this->className = 'StockMvt';
$this->identifier = 'id_stock_mvt';
$this->lang = false;
$this->display_multishop_toolbar = false;
$this->list_no_link = true;
$this->displayInformation($this->l('This interface allows you to display the stock movements for a selected warehouse.').'<br />');
@@ -116,6 +115,8 @@ class AdminStockMvtControllerCore extends AdminController
);
parent::__construct();
$this->multishop_context = null;
}
/**

View File

@@ -44,7 +44,6 @@ class AdminSupplyOrdersControllerCore extends AdminController
$this->identifier = 'id_supply_order';
$this->lang = false;
$this->is_template_list = false;
$this->display_multishop_toolbar = false;
$this->addRowAction('updatereceipt');
$this->addRowAction('changestate');
@@ -114,6 +113,8 @@ class AdminSupplyOrdersControllerCore extends AdminController
array_unshift($this->warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
parent::__construct();
$this->multishop_context = null;
}
/**