[+] Project : Possibility to enable or disable tabs

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11581 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
jBreux
2011-12-22 11:02:55 +00:00
parent accd9d0f19
commit f1bda28edb
7 changed files with 61 additions and 8 deletions
+3 -3
View File
@@ -297,7 +297,7 @@ $echoLis = '';
$mainsubtablist = '';
foreach ($tabs AS $t)
if (checkTabRights($t['id_tab']) === true)
if (checkTabRights($t['id_tab']) === true AND (bool)$t['active'])
{
$img = (Tools::file_exists_cache(_PS_ADMIN_DIR_.'/themes/'.Context::getContext()->employee->bo_theme.'/img/t/'.$t['class_name'].'.gif') ? 'themes/'.Context::getContext()->employee->bo_theme.'/img/' : _PS_IMG_).'t/'.$t['class_name'].'.gif';
if (trim($t['module']) != '')
@@ -316,13 +316,13 @@ foreach ($tabs AS $t)
array_unshift($subTabs, $t);
foreach ($subTabs AS $t2)
if (checkTabRights($t2['id_tab']) === true)
if (checkTabRights($t2['id_tab']) === true AND (bool)$t2['active'])
echo '<li><a href="index.php?controller='.$t2['class_name'].'&token='.Tools::getAdminTokenLite($t2['class_name']).'">'.$t2['name'].'</a></li>';
echo '</ul></li>';
$echoLi = '';
foreach ($subTabs AS $t2)
if (checkTabRights($t2['id_tab']) === true)
if (checkTabRights($t2['id_tab']) === true AND (bool)$t2['active'])
$echoLi .= '<li class="subitem"><a href="index.php?controller='.$t2['class_name'].'&token='.Tools::getAdminTokenLite($t2['class_name']).'">'.$t2['name'].'</a></li>';
if ($current)
+2 -2
View File
@@ -1229,7 +1229,7 @@ class AdminControllerCore extends Controller
$current_id = Tab::getCurrentParentId();
foreach ($tabs as $index => $tab)
{
if (Tab::checkTabRights($tab['id_tab']) === true)
if (Tab::checkTabRights($tab['id_tab']) === true AND (bool)$tab['active'])
{
if ($tab['name'] == 'Stock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0)
{
@@ -1259,7 +1259,7 @@ class AdminControllerCore extends Controller
foreach ($sub_tabs as $index2 => $sub_tab)
{
// class_name is the name of the class controller
if (Tab::checkTabRights($sub_tab) === true)
if (Tab::checkTabRights($sub_tab) === true AND (bool)$sub_tab['active'])
$sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']);
else
unset($sub_tabs[$index2]);
+4
View File
@@ -41,6 +41,9 @@ class TabCore extends ObjectModel
/** @var integer position */
public $position;
/** @var integer active */
public $active;
/**
* @see ObjectModel::$definition
*/
@@ -53,6 +56,7 @@ class TabCore extends ObjectModel
'position' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'module' => array('type' => self::TYPE_STRING, 'validate' => 'isTabName', 'size' => 64),
'class_name' => array('type' => self::TYPE_STRING, 'required' => true, 'size' => 64),
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
// Lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 32),
+31 -1
View File
@@ -60,6 +60,14 @@ class AdminTabsControllerCore extends AdminController
'module' => array(
'title' => $this->l('Module')
),
'active' => array(
'title' => $this->l('Enabled'),
'width' => 70,
'align' => 'center',
'active' => 'status',
'type' => 'bool',
'orderby' => false
),
'position' => array(
'title' => $this->l('Position'),
'width' => 40,
@@ -123,6 +131,27 @@ class AdminTabsControllerCore extends AdminController
'name' => 'icon',
'desc' => $this->l('Upload logo from your computer').' (.gif, .jpg, .jpeg '.$this->l('or').' .png)'
),
array(
'type' => 'radio',
'label' => $this->l('Status:'),
'name' => 'active',
'required' => false,
'class' => 't',
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
'desc' => $this->l('Show or hide tab.')
),
array(
'type' => 'select',
'label' => $this->l('Parent:'),
@@ -242,7 +271,8 @@ class AdminTabsControllerCore extends AdminController
else
{
// Temporary add the position depend of the selection of the parent category
$_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent'));
if (!Tools::isSubmit('id_tab')) // @todo Review
$_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent'));
parent::postProcess();
}
}
+1
View File
@@ -1652,6 +1652,7 @@ CREATE TABLE `PREFIX_tab` (
`class_name` varchar(64) NOT NULL,
`module` varchar(64) NULL,
`position` int(10) unsigned NOT NULL,
`active` tinyint(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`id_tab`),
KEY `class_name` (`class_name`),
KEY `id_parent` (`id_parent`)
+2 -2
View File
@@ -950,14 +950,14 @@ INSERT INTO `PREFIX_tab` (`id_tab`, `class_name`, `id_parent`, `position`) VALUE
(88,'AdminShop', 0, 11), (89,'AdminGroupShop', 88, 1),(90, 'AdminShopUrl', 88, 2),(91, 'AdminGenders', 2, 4),(92, 'AdminRequestSql', 9, 14),
(93, 'AdminProducts', 1, 1),
(94, 'AdminCategories', 1, 2),
(95, 'AdminStock', 0, 15),
(95, 'AdminStock', 0, 12),
(96, 'AdminWarehouses', 95, 1),
(97, 'AdminStockManagement', 95, 2),
(98, 'AdminStockInstantState', 95, 4),
(99, 'AdminStockCover', 95, 5),
(100, 'AdminSupplyOrders', 95, 6),
(101, 'AdminAttributeGenerator', -1, 0),
(102, 'AdminAccounting', 0, 16),
(102, 'AdminAccounting', 0, 13),
(103, 'AdminAccountingManagement', 102, 1),
(104, 'AdminAccountingExport', 102, 2),
(105, 'AdminCmsCategories', -1, 0),
+18
View File
@@ -357,6 +357,8 @@ INSERT INTO `PREFIX_order_invoice` (`id_order`, `number`, `total_discount_tax_ex
WHERE `invoice_number` != 0
);
ALTER TABLE `PREFIX_tab` ADD `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1';
UPDATE `PREFIX_order_detail` od
SET od.`id_order_invoice` = (
SELECT oi.`id_order_invoice`
@@ -393,3 +395,19 @@ INSERT INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) VAL
ALTER TABLE `PREFIX_specific_price` ADD `id_cart` INT(11) UNSIGNED NOT NULL AFTER `id_specific_price_rule`;
ALTER TABLE `PREFIX_specific_price` ADD INDEX `id_cart` (`id_cart`);
/* PHP:update_modules_multishop.php; */;
UPDATE `PREFIX_tab`
SET `position` = (
SELECT MAX(`position`)+1
FROM `PREFIX_tab`
WHERE `id_parent` = 0
)
WHERE `class_name` = 'AdminStock';
UPDATE `PREFIX_tab`
SET `position` = (
SELECT MAX(`position`)+1
FROM `PREFIX_tab`
WHERE `id_parent` = 0
)
WHERE `class_name` = 'AdminAccounting';