Fix bad position sorting of permission list
This commit is contained in:
parent
4ac62773ae
commit
82305d7dd4
@ -292,6 +292,72 @@ if ($user->admin) {
|
||||
}
|
||||
print '</tr>'."\n";
|
||||
|
||||
|
||||
// Fix bad value for module_position in table
|
||||
// ------------------------------------------
|
||||
$sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
||||
$sql .= " AND r.entity = ".((int) $entity);
|
||||
$sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
$oldmod = '';
|
||||
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
// If line is for a module that does not exist anymore (absent of includes/module), we ignore it
|
||||
if (empty($modules[$obj->module])) {
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Special cases
|
||||
if (!empty($conf->reception->enabled)) {
|
||||
// The 2 permissions in fournisseur modules are replaced by permissions into reception module
|
||||
if ($obj->module == 'fournisseur' && $obj->perms == 'commande' && $obj->subperms == 'receptionner') {
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
if ($obj->module == 'fournisseur' && $obj->perms == 'commande_advance' && $obj->subperms == 'check') {
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$objMod = $modules[$obj->module];
|
||||
|
||||
// Save field module_position in database if value is wrong
|
||||
if (empty($obj->module_position) || (is_object($objMod) && $objMod->isCoreOrExternalModule() == 'external' && $obj->module_position < 100000)) {
|
||||
if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) {
|
||||
// TODO Define familyposition
|
||||
//$familyposition = $modules[$obj->module]->family_position;
|
||||
$familyposition = 0;
|
||||
|
||||
$newmoduleposition = $modules[$obj->module]->module_position;
|
||||
|
||||
// Correct $newmoduleposition position for external modules
|
||||
$objMod = $modules[$obj->module];
|
||||
if (is_object($objMod) && $objMod->isCoreOrExternalModule() == 'external' && $newmoduleposition < 100000) {
|
||||
$newmoduleposition += 100000;
|
||||
}
|
||||
|
||||
$sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".((int) $newmoduleposition).",";
|
||||
$sqlupdate .= " family_position = ".((int) $familyposition);
|
||||
$sqlupdate .= " WHERE module_position = ".((int) $obj->module_position)." AND module = '".$db->escape($obj->module)."'";
|
||||
|
||||
$db->query($sqlupdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS;
|
||||
$sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
||||
@ -333,6 +399,7 @@ if ($result) {
|
||||
$objMod = $modules[$obj->module];
|
||||
|
||||
// Save field module_position in database if value is wrong
|
||||
/*
|
||||
if (empty($obj->module_position) || (is_object($objMod) && $objMod->isCoreOrExternalModule() == 'external' && $obj->module_position < 100000)) {
|
||||
if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) {
|
||||
// TODO Define familyposition
|
||||
@ -354,6 +421,7 @@ if ($result) {
|
||||
$db->query($sqlupdate);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Break found, it's a new module to catch
|
||||
if (isset($obj->module) && ($oldmod <> $obj->module)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user