0byt3m1n1
Path:
/
home
/
k
/
a
/
s
/
kassiope
/
www
/
administrer
/
[
Home
]
File: droit.php
<? include("../configuration.inc.php"); necessite_identification(); necessite_priv("admin"); $DOC_TITLE = "Gestion des profils"; include("modeles/haut.php"); switch (vb($_REQUEST['mode'])) { case "modif" : affiche_formulaire_modif_profil(); break; case "maj" : maj_profil($_POST); affiche_formulaire_modif_profil(); break; default : affiche_formulaire_modif_profil(); break; } include("modeles/bas.php"); /****************************************************************************** * FONCTIONS *****************************************************************************/ function affiche_formulaire_modif_profil() { /* Affiche le formulaire de modification pour le profil sélectionné */ global $frm; /* Charge les informations du produit */ $qid = mysql_query_override(" SELECT * FROM gaia_droit "); $frm = mysql_fetch_array_override($qid); $frm["nouveau_mode"] = "maj"; $frm["titre_bouton"] = "Modifier les droits"; affiche_formulaire_profil(); } function affiche_formulaire_profil() { global $frm, $wwwroot; ?> <form name="entryform" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <input type="hidden" name="mode" value="<?=$frm["nouveau_mode"]?>"> <table bcommande="0" width="760" class="tablespace"> <tr> <td class="entete" colspan="8">Gestion des droits par profil dans l'interface d'administration</td> </tr> <tr> <td class="label">Profil</td> <td class="label">Rayons</td> <td class="label">Produits</td> <td class="label">Rubriques</td> <td class="label">Articles</td> <td class="label">Utilisateurs</td> <td class="label">Commandes</td> <td class="label">Options expert</td> </tr> <?php $sqlProfil = "SELECT * FROM gaia_profil ORDER BY name"; $resProfil = mysql_query_override($sqlProfil); while ($Profil = mysql_fetch_array_override($resProfil)) { echo "<input type=\"hidden\" name=\"profilid[]\" value=\"".$Profil['id']."\">"; echo "<tr>"; echo "<td class=\"normal\">".stripslashes($Profil['name'])."</td>"; $resDroit = mysql_query_override("SELECT * FROM gaia_droit WHERE profil_id = '".$Profil['id']."'"); $Droit = mysql_fetch_object_override($resDroit); $rayon = vn($Droit->rayon); $produit = vn($Droit->produit); $rubrique = vn($Droit->rubrique); $article = vn($Droit->article); $client = vn($Droit->client); $commande = vn($Droit->commande); $expert = vn($Droit->expert); ?> <td align=center><input type="checkbox" name="rayons<?echo $Profil['id']?>" <?php echo frmvalide($Droit->rayon); ?>></td> <td align=center><input type="checkbox" name="produits<?echo $Profil['id']?>" <?php echo frmvalide($Droit->produit); ?>></td> <td align=center><input type="checkbox" name="rubriques<?echo $Profil['id']?>" <?php echo frmvalide($Droit->rubrique); ?>></td> <td align=center><input type="checkbox" name="articles<?echo $Profil['id']?>" <?php echo frmvalide($Droit->article); ?>></td> <td align=center><input type="checkbox" name="clients<?echo $Profil['id']?>" <?php echo frmvalide($Droit->client); ?>></td> <td align=center><input type="checkbox" name="commandes<?echo $Profil['id']?>" <?php echo frmvalide($Droit->commande); ?>></td> <td align=center><input type="checkbox" name="experts<?echo $Profil['id']?>" <?php echo frmvalide($Droit->expert); ?>></td> </tr> <? } ?> <tr> <td colspan="8" align="center"><input class="bouton" type="submit" value="<?=$frm["titre_bouton"] ?>"></td> </tr> </table> </form> <? } function maj_profil($frm) { foreach ($frm['profilid'] as $i => $profil_id) { valide($frm["rayons".$profil_id.""]); valide($frm["produits".$profil_id.""]); valide($frm["rubriques".$profil_id.""]); valide($frm["articles".$profil_id.""]); valide($frm["clients".$profil_id.""]); valide($frm["commandes".$profil_id.""]); valide($frm["experts".$profil_id.""]); $sql = "UPDATE gaia_droit SET rayon = '".intval($frm["rayons".$profil_id.""])."' , produit = '".intval($frm["produits".$profil_id.""])."' , rubrique = '".intval($frm["rubriques".$profil_id.""])."' , article = '".intval($frm["articles".$profil_id.""])."' , client = '".intval($frm["clients".$profil_id.""])."' , commande = '".intval($frm["commandes".$profil_id.""])."' , expert = '".intval($frm["experts".$profil_id.""])."' WHERE profil_id = '".intval($profil_id)."'"; mysql_query_override($sql) or DIE('Une erreur de connexion à la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR()); } } ?>