".$msg["es_group_name"]." ".$msg["es_group_fullname"]." ".$msg["connector_out_authorization_authorizedsourcecount"]." "; //Ajoutons l'utilisateur anonyme $sql = "SELECT COUNT(1) FROM connectors_out_sources_esgroups WHERE connectors_out_source_esgroup_esgroupnum = -1"; $anonymous_count = mysql_result(mysql_query($sql, $dbh), 0, 0); $pair_impair = "odd"; $tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./admin.php?categ=connecteurs&sub=out_auth&action=editanonymous'\" "; print " <".$msg["admin_connecteurs_outauth_anonymgroupname"]."> ".$msg["admin_connecteurs_outauth_anonymgroupfullname"]." ".$anonymous_count." "; $parity=1; foreach($esgroups->groups as &$aesgroup) { //Récupérons le nombre de sources autorisées dans le groupe $sql = "SELECT COUNT(1) FROM connectors_out_sources_esgroups WHERE connectors_out_source_esgroup_esgroupnum = ".$aesgroup->esgroup_id; $count = mysql_result(mysql_query($sql, $dbh), 0, 0); $pair_impair = $parity++ % 2 ? 'even' : 'odd'; $tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./admin.php?categ=connecteurs&sub=out_auth&action=edit&id=$aesgroup->esgroup_id';\" "; print ""; print "".htmlentities($aesgroup->esgroup_name ,ENT_QUOTES, $charset).""; print "".htmlentities($aesgroup->esgroup_fullname ,ENT_QUOTES, $charset).""; print "".$count.""; print ""; } print ""; } function show_auth_edit_form($group_id) { global $msg, $charset, $dbh; $the_group = new es_esgroup($group_id); if ($the_group->error) { exit(); } print '
'; print '

'.$msg['admin_connecteurs_outauth_edit'].'

'; print '
'; //id print ''; //Nom du groupe print '

'; print $the_group->esgroup_name; print '

'; //Nom complet du groupe print '

'; print $the_group->esgroup_fullname; print '

'; $current_sources=array(); $current_sql = "SELECT connectors_out_source_esgroup_sourcenum FROM connectors_out_sources_esgroups WHERE connectors_out_source_esgroup_esgroupnum = ".$group_id; $current_res = mysql_query($current_sql, $dbh); while($row = mysql_fetch_assoc($current_res)) { $current_sources[] = $row["connectors_out_source_esgroup_sourcenum"]; } $data_sql = "SELECT connectors_out_sources_connectornum, connectors_out_source_id, connectors_out_source_name, EXISTS(SELECT 1 FROM connectors_out_sources_esgroups WHERE connectors_out_source_esgroup_sourcenum = connectors_out_source_id AND connectors_out_source_esgroup_esgroupnum = ".$group_id.") AS authorized FROM connectors_out_sources ORDER BY connectors_out_sources_connectornum"; $data_res = mysql_query($data_sql, $dbh); $current_connid = 0; print '

'; while($asource=mysql_fetch_assoc($data_res)) { if ($current_connid != $asource["connectors_out_sources_connectornum"]) { if ($current_connid) print '
'; $current_connid = $asource["connectors_out_sources_connectornum"]; } print ''; print $asource["connectors_out_source_name"]; print '
'; } print '
'; //buttons print "
"; print " "; print ''; print "


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

'.$msg['admin_connecteurs_outauth_edit'].'

'; print '
'; //Nom du groupe print '

'; print '<'.$msg["admin_connecteurs_outauth_anonymgroupname"].'>'; print '

'; //Nom complet du groupe print '

'; print $msg["admin_connecteurs_outauth_anonymgroupfullname"]; print '

'; $current_sources=array(); $current_sql = "SELECT connectors_out_source_esgroup_sourcenum FROM connectors_out_sources_esgroups WHERE connectors_out_source_esgroup_esgroupnum = -1"; $current_res = mysql_query($current_sql, $dbh); while($row = mysql_fetch_assoc($current_res)) { $current_sources[] = $row["connectors_out_source_esgroup_sourcenum"]; } $data_sql = "SELECT connectors_out_sources_connectornum, connectors_out_source_id, connectors_out_source_name, EXISTS(SELECT 1 FROM connectors_out_sources_esgroups WHERE connectors_out_source_esgroup_sourcenum = connectors_out_source_id AND connectors_out_source_esgroup_esgroupnum = -1) AS authorized FROM connectors_out_sources ORDER BY connectors_out_sources_connectornum"; $data_res = mysql_query($data_sql, $dbh); $current_connid = 0; print '

'; while($asource=mysql_fetch_assoc($data_res)) { if ($current_connid != $asource["connectors_out_sources_connectornum"]) { if ($current_connid) print '
'; $current_connid = $asource["connectors_out_sources_connectornum"]; } print ''; print $asource["connectors_out_source_name"]; print '
'; } print '
'; //buttons print "
"; print " "; print ''; print "


"; print ''; } if (!isset($action)) $action=""; switch ($action) { case "edit": if (!isset($id) || !$id) { list_esgroups(); exit(); } show_auth_edit_form($id+0); break; case "editanonymous": show_auth_edit_form_anonymous(); break; case "update": if (isset($id) && $id) { array_walk($authorized_sources, create_function('&$a', '$a+=0;')); //Virons de la liste ce qui n'est pas entier //Croisons ce que l'on nous propose avec ce qui existe vraiment dans la base //Vérifions que les sources existents $sql = "SELECT connectors_out_source_id FROM connectors_out_sources WHERE connectors_out_source_id IN (".implode(",", $authorized_sources).')'; $res = mysql_query($sql, $dbh); $final_authorized_sources = array(); while ($row=mysql_fetch_assoc($res)) $final_authorized_sources[] = $row["connectors_out_source_id"]; //Vérifions que le groupe existe $esgroup = new es_esgroup($id); if ($esgroup->error) { exit(); } //On vire ce qui existe déjà: $sql = "DELETE FROM connectors_out_sources_esgroups WHERE connectors_out_source_esgroup_esgroupnum = ".$id; mysql_query($sql, $dbh); //Tout est bon? On insert $values = array(); $insert_sql = "INSERT INTO connectors_out_sources_esgroups (connectors_out_source_esgroup_sourcenum, connectors_out_source_esgroup_esgroupnum) VALUES "; foreach ($final_authorized_sources as $an_authorized_source) { $values[] = '('.$an_authorized_source.','.$id.')'; } $insert_sql .= implode(",", $values); mysql_query($insert_sql, $dbh); } list_esgroups(); break; case "updateanonymous": if (!$authorized_sources) $final_authorized_sources=array(); else { array_walk($authorized_sources, create_function('&$a', '$a+=0;')); //Virons de la liste ce qui n'est pas entier //Croisons ce que l'on nous propose avec ce qui existe vraiment dans la base //Vérifions que les sources existents $sql = "SELECT connectors_out_source_id FROM connectors_out_sources WHERE connectors_out_source_id IN (".implode(",", $authorized_sources).')'; $res = mysql_query($sql, $dbh); $final_authorized_sources = array(); while ($row=mysql_fetch_assoc($res)) $final_authorized_sources[] = $row["connectors_out_source_id"]; } //On vire ce qui existe déjà: $sql = "DELETE FROM connectors_out_sources_esgroups WHERE connectors_out_source_esgroup_esgroupnum = -1"; mysql_query($sql, $dbh); //Tout est bon? On insert $values = array(); $insert_sql = "INSERT INTO connectors_out_sources_esgroups (connectors_out_source_esgroup_sourcenum, connectors_out_source_esgroup_esgroupnum) VALUES "; foreach ($final_authorized_sources as $an_authorized_source) { $values[] = '('.$an_authorized_source.', -1)'; } $insert_sql .= implode(",", $values); mysql_query($insert_sql, $dbh); list_esgroups(); break; default: list_esgroups(); break; } ?>