Fix: Ne plante plus sur les permissions si un module a été effacé sans avoir été désactivé.

This commit is contained in:
Laurent Destailleur 2005-04-17 15:06:18 +00:00
parent e9a8c4b189
commit 914e32fc57
3 changed files with 64 additions and 41 deletions

View File

@ -96,56 +96,63 @@ $sql.=" WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
$sql.=" ORDER BY r.id, r.module"; $sql.=" ORDER BY r.id, r.module";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$num = $db->num_rows(); $num = $db->num_rows();
$i = 0; $i = 0;
$var=True; $var=True;
$old = ""; $old = "";
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$var=!$var;
if ($old <> $obj->module) // Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore
{ if (! $modules[$obj->module])
// Rupture détectée, on récupère objMod {
$objMod=$modules[$obj->module]; $i++;
$picto=($objMod->picto?$objMod->picto:'generic'); continue;
}
print '<tr class="liste_titre">'; if ($old <> $obj->module)
print '<td>'.$langs->trans("Module").'</td>'; {
print '<td>'.$langs->trans("Permission").'</td>'; // Rupture détectée, on récupère objMod
print '<td align="center">'.$langs->trans("Default").'</td>'; $objMod=$modules[$obj->module];
print '<td align="center">&nbsp;</td>'; $picto=($objMod->picto?$objMod->picto:'generic');
print "</tr>\n";
$old = $obj->module;
}
print '<tr '. $bc[$var].'>'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>';
print '<td>'.$langs->trans("Permission").'</td>';
print '<td align="center">'.$langs->trans("Default").'</td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
$old = $obj->module;
}
print '<td>'.img_object('',$picto).' '.$objMod->getName(); $var=!$var;
print '<tr '. $bc[$var].'>';
$perm_libelle=(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$obj->libelle); print '<td>'.img_object('',$picto).' '.$objMod->getName();
print '<td>'.$perm_libelle. '</td>';
print '<td align="center">';
if ($obj->bydefault == 1)
{
print img_tick(); $perm_libelle=(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$obj->libelle);
print '</td><td>'; print '<td>'.$perm_libelle. '</td>';
print '<a href="perms.php?pid='.$obj->id.'&amp;action=remove">'.img_edit_remove().'</a>';
}
else
{
print '&nbsp;';
print '</td><td>';
print '<a href="perms.php?pid='.$obj->id.'&amp;action=add">'.img_edit_add().'</a>';
}
print '</td></tr>'; print '<td align="center">';
$i++; if ($obj->bydefault == 1)
{
print img_tick();
print '</td><td>';
print '<a href="perms.php?pid='.$obj->id.'&amp;action=remove">'.img_edit_remove().'</a>';
}
else
{
print '&nbsp;';
print '</td><td>';
print '<a href="perms.php?pid='.$obj->id.'&amp;action=add">'.img_edit_add().'</a>';
}
print '</td></tr>';
$i++;
} }
} }

View File

@ -171,6 +171,14 @@ if ($_GET["id"])
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore
if (! $modules[$obj->module])
{
$i++;
continue;
}
if ($oldmod <> $obj->module) if ($oldmod <> $obj->module)
{ {
$oldmod = $obj->module; $oldmod = $obj->module;

View File

@ -211,6 +211,14 @@ if ($_GET["id"])
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore
if (! $modules[$obj->module])
{
$i++;
continue;
}
if ($oldmod <> $obj->module) if ($oldmod <> $obj->module)
{ {
$oldmod = $obj->module; $oldmod = $obj->module;