// 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
+13 -4
View File
@@ -419,10 +419,19 @@ 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>';
foreach ($group_data['shops'] as $sID => $shopData) if ($context->controller->multishop_context & Shop::CONTEXT_GROUP)
if ($shopData['active']) $html .= '<option class="group" value="g-'.$gID.'" '.(($value == 'g-'.$gID) ? 'selected="selected"' : '').' '.$disabled.'>'.translate('Group:').' '.htmlspecialchars($group_data['name']).'</option>';
$html .= '<option value="s-'.$sID.'" class="shop" '.(($value == 's-'.$sID || $context->shop->id == $sID) ? 'selected="selected"' : '').'>&raquo; '.$shopData['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>'; $html .= '</select>';
+1 -1
View File
@@ -218,7 +218,7 @@
</div> </div>
{/if} {/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"> <div class="multishop_toolbar">
<span class="text_multishop">{l s='Multishop configuration for'}</span> <span class="text_multishop">{l s='Multishop configuration for'}</span>
{$shop_list} {$shop_list}
+5 -6
View File
@@ -255,10 +255,7 @@ class AdminControllerCore extends Controller
*/ */
public $controller_name; public $controller_name;
/** public $multishop_context;
* @var bool Display or not the multishop toolbar for this controller
*/
public $display_multishop_toolbar = true;
public function __construct() public function __construct()
{ {
@@ -268,6 +265,8 @@ class AdminControllerCore extends Controller
parent::__construct(); 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->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'); $this->context->smarty->setTemplateDir(_PS_BO_ALL_THEMES_DIR_.$this->bo_theme.'/template');
@@ -1303,7 +1302,7 @@ class AdminControllerCore extends Controller
'tabs' => $tabs, 'tabs' => $tabs,
'install_dir_exists' => file_exists(_PS_ADMIN_DIR_.'/../install'), 'install_dir_exists' => file_exists(_PS_ADMIN_DIR_.'/../install'),
'is_multishop' => $is_multishop, 'is_multishop' => $is_multishop,
'display_multishop_toolbar' => $this->display_multishop_toolbar, 'multishop_context' => $this->multishop_context,
'pic_dir' => _THEME_PROD_PIC_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_,
'controller_name' => Tools::getValue('controller'), 'controller_name' => Tools::getValue('controller'),
)); ));
@@ -1939,7 +1938,7 @@ class AdminControllerCore extends Controller
$where_shop = $this->context->shop->addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType); $where_shop = $this->context->shop->addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
} }
if ($this->display_multishop_toolbar) if ($this->multishop_context)
{ {
$assos = Shop::getAssoTables(); $assos = Shop::getAssoTables();
$assos_group = GroupShop::getAssoTables(); $assos_group = GroupShop::getAssoTables();
+1 -1
View File
@@ -110,7 +110,7 @@ class ShopCore extends ObjectModel
*/ */
const CONTEXT_SHOP = 1; const CONTEXT_SHOP = 1;
const CONTEXT_GROUP = 2; const CONTEXT_GROUP = 2;
const CONTEXT_ALL = 3; const CONTEXT_ALL = 4;
/** /**
* Some data can be shared between shops, like customers or orders * Some data can be shared between shops, like customers or orders
@@ -27,8 +27,6 @@
class AdminCurrenciesControllerCore extends AdminController class AdminCurrenciesControllerCore extends AdminController
{ {
public $display_multishop_toolbar = false;
public function __construct() public function __construct()
{ {
$this->table = 'currency'; $this->table = 'currency';
@@ -82,6 +80,8 @@ class AdminCurrenciesControllerCore extends AdminController
) )
); );
parent::__construct(); parent::__construct();
$this->multishop_context = Shop::CONTEXT_ALL;
} }
public function renderList() public function renderList()
@@ -27,8 +27,6 @@
class AdminGroupShopControllerCore extends AdminController class AdminGroupShopControllerCore extends AdminController
{ {
public $display_multishop_toolbar = false;
public function __construct() public function __construct()
{ {
$this->table = 'group_shop'; $this->table = 'group_shop';
@@ -69,6 +67,8 @@ class AdminGroupShopControllerCore extends AdminController
); );
parent::__construct(); parent::__construct();
$this->multishop_context = null;
} }
public function renderForm() public function renderForm()
+5 -1
View File
@@ -29,7 +29,11 @@ class AdminHomeControllerCore extends AdminController
{ {
const TIPS_TIMEOUT = 5; const TIPS_TIMEOUT = 5;
public $display_multishop_toolbar = false; public function __construct()
{
parent::__construct();
$this->multishop_context = null;
}
protected function _displayOptimizationTips() protected function _displayOptimizationTips()
{ {
+3 -2
View File
@@ -28,8 +28,6 @@
class AdminShopControllerCore extends AdminController class AdminShopControllerCore extends AdminController
{ {
public $display_multishop_toolbar = false;
public function __construct() public function __construct()
{ {
$this->context = Context::getContext(); $this->context = Context::getContext();
@@ -92,7 +90,10 @@ class AdminShopControllerCore extends AdminController
'submit' => array() 'submit' => array()
) )
); );
parent::__construct(); parent::__construct();
$this->multishop_context ^= Shop::CONTEXT_SHOP;
} }
public function initToolbar() public function initToolbar()
+2 -2
View File
@@ -27,8 +27,6 @@
class AdminShopUrlControllerCore extends AdminController class AdminShopUrlControllerCore extends AdminController
{ {
public $display_multishop_toolbar = false;
public function __construct() public function __construct()
{ {
$this->table = 'shop_url'; $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?'))); $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
parent::__construct(); parent::__construct();
$this->multishop_context = null;
} }
public function renderList() public function renderList()
@@ -39,7 +39,6 @@ class AdminStockConfigurationControllerCore extends AdminController
$this->table = 'stock_mvt_reason'; $this->table = 'stock_mvt_reason';
$this->className = 'StockMvtReason'; $this->className = 'StockMvtReason';
$this->lang = true; $this->lang = true;
$this->display_multishop_toolbar = false;
// defines fields // defines fields
$this->fieldsDisplay = array( $this->fieldsDisplay = array(
@@ -122,6 +121,8 @@ class AdminStockConfigurationControllerCore extends AdminController
); );
parent::__construct(); parent::__construct();
$this->multishop_context = null;
} }
public function init() public function init()
@@ -40,7 +40,6 @@ class AdminStockCoverControllerCore extends AdminController
$this->className = 'Product'; $this->className = 'Product';
$this->lang = true; $this->lang = true;
$this->colorOnBackground = true; $this->colorOnBackground = true;
$this->display_multishop_toolbar = false;
$this->fieldsDisplay = array( $this->fieldsDisplay = array(
'reference' => 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'))); array_unshift($this->stock_cover_warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
parent::__construct(); parent::__construct();
$this->multishop_context = null;
} }
/** /**
@@ -38,7 +38,6 @@ class AdminStockInstantStateControllerCore extends AdminController
$this->table = 'stock'; $this->table = 'stock';
$this->className = 'Stock'; $this->className = 'Stock';
$this->lang = false; $this->lang = false;
$this->display_multishop_toolbar = false;
$this->fieldsDisplay = array( $this->fieldsDisplay = array(
'reference' => 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'))); array_unshift($this->stock_instant_state_warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
parent::__construct(); parent::__construct();
$this->multishop_context = null;
} }
/** /**
@@ -36,7 +36,6 @@ class AdminStockManagementControllerCore extends AdminController
$this->table = 'product'; $this->table = 'product';
$this->className = 'Product'; $this->className = 'Product';
$this->lang = true; $this->lang = true;
$this->display_multishop_toolbar = false;
$this->fieldsDisplay = array( $this->fieldsDisplay = array(
'reference' => array( 'reference' => array(
@@ -72,6 +71,8 @@ class AdminStockManagementControllerCore extends AdminController
parent::__construct(); parent::__construct();
$this->multishop_context = null;
// overrides confirmation messages specifically for this controller // overrides confirmation messages specifically for this controller
$this->_conf = array( $this->_conf = array(
1 => $this->l('The product was successfully added to stock'), 1 => $this->l('The product was successfully added to stock'),
@@ -37,7 +37,6 @@ class AdminStockMvtControllerCore extends AdminController
$this->className = 'StockMvt'; $this->className = 'StockMvt';
$this->identifier = 'id_stock_mvt'; $this->identifier = 'id_stock_mvt';
$this->lang = false; $this->lang = false;
$this->display_multishop_toolbar = false;
$this->list_no_link = true; $this->list_no_link = true;
$this->displayInformation($this->l('This interface allows you to display the stock movements for a selected warehouse.').'<br />'); $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(); parent::__construct();
$this->multishop_context = null;
} }
/** /**
@@ -44,7 +44,6 @@ class AdminSupplyOrdersControllerCore extends AdminController
$this->identifier = 'id_supply_order'; $this->identifier = 'id_supply_order';
$this->lang = false; $this->lang = false;
$this->is_template_list = false; $this->is_template_list = false;
$this->display_multishop_toolbar = false;
$this->addRowAction('updatereceipt'); $this->addRowAction('updatereceipt');
$this->addRowAction('changestate'); $this->addRowAction('changestate');
@@ -114,6 +113,8 @@ class AdminSupplyOrdersControllerCore extends AdminController
array_unshift($this->warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses'))); array_unshift($this->warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
parent::__construct(); parent::__construct();
$this->multishop_context = null;
} }
/** /**