get_display_list(); } function show_auth_edit_form($group_id) { global $msg; $the_group = new es_esgroup($group_id); if ($the_group->error) { exit(); } $content_form = ''; //Nom du groupe $content_form .= '

'; $content_form .= $the_group->esgroup_name; $content_form .= '

'; //Nom complet du groupe $content_form .= '

'; $content_form .= $the_group->esgroup_fullname; $content_form .= '

'; $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 = pmb_mysql_query($current_sql); while($row = pmb_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 = pmb_mysql_query($data_sql); $current_connid = 0; $content_form .= '

'; while($asource=pmb_mysql_fetch_assoc($data_res)) { if ($current_connid != $asource["connectors_out_sources_connectornum"]) { if ($current_connid) $content_form .= '
'; $current_connid = $asource["connectors_out_sources_connectornum"]; } $content_form .= ''; $content_form .= $asource["connectors_out_source_name"]; $content_form .= '
'; } $content_form .= '
'; $interface_form = new interface_admin_form('form_outauth'); $interface_form->set_label($msg["admin_connecteurs_outauth_edit"]); $interface_form->set_object_id($group_id) ->set_content_form($content_form); print $interface_form->get_display_parameters(); } function show_auth_edit_form_anonymous() { global $msg; 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 = pmb_mysql_query($current_sql); while($row = pmb_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 = pmb_mysql_query($data_sql); $current_connid = 0; print '

'; while($asource=pmb_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 ''; } switch ($action) { case "edit": if (!isset($id) || !$id) { list_esgroups(); exit(); } show_auth_edit_form((int)$id); break; case "editanonymous": show_auth_edit_form_anonymous(); break; case "update": if (isset($id) && $id) { array_walk($authorized_sources, function(&$a) {$a = intval($a);}); //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 = pmb_mysql_query($sql); $final_authorized_sources = array(); while ($row=pmb_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; pmb_mysql_query($sql); //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); pmb_mysql_query($insert_sql); } list_esgroups(); break; case "updateanonymous": if (!$authorized_sources) $final_authorized_sources=array(); else { array_walk($authorized_sources, function(&$a) {$a = intval($a);}); //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 = pmb_mysql_query($sql); $final_authorized_sources = array(); while ($row=pmb_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"; pmb_mysql_query($sql); //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)'; } if(!empty($values)) { $insert_sql .= implode(",", $values); pmb_mysql_query($insert_sql); } list_esgroups(); break; default: list_esgroups(); break; } ?>