// removing group_module_restriction table to set every restrictions in an only table : module_group
This commit is contained in:
@@ -236,7 +236,7 @@ class GroupCore extends ObjectModel
|
||||
public static function truncateModulesRestrictions($id_group)
|
||||
{
|
||||
return Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'group_module_restriction`
|
||||
DELETE FROM `'._DB_PREFIX_.'module_group`
|
||||
WHERE `id_group` = '.(int)$id_group);
|
||||
}
|
||||
|
||||
@@ -248,27 +248,32 @@ class GroupCore extends ObjectModel
|
||||
public static function truncateRestrictionsByModule($id_module)
|
||||
{
|
||||
return Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'group_module_restriction`
|
||||
DELETE FROM `'._DB_PREFIX_.'module_group`
|
||||
WHERE `id_module` = '.(int)$id_module);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding restrictions modules to the group with id $id_group
|
||||
* @param integer id_group
|
||||
* @param array modules
|
||||
* @param integer authorized
|
||||
* @param $id_group
|
||||
* @param $modules
|
||||
* @param array $shops
|
||||
* @return bool
|
||||
* @internal param \id_group $integer
|
||||
* @internal param \modules $array
|
||||
* @internal param \authorized $integer
|
||||
*/
|
||||
public static function addModulesRestrictions($id_group, $modules, $authorized)
|
||||
public static function addModulesRestrictions($id_group, $modules, $shops = array(1))
|
||||
{
|
||||
if (!is_array($modules) AND !empty($modules))
|
||||
if (!is_array($modules) && !empty($modules))
|
||||
return false;
|
||||
else
|
||||
{
|
||||
//delete all record for this group
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'group_module_restriction` WHERE `id_group` = '.(int)$id_group.' AND `authorized` = '.(int)$authorized);
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'group_module_restriction` (`id_group`, `id_module`, `authorized`) VALUES ';
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'module_group` WHERE `id_group` = '.(int)$id_group);
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'module_group` (`id_module`, `id_shop`, `id_group`) VALUES ';
|
||||
foreach ($modules as $mod)
|
||||
$sql .= '("'.(int)$id_group.'", "'.(int)$mod.'", "'.(int)$authorized.'"),';
|
||||
foreach ($shops as $s)
|
||||
$sql .= '("'.(int)$mod.'", "'.(int)$s.'", "'.(int)$id_group.'"),';
|
||||
// removing last comma to avoid SQL error
|
||||
$sql = substr($sql, 0, strlen($sql) - 1);
|
||||
Db::getInstance()->execute($sql);
|
||||
@@ -279,13 +284,15 @@ class GroupCore extends ObjectModel
|
||||
* Add restrictions for a new module
|
||||
* We authorize every groups to the new module
|
||||
* @param integer id_module
|
||||
* @param array $shops
|
||||
*/
|
||||
public static function addRestrictionsForModule($id_module)
|
||||
public static function addRestrictionsForModule($id_module, $shops = array(1))
|
||||
{
|
||||
$groups = Group::getGroups(Context::getContext()->language->id);
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'group_module_restriction` (`id_group`, `id_module`, `authorized`) VALUES ';
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'module_group` (`id_module`, `id_shop`, `id_group`) VALUES ';
|
||||
foreach ($groups as $g)
|
||||
$sql .= '("'.(int)$g['id_group'].'", "'.(int)$id_module.'", "1"),';
|
||||
foreach ($shops as $s)
|
||||
$sql .= '("'.(int)$id_module.'", "'.(int)$s.'", "'.(int)$g['id_group'].'"),';
|
||||
// removing last comma to avoid SQL error
|
||||
$sql = substr($sql, 0, strlen($sql) - 1);
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
@@ -207,8 +207,8 @@ class HookCore extends ObjectModel
|
||||
ON hm.`id_module` = m.`id_module`';
|
||||
if (isset($context->customer) && $context->customer->isLogged())
|
||||
$sql .= '
|
||||
LEFT JOIN `'._DB_PREFIX_.'group_module_restriction` gmr
|
||||
ON gmr.`id_module` = m.`id_module`';
|
||||
LEFT JOIN `'._DB_PREFIX_.'module_group` mg
|
||||
ON mg.`id_module` = m.`id_module`';
|
||||
$sql .= '
|
||||
LEFT JOIN `'._DB_PREFIX_.'hook` h
|
||||
ON hm.`id_hook` = h.`id_hook`
|
||||
@@ -216,7 +216,7 @@ class HookCore extends ObjectModel
|
||||
AND hm.id_shop IN('.implode(', ', $list).')';
|
||||
if (isset($context->customer) && $context->customer->isLogged())
|
||||
$sql .= '
|
||||
AND (gmr.`authorized` = 1 AND gmr.`id_group` IN('.implode(', ', $groups).'))';
|
||||
AND (mg.`id_group` IN('.implode(', ', $groups).'))';
|
||||
$sql .= '
|
||||
GROUP BY hm.id_hook, hm.id_module
|
||||
ORDER BY hm.`position`';
|
||||
|
||||
@@ -187,7 +187,7 @@ abstract class ModuleCore
|
||||
AND a.`view` = 0
|
||||
)');
|
||||
// Adding Restrictions for client groups
|
||||
Group::addRestrictionsForModule($this->id);
|
||||
Group::addRestrictionsForModule($this->id, Shop::getShops(true, null, true));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -918,21 +918,14 @@ abstract class ModuleCore
|
||||
INNER JOIN `'._DB_PREFIX_.'module_group` mg ON (m.`id_module` = mg.`id_module`)
|
||||
INNER JOIN `'._DB_PREFIX_.'customer_group` cg on (cg.`id_group` = mg.`id_group` AND cg.`id_customer` = '.(int)$context->customer->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
|
||||
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`';
|
||||
if (isset($context->customer))
|
||||
$sql .= '
|
||||
LEFT JOIN `'._DB_PREFIX_.'group_module_restriction` gmr ON gmr.`id_module` = m.`id_module`';
|
||||
$sql .= '
|
||||
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
|
||||
WHERE h.`name` = \''.pSQL($hookPayment).'\'
|
||||
AND mc.id_country = '.(int)($billing->id_country).'
|
||||
AND mc.id_shop = '.(int)$context->shop->getID(true).'
|
||||
AND mg.id_shop = '.(int)$context->shop->getID(true).'
|
||||
AND (SELECT COUNT(*) FROM '._DB_PREFIX_.'module_shop ms WHERE ms.id_module = m.id_module AND ms.id_shop IN('.implode(', ', $list).')) = '.count($list).'
|
||||
AND hm.id_shop IN('.implode(', ', $list).')';
|
||||
if (isset($context->customer))
|
||||
$sql .= '
|
||||
AND (gmr.`authorized` = 1 AND gmr.`id_group` IN('.implode(', ', $groups).'))';
|
||||
$sql .= '
|
||||
AND hm.id_shop IN('.implode(', ', $list).')
|
||||
AND (mg.`id_group` IN('.implode(', ', $groups).'))
|
||||
GROUP BY hm.id_hook, hm.id_module
|
||||
ORDER BY hm.`position`, m.`name` DESC';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
@@ -1311,11 +1304,9 @@ abstract class ModuleCore
|
||||
public static function getAuthorizedModules($group_id)
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT m.id_module, m.name FROM `'._DB_PREFIX_.'group_module_restriction` gmr
|
||||
LEFT JOIN `'._DB_PREFIX_.'module` m ON (m.`id_module` = gmr.`id_module`)
|
||||
WHERE gmr.`id_group` = '.(int) $group_id.'
|
||||
AND gmr.`authorized` = 1
|
||||
');
|
||||
SELECT m.id_module, m.name FROM `'._DB_PREFIX_.'module_group` mg
|
||||
LEFT JOIN `'._DB_PREFIX_.'module` m ON (m.`id_module` = mg.`id_module`)
|
||||
WHERE mg.`id_group` = '.(int) $group_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -327,16 +327,13 @@ class AdminGroupsController extends AdminController
|
||||
protected function updateRestrictions()
|
||||
{
|
||||
$id_group = Tools::getValue('id_group');
|
||||
$unauth_modules = Tools::getValue('modulesBoxUnauth');
|
||||
$auth_modules = Tools::getValue('modulesBoxAuth');
|
||||
$return = true;
|
||||
if ($id_group)
|
||||
Group::truncateModulesRestrictions((int)$id_group);
|
||||
|
||||
$shops = Shop::getShops(true, null, true);
|
||||
if (is_array($auth_modules))
|
||||
$return &= Group::addModulesRestrictions($id_group, $auth_modules, 1);
|
||||
if (is_array($unauth_modules))
|
||||
$return &= Group::addModulesRestrictions($id_group, $unauth_modules, 0);
|
||||
$return &= Group::addModulesRestrictions($id_group, $auth_modules, $shops);
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @version Release: $Revision: 10056 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
@@ -33,15 +33,19 @@ function add_default_restrictions_modules_groups()
|
||||
$modules = Db::getInstance()->executeS('
|
||||
SELECT m.*
|
||||
FROM `'._DB_PREFIX_.'module` m');
|
||||
$shops = Db::getInstance()->executeS('
|
||||
SELECT `id_shop`
|
||||
FROM `'._DB_PREFIX_.'shop`');
|
||||
foreach ($groups as $group)
|
||||
{
|
||||
if (!is_array($modules))
|
||||
return false;
|
||||
else
|
||||
{
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'group_module_restriction` (`id_group`, `id_module`, `authorized`) VALUES ';
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'module_group` (`id_module`, `id_shop`, `id_group`) VALUES ';
|
||||
foreach ($modules as $mod)
|
||||
$sql .= '("'.(int)$group['id_group'].'", "'.(int)$mod['id_module'].'", "1"),';
|
||||
foreach ($shops as $s)
|
||||
$sql .= '("'.(int)$mod['id_module'].'", "'.(int)$s.'", "'.(int)$group['id_group'].'"),';
|
||||
// removing last comma to avoid SQL error
|
||||
$sql = substr($sql, 0, strlen($sql) - 1);
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
@@ -2020,13 +2020,6 @@ PRIMARY KEY (`id_scene`, `id_shop`),
|
||||
KEY `id_shop` (`id_shop`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_group_module_restriction` (
|
||||
`id_group` INT(11) UNSIGNED NOT NULL ,
|
||||
`id_module` INT(11) UNSIGNED NOT NULL ,
|
||||
`authorized` tinyint(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id_group`,`id_module`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_stock_mvt` (
|
||||
`id_stock_mvt` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_stock` INT(11) UNSIGNED NOT NULL,
|
||||
|
||||
@@ -650,7 +650,6 @@ INSERT INTO `PREFIX_cms_block_lang` (`id_cms_block`, `id_lang`, `name`) VALUES (
|
||||
|
||||
/* Currency/Country module */
|
||||
INSERT INTO `PREFIX_module_currency` (`id_module`, `id_currency`) VALUES (3, 1),(3, 2),(3, 3),(4, 1),(4, 2),(4, 3),(6, 1),(6, 2),(6, 3);
|
||||
INSERT INTO `PREFIX_module_group` (`id_module`, `id_group`) VALUES (3, 2),(4, 2),(6, 2),(3, 3),(4, 3),(6, 3);
|
||||
|
||||
INSERT INTO `PREFIX_module_country` (`id_module`, `id_country`) VALUES (3, 1),(3, 2),(3, 3),(3, 4),(3, 5),(3, 6),(3, 7),(3, 8),
|
||||
(3, 9),(3, 10),(3, 11),(3, 12),(3, 13),(3, 14),(3, 15),(3, 16),(3, 17),(3, 18),(3, 19),(3, 20),(3, 21),(3, 22),(3, 23),(3, 24),
|
||||
@@ -1351,163 +1350,160 @@ INSERT INTO `PREFIX_store` (`id_store`, `id_country`, `id_state`, `name`, `addre
|
||||
|
||||
INSERT INTO `PREFIX_store_shop` (`id_store`, `id_shop`) (SELECT `id_store`, 1 FROM `PREFIX_store`);
|
||||
|
||||
INSERT INTO `PREFIX_group_module_restriction` (`id_group`, `id_module`, `authorized`) VALUES
|
||||
("1", "1", "1"),
|
||||
("1", "2", "1"),
|
||||
("1", "3", "1"),
|
||||
("1", "4", "1"),
|
||||
("1", "5", "1"),
|
||||
("1", "6", "1"),
|
||||
("1", "7", "1"),
|
||||
("1", "8", "1"),
|
||||
("1", "9", "1"),
|
||||
("1", "10", "1"),
|
||||
("1", "11", "1"),
|
||||
("1", "12", "1"),
|
||||
("1", "13", "1"),
|
||||
("1", "14", "1"),
|
||||
("1", "15", "1"),
|
||||
("1", "16", "1"),
|
||||
("1", "17", "1"),
|
||||
("1", "18", "1"),
|
||||
("1", "19", "1"),
|
||||
("1", "20", "1"),
|
||||
("1", "21", "1"),
|
||||
("1", "22", "1"),
|
||||
("1", "24", "1"),
|
||||
("1", "25", "1"),
|
||||
("1", "26", "1"),
|
||||
("1", "27", "1"),
|
||||
("1", "28", "1"),
|
||||
("1", "30", "1"),
|
||||
("1", "31", "1"),
|
||||
("1", "32", "1"),
|
||||
("1", "33", "1"),
|
||||
("1", "34", "1"),
|
||||
("1", "35", "1"),
|
||||
("1", "36", "1"),
|
||||
("1", "37", "1"),
|
||||
("1", "39", "1"),
|
||||
("1", "40", "1"),
|
||||
("1", "41", "1"),
|
||||
("1", "42", "1"),
|
||||
("1", "43", "1"),
|
||||
("1", "44", "1"),
|
||||
("1", "45", "1"),
|
||||
("1", "46", "1"),
|
||||
("1", "47", "1"),
|
||||
("1", "48", "1"),
|
||||
("1", "49", "1"),
|
||||
("1", "50", "1"),
|
||||
("1", "51", "1"),
|
||||
("1", "52", "1"),
|
||||
("1", "53", "1"),
|
||||
("1", "54", "1"),
|
||||
("1", "55", "1"),
|
||||
("2", "1", "1"),
|
||||
("2", "2", "1"),
|
||||
("2", "3", "1"),
|
||||
("2", "4", "1"),
|
||||
("2", "5", "1"),
|
||||
("2", "6", "1"),
|
||||
("2", "7", "1"),
|
||||
("2", "8", "1"),
|
||||
("2", "9", "1"),
|
||||
("2", "10", "1"),
|
||||
("2", "11", "1"),
|
||||
("2", "12", "1"),
|
||||
("2", "13", "1"),
|
||||
("2", "14", "1"),
|
||||
("2", "15", "1"),
|
||||
("2", "16", "1"),
|
||||
("2", "17", "1"),
|
||||
("2", "18", "1"),
|
||||
("2", "19", "1"),
|
||||
("2", "20", "1"),
|
||||
("2", "21", "1"),
|
||||
("2", "22", "1"),
|
||||
("2", "24", "1"),
|
||||
("2", "25", "1"),
|
||||
("2", "26", "1"),
|
||||
("2", "27", "1"),
|
||||
("2", "28", "1"),
|
||||
("2", "30", "1"),
|
||||
("2", "31", "1"),
|
||||
("2", "32", "1"),
|
||||
("2", "33", "1"),
|
||||
("2", "34", "1"),
|
||||
("2", "35", "1"),
|
||||
("2", "36", "1"),
|
||||
("2", "37", "1"),
|
||||
("2", "39", "1"),
|
||||
("2", "40", "1"),
|
||||
("2", "41", "1"),
|
||||
("2", "42", "1"),
|
||||
("2", "43", "1"),
|
||||
("2", "44", "1"),
|
||||
("2", "45", "1"),
|
||||
("2", "46", "1"),
|
||||
("2", "47", "1"),
|
||||
("2", "48", "1"),
|
||||
("2", "49", "1"),
|
||||
("2", "50", "1"),
|
||||
("2", "51", "1"),
|
||||
("2", "52", "1"),
|
||||
("2", "53", "1"),
|
||||
("2", "54", "1"),
|
||||
("2", "55", "1"),
|
||||
("3", "1", "1"),
|
||||
("3", "2", "1"),
|
||||
("3", "3", "1"),
|
||||
("3", "4", "1"),
|
||||
("3", "5", "1"),
|
||||
("3", "6", "1"),
|
||||
("3", "7", "1"),
|
||||
("3", "8", "1"),
|
||||
("3", "9", "1"),
|
||||
("3", "10", "1"),
|
||||
("3", "11", "1"),
|
||||
("3", "12", "1"),
|
||||
("3", "13", "1"),
|
||||
("3", "14", "1"),
|
||||
("3", "15", "1"),
|
||||
("3", "16", "1"),
|
||||
("3", "17", "1"),
|
||||
("3", "18", "1"),
|
||||
("3", "19", "1"),
|
||||
("3", "20", "1"),
|
||||
("3", "21", "1"),
|
||||
("3", "22", "1"),
|
||||
("3", "24", "1"),
|
||||
("3", "25", "1"),
|
||||
("3", "26", "1"),
|
||||
("3", "27", "1"),
|
||||
("3", "28", "1"),
|
||||
("3", "30", "1"),
|
||||
("3", "31", "1"),
|
||||
("3", "32", "1"),
|
||||
("3", "33", "1"),
|
||||
("3", "34", "1"),
|
||||
("3", "35", "1"),
|
||||
("3", "36", "1"),
|
||||
("3", "37", "1"),
|
||||
("3", "39", "1"),
|
||||
("3", "40", "1"),
|
||||
("3", "41", "1"),
|
||||
("3", "42", "1"),
|
||||
("3", "43", "1"),
|
||||
("3", "44", "1"),
|
||||
("3", "45", "1"),
|
||||
("3", "46", "1"),
|
||||
("3", "47", "1"),
|
||||
("3", "48", "1"),
|
||||
("3", "49", "1"),
|
||||
("3", "50", "1"),
|
||||
("3", "51", "1"),
|
||||
("3", "52", "1"),
|
||||
("3", "53", "1"),
|
||||
("3", "54", "1"),
|
||||
("3", "55", "1");
|
||||
INSERT INTO `PREFIX_module_group` (`id_group`, `id_module`) VALUES
|
||||
("1", "1"),
|
||||
("1", "2"),
|
||||
("1", "5"),
|
||||
("1", "7"),
|
||||
("1", "8"),
|
||||
("1", "9"),
|
||||
("1", "10"),
|
||||
("1", "11"),
|
||||
("1", "12"),
|
||||
("1", "13"),
|
||||
("1", "14"),
|
||||
("1", "15"),
|
||||
("1", "16"),
|
||||
("1", "17"),
|
||||
("1", "18"),
|
||||
("1", "19"),
|
||||
("1", "20"),
|
||||
("1", "21"),
|
||||
("1", "22"),
|
||||
("1", "24"),
|
||||
("1", "25"),
|
||||
("1", "26"),
|
||||
("1", "27"),
|
||||
("1", "28"),
|
||||
("1", "30"),
|
||||
("1", "31"),
|
||||
("1", "32"),
|
||||
("1", "33"),
|
||||
("1", "34"),
|
||||
("1", "35"),
|
||||
("1", "36"),
|
||||
("1", "37"),
|
||||
("1", "39"),
|
||||
("1", "40"),
|
||||
("1", "41"),
|
||||
("1", "42"),
|
||||
("1", "43"),
|
||||
("1", "44"),
|
||||
("1", "45"),
|
||||
("1", "46"),
|
||||
("1", "47"),
|
||||
("1", "48"),
|
||||
("1", "49"),
|
||||
("1", "50"),
|
||||
("1", "51"),
|
||||
("1", "52"),
|
||||
("1", "53"),
|
||||
("1", "54"),
|
||||
("1", "55"),
|
||||
("2", "1"),
|
||||
("2", "2"),
|
||||
("2", "3"),
|
||||
("2", "4"),
|
||||
("2", "5"),
|
||||
("2", "6"),
|
||||
("2", "7"),
|
||||
("2", "8"),
|
||||
("2", "9"),
|
||||
("2", "10"),
|
||||
("2", "11"),
|
||||
("2", "12"),
|
||||
("2", "13"),
|
||||
("2", "14"),
|
||||
("2", "15"),
|
||||
("2", "16"),
|
||||
("2", "17"),
|
||||
("2", "18"),
|
||||
("2", "19"),
|
||||
("2", "20"),
|
||||
("2", "21"),
|
||||
("2", "22"),
|
||||
("2", "24"),
|
||||
("2", "25"),
|
||||
("2", "26"),
|
||||
("2", "27"),
|
||||
("2", "28"),
|
||||
("2", "30"),
|
||||
("2", "31"),
|
||||
("2", "32"),
|
||||
("2", "33"),
|
||||
("2", "34"),
|
||||
("2", "35"),
|
||||
("2", "36"),
|
||||
("2", "37"),
|
||||
("2", "39"),
|
||||
("2", "40"),
|
||||
("2", "41"),
|
||||
("2", "42"),
|
||||
("2", "43"),
|
||||
("2", "44"),
|
||||
("2", "45"),
|
||||
("2", "46"),
|
||||
("2", "47"),
|
||||
("2", "48"),
|
||||
("2", "49"),
|
||||
("2", "50"),
|
||||
("2", "51"),
|
||||
("2", "52"),
|
||||
("2", "53"),
|
||||
("2", "54"),
|
||||
("2", "55"),
|
||||
("3", "1"),
|
||||
("3", "2"),
|
||||
("3", "3"),
|
||||
("3", "4"),
|
||||
("3", "5"),
|
||||
("3", "6"),
|
||||
("3", "7"),
|
||||
("3", "8"),
|
||||
("3", "9"),
|
||||
("3", "10"),
|
||||
("3", "11"),
|
||||
("3", "12"),
|
||||
("3", "13"),
|
||||
("3", "14"),
|
||||
("3", "15"),
|
||||
("3", "16"),
|
||||
("3", "17"),
|
||||
("3", "18"),
|
||||
("3", "19"),
|
||||
("3", "20"),
|
||||
("3", "21"),
|
||||
("3", "22"),
|
||||
("3", "24"),
|
||||
("3", "25"),
|
||||
("3", "26"),
|
||||
("3", "27"),
|
||||
("3", "28"),
|
||||
("3", "30"),
|
||||
("3", "31"),
|
||||
("3", "32"),
|
||||
("3", "33"),
|
||||
("3", "34"),
|
||||
("3", "35"),
|
||||
("3", "36"),
|
||||
("3", "37"),
|
||||
("3", "39"),
|
||||
("3", "40"),
|
||||
("3", "41"),
|
||||
("3", "42"),
|
||||
("3", "43"),
|
||||
("3", "44"),
|
||||
("3", "45"),
|
||||
("3", "46"),
|
||||
("3", "47"),
|
||||
("3", "48"),
|
||||
("3", "49"),
|
||||
("3", "50"),
|
||||
("3", "51"),
|
||||
("3", "52"),
|
||||
("3", "53"),
|
||||
("3", "54"),
|
||||
("3", "55");
|
||||
|
||||
INSERT INTO `PREFIX_stock_available` (`id_stock_available`, `id_product`, `id_product_attribute`, `id_shop`, `id_group_shop`, `quantity`, `depends_on_stock`, `out_of_stock`) VALUES
|
||||
(1, 2, 7, 1, 1, 10, 0, 2),
|
||||
|
||||
@@ -1953,13 +1953,6 @@ PRIMARY KEY (`id_scene`, `id_shop`),
|
||||
KEY `id_shop` (`id_shop`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_group_module_restriction` (
|
||||
`id_group` INT(11) UNSIGNED NOT NULL ,
|
||||
`id_module` INT(11) UNSIGNED NOT NULL ,
|
||||
`authorized` tinyint(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id_group`,`id_module`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_stock_mvt` (
|
||||
`id_stock_mvt` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_stock` INT(11) UNSIGNED NOT NULL,
|
||||
|
||||
@@ -33,15 +33,19 @@ function add_default_restrictions_modules_groups()
|
||||
$modules = Db::getInstance()->executeS('
|
||||
SELECT m.*
|
||||
FROM `'._DB_PREFIX_.'module` m');
|
||||
$shops = Db::getInstance()->executeS('
|
||||
SELECT `id_shop`
|
||||
FROM `'._DB_PREFIX_.'shop`');
|
||||
foreach ($groups as $group)
|
||||
{
|
||||
if (!is_array($modules))
|
||||
return false;
|
||||
else
|
||||
{
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'group_module_restriction` (`id_group`, `id_module`, `authorized`) VALUES ';
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'module_group` (`id_module`, `id_shop`, `id_group`) VALUES ';
|
||||
foreach ($modules as $mod)
|
||||
$sql .= '("'.(int)$group['id_group'].'", "'.(int)$mod['id_module'].'", "1"),';
|
||||
foreach ($shops as $s)
|
||||
$sql .= '("'.(int)$mod['id_module'].'", "'.(int)$s.'", "'.(int)$group['id_group'].'"),';
|
||||
// removing last comma to avoid SQL error
|
||||
$sql = substr($sql, 0, strlen($sql) - 1);
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
Reference in New Issue
Block a user