From 4b2a5b2377c1438fb2bb3003e05f08ec8825702b Mon Sep 17 00:00:00 2001 From: vChabot Date: Mon, 5 Mar 2012 16:52:58 +0000 Subject: [PATCH] [-] BO : Bugfix : #PSFV-619 : removing the ability to add a new root category if you are not in multishop // category tree improved --- classes/helper/Helper.php | 2 +- controllers/admin/AdminCategoriesController.php | 9 +++++---- controllers/admin/AdminProductsController.php | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/classes/helper/Helper.php b/classes/helper/Helper.php index e460033e0..9024f80c3 100755 --- a/classes/helper/Helper.php +++ b/classes/helper/Helper.php @@ -273,7 +273,7 @@ class HelperCore } $root_input = ' '; - if ($root_category->id != $top_category->id || (Tools::isSubmit('ajax') && Tools::getValue('action') == 'getCategoriesFromRootCategory')) + if ($root['id_category'] != $top_category->id || (Tools::isSubmit('ajax') && Tools::getValue('action') == 'getCategoriesFromRootCategory')) $root_input = ' diff --git a/controllers/admin/AdminCategoriesController.php b/controllers/admin/AdminCategoriesController.php index 6e424e161..3026a7f50 100644 --- a/controllers/admin/AdminCategoriesController.php +++ b/controllers/admin/AdminCategoriesController.php @@ -210,10 +210,11 @@ class AdminCategoriesControllerCore extends AdminController { if (empty($this->display)) { - $this->toolbar_btn['new-url'] = array( - 'href' => self::$currentIndex.'&add'.$this->table.'root&token='.$this->token, - 'desc' => $this->l('Add new root category') - ); + if (Shop::isFeatureActive()) + $this->toolbar_btn['new-url'] = array( + 'href' => self::$currentIndex.'&add'.$this->table.'root&token='.$this->token, + 'desc' => $this->l('Add new root category') + ); $this->toolbar_btn['new'] = array( 'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token, 'desc' => $this->l('Add new') diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index fdc681e43..214ada0ed 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2524,7 +2524,7 @@ class AdminProductsControllerCore extends AdminController $data = $this->createTemplate($this->tpl_form); // Prepare Categories tree for display in Associations tab $root = Category::getRootCategory(); - $default_category = Tools::getValue('id_category', $root->id); + $default_category = Tools::getValue('id_category', Configuration::get('PS_HOME_CATEGORY')); if (!$product->id) $selected_cat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language); @@ -2562,12 +2562,13 @@ class AdminProductsControllerCore extends AdminController $product->manufacturer_name = Manufacturer::getNameById($product->id_manufacturer); + $tab_root = array('id_category' => $root->id, 'name' => $root->name); $helper = new Helper(); $data->assign(array('default_category' => $default_category, 'selected_cat_ids' => implode(',', array_keys($selected_cat)), 'selected_cat' => $selected_cat, 'id_category_default' => $product->getDefaultCategory(), - 'category_tree' => $helper->renderCategoryTree(null, $selected_cat, 'categoryBox', false, true), + 'category_tree' => $helper->renderCategoryTree($tab_root, $selected_cat, 'categoryBox', false, true), 'product' => $product, 'link' => $this->context->link ));