<?php
header('Cache-Control: no-store');
header('Content-type: text/xml; charset=utf-8');
require('local-criteria.php');
require('global-php.php');
$verbindung = database_connection(
"<status>" . $lang_database_failure[$language] . "</status>");
$sortings = array(
'prep_course' => 'prep_course,',
'name' => 'name,',
'phone' => 'phone,',
'email' => 'email,'
);
$PHP_AUTH_USER = $_SERVER["PHP_AUTH_USER"];
$PHP_AUTH_PW = $_SERVER["PHP_AUTH_PW"];
$kurs = intval($_REQUEST["kurs"]);
$ergebnis = db_exec($verbindung,
"SELECT id FROM staff_authorization,authorized_course"
. " WHERE "
. login_query_clauses(
$PHP_AUTH_USER,
$PHP_AUTH_PW)
. " AND account=staff_authorization.id"
. " AND (course=$kurs"
. " OR -1=$kurs)"
. ";");
if (pg_numrows($ergebnis) < 1) {
header('WWW-Authenticate: Basic realm="Kursverwaltung"');
header("HTTP/1.0 401 Unauthorized");
echo '<status>' . $lang_authentication_failure[$language] . '</status>';
exit;
}
$authorization = pg_result($ergebnis, 0, 0);
?>
<course>
<?php
$course_period = option_value($course_period_option);
$ergebnis = db_exec($verbindung,
"SELECT * FROM ("
. "SELECT max(registration_person.registration),"
. "'<name>'||xml_string(person.name)"
. "||'</name>
' as name,"
. "'<first_name>'||xml_string(first_name)||'</first_name>
' as first_name,"
. "'<phone>'||xml_string(max(phone))||'</phone>
' as phone,"
. "'<email>'||xml_string(max(email))||'</email>
' as email,"
. "max(prep_course) as prep_course,"
. "'<commentary>'||xml_string(max(commentary))||'</commentary>
',"
. "'<id>'||person||'</id>
$registrant_xml_columns',max(registration_course.course)="
. $kurs
. ",(SELECT '<attending>'||priority||'</attending>
' FROM person_course WHERE person_course.person=person.id "
. "AND person_course.course="
. $kurs
. " LIMIT 1),(SELECT '
<attending_alternative>'||priority||'</attending_alternative>
'
FROM person_course "
. "WHERE person_course.person="
. "person.id "
. "AND (person_course.course="
. "max(registration_course.course) "
. "OR person_course.course="
. "min(registration_course.secondary)) "
. "AND NOT person_course.course="
. $kurs
. " LIMIT 1) FROM person,registration_person,"
. "registration_course$registrant_xml_tables,"
. "valid_registration,authorized_course "
. "WHERE (((registration_course.course="
. $kurs
. " OR $kurs=-1)"
. " AND authorized_course.course="
. "registration_course.course)"
. " OR ((secondary="
. $kurs
. " OR $kurs=-1)"
. " AND authorized_course.course="
. "secondary)) "
. "AND authorized_course.account=$authorization "
. "AND course_period=$course_period "
. "AND registration_person.registration"
. "=registration_course.registration "
. "AND registration_person.registration"
. "=valid_registration.registration "
. "AND person=person.id$registrant_xml_joins "
. "GROUP BY person,person.id,person.name,"
. "first_name) AS materialized "
. "ORDER BY "
. $sortings[$_REQUEST['sort']]
. "name,first_name;");
for ($lt = 0; $lt < pg_numrows($ergebnis); $lt++) {
$col = 0;
$registration_id = pg_result($ergebnis, $lt, $col++);
$name = pg_result($ergebnis, $lt, $col++);
$vorname = pg_result($ergebnis, $lt, $col++);
$telefon = pg_result($ergebnis, $lt, $col++);
$email = pg_result($ergebnis, $lt, $col++);
$prep_course = "<prep_course>"
. $prep_course_conditions[
pg_result($ergebnis, $lt, $col++)]
. "</prep_course>
";
$commentary = pg_result($ergebnis, $lt, $col++);
$id = pg_result($ergebnis, $lt, $col++);
$local_data = "";
for ($additional_column = 0;
$additional_column < $registrant_xml_column_count;
$additional_column++) {
$local_data .= pg_result($ergebnis, $lt, $col++);
}
$prioritaet = (pg_result($ergebnis, $lt, $col++) == 't')
? "<primary />\n"
: "<secondary />\n";
$teilnahme = pg_result($ergebnis, $lt, $col++);
$teilnahme_alternative = pg_result($ergebnis, $lt, $col++);
print("<person>
"
. $id
. $name
. $vorname
. $telefon
. $email
. $prep_course
. $commentary
. $prioritaet
. $teilnahme
. $teilnahme_alternative
. $local_data);
print additional_xml_query($local_data,$registration_id,$verbindung);
print("</person>\n");
}
db_close($verbindung);
?>
</course>