From ef00a2400b3cb475e39286a22677cecf28ebc373 Mon Sep 17 00:00:00 2001 From: vChabot Date: Thu, 3 Nov 2011 17:14:16 +0000 Subject: [PATCH] [*] BO : when a group is created, every category are linked to this group git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9859 b9a71923-0436-4b27-9f14-aed3839534dd --- admin-dev/tabs/AdminGroups.php | 2 ++ classes/AdminTab.php | 10 ++++++++++ classes/Group.php | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/admin-dev/tabs/AdminGroups.php b/admin-dev/tabs/AdminGroups.php index 9cc2f4ffd..fac957d38 100644 --- a/admin-dev/tabs/AdminGroups.php +++ b/admin-dev/tabs/AdminGroups.php @@ -508,7 +508,9 @@ class AdminGroups extends AdminTab } } if (!count($this->_errors)) + { parent::postProcess(); + } } } else diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 665183b87..8df2d849e 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -775,7 +775,17 @@ abstract class AdminTabCore $this->afterAdd($object); $this->updateAssoShop($object->id); if ($this->table == 'group') + { $this->updateRestrictions($object->id); + // assign group access to every categories + $categories = Category::getCategories($this->context->language->id, true); + $rowList = array();$a=0; + foreach ($categories as $category) + foreach ($category as $categ_id => $categ) + if ($categ_id != 1) + $rowList[] = array('id_category' => $categ_id, 'id_group' => $object->id); + Db::getInstance()->autoExecute(_DB_PREFIX_.'category_group', $rowList, 'INSERT'); + } // Save and stay on same form if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&update'.$this->table.'&token='.$token); diff --git a/classes/Group.php b/classes/Group.php index 0da9148cc..068ad84fd 100644 --- a/classes/Group.php +++ b/classes/Group.php @@ -171,7 +171,7 @@ class GroupCore extends ObjectModel Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'category_group` WHERE `id_group` = '.(int)$this->id); Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'group_reduction` WHERE `id_group` = '.(int)$this->id); Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'product_group_reduction_cache` WHERE `id_group` = '.(int)$this->id); - $this->truncateRestrictionsModules($this->id); + $this->truncateModulesRestrictions($this->id); // Refresh cache of feature detachable Configuration::updateGlobalValue('PS_GROUP_FEATURE_ACTIVE', self::isCurrentlyUsed());