';
//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 '';
}
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;
}
?>