This commit is contained in:
Laurent Destailleur 2018-02-14 14:57:53 +01:00
parent 9f883f3401
commit ca71d90d96

View File

@ -901,61 +901,10 @@ if ($ok && GETPOST('set_empty_time_spent_amount','alpha'))
}
// clean_old_module_entries: Clean data into const when files of module were removed without being
if ($ok && GETPOST('clean_perm_table','alpha'))
{
print '<tr><td colspan="2"><br>*** Clean table user_rights from lines of external modules no more enabled</td></tr>';
$listofmods='';
foreach($conf->modules as $key => $val)
{
$listofmods.=($listofmods?',':'')."'".$val."'";
}
$sql = 'SELECT id, libelle, module from '.MAIN_DB_PREFIX.'rights_def WHERE module not in ('.$listofmods.') AND id > 100000';
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
$i = 0;
while ($i < $num)
{
$obj=$db->fetch_object($resql);
if ($obj->id > 0)
{
print '<tr><td>Found line with id '.$obj->id.', label "'.$obj->libelle.'" of module "'.$obj->module.'" to delete';
if (GETPOST('clean_perm_table','alpha') == 'confirmed')
{
$sqldelete = 'DELETE FROM '.MAIN_DB_PREFIX.'rights_def WHERE id = '.$obj->id;
$resqldelete = $db->query($sqldelete);
if (! $resqldelete)
{
dol_print_error($db);
}
print ' - deleted';
}
print '</td></tr>';
}
$i++;
}
}
else
{
print '<tr><td>No lines of a disabled external module (with id > 100000) found into table rights_def</td></tr>';
}
}
else
{
dol_print_error($db);
}
}
// clean_old_module_entries: Clean data into const when files of module were removed without being
if ($ok && GETPOST('force_disable_of_modules_not_found','alpha'))
{
print '<tr><td colspan="2"><br>*** Force modules not found to be disabled</td></tr>';
print '<tr><td colspan="2"><br>*** Force modules not found to be disabled (only modules adding js, css or hooks can be detected as removed)</td></tr>';
$arraylistofkey=array('hooks','js','css');
@ -1071,6 +1020,56 @@ if ($ok && GETPOST('force_disable_of_modules_not_found','alpha'))
}
// clean_old_module_entries: Clean data into const when files of module were removed without being
if ($ok && GETPOST('clean_perm_table','alpha'))
{
print '<tr><td colspan="2"><br>*** Clean table user_rights from lines of external modules no more enabled</td></tr>';
$listofmods='';
foreach($conf->modules as $key => $val)
{
$listofmods.=($listofmods?',':'')."'".$val."'";
}
$sql = 'SELECT id, libelle, module from '.MAIN_DB_PREFIX.'rights_def WHERE module not in ('.$listofmods.') AND id > 100000';
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
$i = 0;
while ($i < $num)
{
$obj=$db->fetch_object($resql);
if ($obj->id > 0)
{
print '<tr><td>Found line with id '.$obj->id.', label "'.$obj->libelle.'" of module "'.$obj->module.'" to delete';
if (GETPOST('clean_perm_table','alpha') == 'confirmed')
{
$sqldelete = 'DELETE FROM '.MAIN_DB_PREFIX.'rights_def WHERE id = '.$obj->id;
$resqldelete = $db->query($sqldelete);
if (! $resqldelete)
{
dol_print_error($db);
}
print ' - deleted';
}
print '</td></tr>';
}
$i++;
}
}
else
{
print '<tr><td>No lines of a disabled external module (with id > 100000) found into table rights_def</td></tr>';
}
}
else
{
dol_print_error($db);
}
}
// clean_linked_elements: Check and clean linked elements