function test_form(form) { if(form.form_libelle.value.length == 0) { alert(\"".$msg[559]."\"); return false; } return true; } "; function show_group_list() { global $dbh, $msg, $charset; print ""; // affichage du tableau des groupes $q = "SELECT grp_id, grp_name FROM users_groups ORDER BY grp_name "; $r = mysql_query($q, $dbh); $nb = mysql_num_rows($r); $parity=1; for($i=0;$i<$nb;$i++) { $row=mysql_fetch_object($r); if ($parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $parity += 1; $tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./admin.php?categ=users&sub=groups&action=modif&id=$row->grp_id';\" "; print ""; print '"; print ''; } //non affectes $q2 ="select userid, username, prenom, nom from users where grp_num='0' order by username "; $r2 = mysql_query($q2, $dbh); if (mysql_num_rows($r2)) { if ($parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } print "'; } print "
".htmlentities($msg['admin_usr_grp_lib'], ENT_QUOTES, $charset)." ".htmlentities($msg['admin_usr_grp_usr'], ENT_QUOTES, $charset)."
'.htmlentities($row->grp_name, ENT_QUOTES, $charset)."'; $q1="select userid, username, prenom, nom from users where grp_num='".$row->grp_id."' order by username "; $r1 = mysql_query($q1, $dbh); while (($row1 = mysql_fetch_object($r1))) { print "userid."\" >"; $lib = $row1->username.' ('; if (trim($row1->prenom)!=='') $lib.= $row1->prenom.' '; $lib.= $row1->nom.')'; print htmlentities($lib, ENT_QUOTES, $charset); print '
'; } print '
".htmlentities($msg['admin_usr_grp_non_aff'], ENT_QUOTES, $charset).""; while (($row2 = mysql_fetch_object($r2))) { print "userid."\" >"; $lib = $row2->username.' ('; if (trim($row2->prenom)!=='') $lib.= $row2->prenom.' '; $lib.= $row2->nom.')'; print htmlentities($lib, ENT_QUOTES, $charset); print '
'; } print '
"; print ""; } function group_form($libelle='', $id=0) { global $msg, $charset; global $admin_group_form; $admin_group_form = str_replace('!!id!!', $id, $admin_group_form); if(!$id) { $admin_group_form = str_replace('!!form_title!!', $msg['admin_usr_grp_add'], $admin_group_form); } else { $admin_group_form = str_replace('!!form_title!!', $msg['admin_usr_grp_mod'], $admin_group_form); } $admin_group_form = str_replace('!!libelle!!', htmlentities($libelle,ENT_QUOTES, $charset), $admin_group_form); $admin_group_form = str_replace('!!libelle_suppr!!', addslashes($libelle), $admin_group_form); print confirmation_delete("./admin.php?categ=users&sub=groups&action=del&id="); print $admin_group_form; } switch($action) { case 'update': // verification validite des donnees fournies $q = "SELECT count(1) FROM users_groups WHERE grp_name='$form_libelle' AND grp_id!='$id' LIMIT 1 "; $r = mysql_query($q, $dbh); $nb = mysql_result($r, 0, 0); if ($nb > 0) { error_form_message($form_libelle.$msg['admin_usr_grp_lib_used']); } else { //if item already exists UPDATE else INSERT if($id != 0) { $q = "UPDATE users_groups SET grp_name='$form_libelle' WHERE grp_id='$id' "; mysql_query($q, $dbh); } else { $q = "INSERT INTO users_groups (grp_id, grp_name) VALUES (0, '$form_libelle') "; mysql_query($q, $dbh); } } show_group_list(); break; case 'add': if(empty($form_libelle)) { group_form($libelle="", $id=0); } else { show_group_list(); } break; case 'modif': if($id){ $q = "SELECT grp_name FROM users_groups WHERE grp_id='$id' "; $r = mysql_query($q, $dbh); if(mysql_num_rows($r)) { $row=mysql_fetch_object($r); group_form($row->grp_name, $id); } else { show_group_list(); } } else { show_group_list(); } break; case 'del': if($id) { $total = 0; $total = mysql_result(mysql_query("select count(1) from users where grp_num='".$id."' ", $dbh),0 ,0 ); if ($total==0) { $q = "DELETE FROM users_groups WHERE grp_id='$id' "; mysql_query($q, $dbh); show_group_list(); } else { error_message( $msg['admin_usr_grp_ges'], htmlentities($msg['admin_usr_grp_del_imp'], ENT_QUOTES, $charset), 1); } } else { show_group_list(); } break; default: show_group_list(); break; } ?>