0byt3m1n1
Path:
/
home
/
k
/
a
/
s
/
kassiope
/
www
/
administrer
/
[
Home
]
File: profil.php
<? include("../configuration.inc.php"); necessite_identification(); necessite_priv("admin"); $DOC_TITLE = "Gestion des profils"; include("modeles/haut.php"); $start = vn($_REQUEST['start']);// Détermine la variable start (début de page) switch (vb($_REQUEST['mode'])) { case "ajout" : affiche_formulaire_ajout_profil(); break; case "modif" : affiche_formulaire_modif_profil($_GET['id']); break; case "suppr" : supprime_profil($_GET['id']); affiche_liste_profil($start); break; case "insere" : insere_profil($_POST['id'], $_POST); affiche_liste_profil($start); break; case "maj" : maj_profil($_POST['id'], $_POST); affiche_liste_profil($start); break; default : affiche_liste_profil($start); break; } include("modeles/bas.php"); /****************************************************************************** * FONCTIONS *****************************************************************************/ function affiche_formulaire_ajout_profil() { /* Affiche un formulaire vierge pour ajouter un profil */ global $frm; /* Valeurs par défaut */ $frm['nouveau_mode'] = "insere"; $frm['id'] = ""; $frm['name'] = ""; $frm['priv'] = ""; $frm['titre_bouton'] = "Ajouter une profil"; affiche_formulaire_profil(); } function affiche_formulaire_modif_profil($id) { /* Affiche le formulaire de modification pour le profil sélectionné */ global $frm; /* Charge les informations du produit */ $qid = mysql_query_override(" SELECT * FROM gaia_profil WHERE id = $id "); $frm = mysql_fetch_array_override($qid); $frm['id'] = $id; $frm["nouveau_mode"] = "maj"; $frm["titre_bouton"] = "Sauvegarder changements"; affiche_formulaire_profil(); } function affiche_formulaire_profil() { GLOBAL $frm,$wwwroot; ?> <form name="entryform" method="post" action="<?=$_SERVER['PHP_SELF']?>?start=0"> <input type="hidden" name="mode" value="<?=$frm["nouveau_mode"]?>"> <input type="hidden" name="id" value="<?=$frm['id']?>"> <table border="0" width="760" class="tablespace"> <tr> <td class="entete" colspan="2">Ajouter ou modifier un profil</td> </tr> <tr> <td class="normal">Type de profil :</td> <td width="540"><input type="text" name="name" style="width:100%" value="<?=$frm["name"] ?>"></td> </tr> <tr> <td class="normal">Terminologie du privilège :</td> <?php if ($frm["nouveau_mode"] == "insere") { ?> <td><input maxlength="15" type="text" name="priv" size="15" value="<?=$frm["priv"] ?>"></td> <?php } else { echo "<td class=\"normal\">".$frm["priv"]; echo "<input type=\"hidden\" name=\"priv\" value=\"".$frm["priv"]."\"></td>"; } ?> </tr> <tr> <td colspan="2"><input class="bouton" type="submit" value="<?=$frm["titre_bouton"] ?>"></td> </tr> </table> </form> <? } function insere_profil($id, $frm) { /*ajoute le profil dans la table profil */ $qid = mysql_query_override(" INSERT INTO gaia_profil ( name , priv ) VALUES ( '".addslashes($frm['name'])."' ,'".addslashes($frm['priv'])."' ) "); } function maj_profil($id, $frm) { /* Met à jour le profil $id avec de nouvelles valeurs. Les champs sont dans $frm */ /* Met à jour la table profil */ $qid = mysql_query_override(" UPDATE gaia_profil SET name= '".addslashes($frm['name'])."' , priv = '".addslashes($frm['priv'])."' WHERE id = '$id' "); } function affiche_liste_profil($start) { ?> <table border="0" width="760" class="tablespace"> <tr> <td class="entete" colspan="3">Gérer les profil</td> </tr> <tr> <td colspan="2" class="normal"> <a class="normal" href="<?=$_SERVER['PHP_SELF']?>?mode=ajout"> Ajouter un profil</a> <br />Attention en ajoutant un profil, il est impératif de créer les fonctions associées dans /lib/fonctions/fonctions.php ainsi que les fonctions liées aux utilisateurs du site. </td> </tr> <? $result=mysql_query_override("SELECT id, name, priv FROM gaia_profil ORDER BY name") or DIE('Une erreur de connexion à la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR()); if (mysql_num_rows_override($result) == 0) {echo "<tr><td class=normal><b>Aucun profil enregistré dans la base.</b></td></tr>"; } else { ?> <tr bgcolor="#6699ff"> <td class="menu">Action</td> <td class="menu">Profil</td> <td class="menu">Terminologie privilège</td> </tr> <? $i = 0; while ($ligne = mysql_fetch_array_override($result)) { ?> <tr bgcolor="<?echo ($i % 2 == 0 ? '#F4F4F4' : '#ffffff' );?>"> <td align="center" class=petit><a class=petit title="Modifier ce profil" href="<?=$_SERVER['PHP_SELF']?>?mode=modif&id=<?=$ligne['id'] ?>"><img src="images/b_edit.png" width="16" height="16" alt="" border="0"></a></td> <td align="center" class=petit><a class=petit title="Modifier ce profil" href="<?=$_SERVER['PHP_SELF']?>?mode=modif&id=<?=$ligne['id'] ?>"><?=$ligne['name'] ?></a></td> <td align="center" class=petit><?=$ligne['priv'] ?></td> </tr> <? $i++; } } echo "</table>"; } ?>