".$msg["es_group_name"]." ".$msg["es_group_fullname"]." ".$msg["es_group_pmbuserid"]." ".$msg["es_group_esusers_count"]." ".$msg["es_group_emprgroup_count"]." "; //Ajoutons le groupe anonyme $pair_impair = "odd"; $ano_sql = "SELECT CONCAT(users.username, ' (', users.nom, ' ', users.prenom,')') AS pmbusercaption FROM `es_esgroups` LEFT JOIN users ON (users.userid = es_esgroups.esgroup_pmbusernum) WHERE `esgroup_id` = -1"; $ano_res = mysql_query($ano_sql, $dbh); if (!mysql_numrows($ano_res)) $ano_pmbusercaption = mysql_result(mysql_query("SELECT CONCAT(users.username, ' (', users.nom, ' ', users.prenom,')') FROM users WHERE userid = 1", $dbh), 0, 0); else $ano_pmbusercaption = mysql_result($ano_res, 0, 0); $tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./admin.php?categ=external_services&sub=esusergroups&action=editanonymous'\" "; print " <".$msg["admin_connecteurs_outauth_anonymgroupname"]."> ".$msg["admin_connecteurs_outauth_anonymgroupfullname"]." ".htmlentities($ano_pmbusercaption ,ENT_QUOTES, $charset)." "; $parity=1; foreach($esgroups->groups as &$aesgroup) { $pair_impair = $parity++ % 2 ? 'even' : 'odd'; $tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./admin.php?categ=external_services&sub=esusergroups&action=edit&id=$aesgroup->esgroup_id';\" "; print ""; print "".htmlentities($aesgroup->esgroup_name ,ENT_QUOTES, $charset).""; print "".htmlentities($aesgroup->esgroup_fullname ,ENT_QUOTES, $charset).""; print "".htmlentities($aesgroup->esgroup_pmbuser_username.' ('.$aesgroup->esgroup_pmbuser_lastname.' '.$aesgroup->esgroup_pmbuser_firstname.')' ,ENT_QUOTES, $charset).""; print "".count($aesgroup->esgroup_esusers).""; print "".count($aesgroup->esgroup_emprgroups).""; print ""; } if (!count($esgroups->groups)) { print ''.$msg["es_users_noesgroups"].''; } print " "; } function show_esgroup_form($id=0, $esg_name='', $esg_fullname="", $esg_pmbuserid='', $esg_esusers=array(), $esg_emprgroups=array()) { global $msg, $charset, $dbh; print '
'; if (!$id) print '

'.$msg['es_groups_add'].'

'; else print '

'.$msg['es_groups_edit'].'

'; print '
'; //id print ''; //name print '

'; print '
'; //fullname print '

'; print '
'; $pmbusers_sql = "SELECT userid, username, nom, prenom FROM users"; $pmbusers_res = mysql_query($pmbusers_sql, $dbh); $pmbusers = array(); while($pmbusers_row = mysql_fetch_assoc($pmbusers_res)) { $pmbusers[] = $pmbusers_row; } //pmbuser print '

'; print '
'; //es_users $es_users = new es_esusers(); print '

'; print '
'; //empr_groups $pmbemprgroups = array(); $pmbemprgroup_sql = "SELECT id_groupe, libelle_groupe FROM groupe"; $pmbemprgroup_res = mysql_query($pmbemprgroup_sql, $dbh); while($row=mysql_fetch_assoc($pmbemprgroup_res)) $pmbemprgroups[] = $row; print '

'; print '
'; //buttons print "
"; print " "; print ''; print "
"; if ($id) { print confirmation_delete("./admin.php?categ=external_services&sub=esusergroups&action=del&id="); print ""; } print "


"; print ''; } function show_esgroup_form_anonymous() { global $msg, $charset, $dbh; print '
'; print '

'.$msg['es_groups_edit'].'

'; print '
'; //id print ''; //name print '

'; print $msg["admin_connecteurs_outauth_anonymgroupname"]; print '
'; //fullname print '

'; print $msg["admin_connecteurs_outauth_anonymgroupfullname"]; print '
'; $pmbusers_sql = "SELECT userid, username, nom, prenom FROM users"; $pmbusers_res = mysql_query($pmbusers_sql, $dbh); $pmbusers = array(); while($pmbusers_row = mysql_fetch_assoc($pmbusers_res)) { $pmbusers[] = $pmbusers_row; } $sql = "SELECT esgroup_pmbusernum FROM es_esgroups WHERE esgroup_id = -1"; $res = mysql_query($sql, $dbh); if (!mysql_numrows($res)) $esg_pmbuserid = 1; else $esg_pmbuserid = mysql_result($res, 0, 0); //pmbuser print '

'; print '
'; //buttons print "
"; print " "; print ''; print "


"; print ''; } function update_esgroup_from_form() { global $msg, $charset,$dbh,$id; global $es_group_name, $es_group_fullname, $es_group_pmbuserid/*, $es_group_esusers*/, $es_group_emprgroups; if (!is_array($es_group_esusers)) $es_group_esusers = array($es_group_esusers); if (!is_array($es_group_emprgroups)) $es_group_emprgroups = array($es_group_emprgroups); if (!$id) { //Ajout d'un nouveau groupe if (!$es_group_name) { print $msg['es_group_error_emptyfield']; show_esgroup_form(0, stripslashes($es_group_name), stripslashes($es_group_fullname), stripslashes($es_group_pmbuserid), array(), $es_group_emprgroups); return false; } if (es_esgroup::name_exists($es_group_name)) { print $msg['es_group_error_namealreadyexists']; show_esgroup_form(0, stripslashes($es_group_name), stripslashes($es_group_fullname), stripslashes($es_group_pmbuserid), array(), $es_group_emprgroups); return false; } $new_esgroup = es_esgroup::add_new(); $new_esgroup->esgroup_name = $es_group_name; $new_esgroup->esgroup_fullname = $es_group_fullname; $new_esgroup->esgroup_pmbuserid = $es_group_pmbuserid; // $new_esgroup->esgroup_esusers = $es_group_esusers; $new_esgroup->esgroup_emprgroups = $es_group_emprgroups; $new_esgroup->commit_to_db(); } else { $thegroup = new es_esgroup($id); if ($the_group->error) { return false; } $thegroup->esgroup_name = $es_group_name; $thegroup->esgroup_fullname = $es_group_fullname; $thegroup->esgroup_pmbuserid = $es_group_pmbuserid; $thegroup->esgroup_esusers = $es_group_esusers; $thegroup->esgroup_emprgroups = $es_group_emprgroups; $thegroup->commit_to_db(); } return true; } switch ($action) { case "add": show_esgroup_form(0, '', ''); break; case "edit": $esg_name=''; $esg_fullname=''; $esg_pmbuserid=''; $esg_esusers=array(); $esg_emprgroups=array(); if ($id) { $the_group = new es_esgroup($id); if ($the_group->error) { $id = 0; } else { $esg_name=$the_group->esgroup_name; $esg_fullname=$the_group->esgroup_fullname; $esg_pmbuserid=$the_group->esgroup_pmbuserid; $esg_esusers=$the_group->esgroup_esusers; $esg_emprgroups=$the_group->esgroup_emprgroups; } } show_esgroup_form($id, $esg_name, $esg_fullname, $esg_pmbuserid, $esg_esusers, $esg_emprgroups); break; case "editanonymous": show_esgroup_form_anonymous(); break; case "update": if (update_esgroup_from_form()) list_groups(); break; case 'updateanonymous': if ($es_group_pmbuserid) { $es_group_pmbuserid += 0; $sql = "REPLACE INTO es_esgroups SET esgroup_id = -1, esgroup_name = '".$msg["admin_connecteurs_outauth_anonymgroupname"]."', esgroup_fullname = '".$msg["admin_connecteurs_outauth_anonymgroupfullname"]."', esgroup_pmbusernum = ".$es_group_pmbuserid; mysql_query($sql, $dbh); } list_groups(); break; case "del": if ($id) { $the_groupe = new es_esgroup($id); $the_groupe->delete(); } list_groups(); break; default: list_groups(); break; } ?>