diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 25e2d9f72d8..baf1846b322 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -50,6 +50,7 @@ UPDATE llx_c_units SET label = 'SurfaceUnitm2' WHERE code IN ('M2'); -- For v11 ALTER TABLE llx_rights_def ADD COLUMN module_position INTEGER NOT NULL DEFAULT 0; +ALTER TABLE llx_rights_def ADD COLUMN family_position INTEGER NOT NULL DEFAULT 0; ALTER TABLE llx_bom_bom ADD COLUMN duration double(8,4) DEFAULT NULL; ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_rights_def.sql b/htdocs/install/mysql/tables/llx_rights_def.sql index 3ad6972f3c8..1cfcdbe25ef 100644 --- a/htdocs/install/mysql/tables/llx_rights_def.sql +++ b/htdocs/install/mysql/tables/llx_rights_def.sql @@ -23,6 +23,7 @@ create table llx_rights_def libelle varchar(255), module varchar(64), module_position integer NOT NULL DEFAULT 0, + family_position integer NOT NULL DEFAULT 0, entity integer DEFAULT 1 NOT NULL, perms varchar(50), subperms varchar(50), diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index f52b7618daa..a49c3e930b0 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -288,7 +288,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql.= " AND r.entity = " . $entity; if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable -$sql.= " ORDER BY r.module_position, r.module, r.id"; +$sql.= " ORDER BY r.family_position, r.module_position, r.module, r.id"; $result=$db->query($sql); if ($result) @@ -308,12 +308,16 @@ if ($result) continue; } - // Fix field module_position in database if value is still zero + // Save field module_position in database if value is still zero if (empty($obj->module_position)) { if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) { - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def set module_position = ".$modules[$obj->module]->module_position; + // TODO Define familyposition + $family = $modules[$obj->module]->family_position; + $familyposition = 0; + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.","; + $sqlupdate.= " family_position = ".$familyposition; $sqlupdate.= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'"; $db->query($sqlupdate); }