updated to delete links between schedule registrations and users when a schedule registration is deleted

This commit is contained in:
jacob 2010-06-22 19:35:36 +00:00
parent 00716cd84d
commit b3448b7c7c

View File

@ -33,47 +33,47 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){
if($school) {
switch($_GET['action']) {
case "load":
$id=intval($_GET['id']);
$q=mysql_query("SELECT schedule.*,
events.eventtype,
events.website,
events.summary,
events.name,
locations.name AS location
FROM schedule
JOIN events ON schedule.events_id=events.id
JOIN locations ON schedule.locations_id=locations.id
WHERE schedule.conferences_id='{$conference['id']}'
AND schedule.id='{$id}'");
echo mysql_error();
$r=mysql_fetch_object($q);
if($r->title!=$r->name) {
$name="($r->name)";
}
echo "<h3>$r->title $name</h3>";
$id=intval($_GET['id']);
$q=mysql_query("SELECT schedule.*,
events.eventtype,
events.website,
events.summary,
events.name,
locations.name AS location
FROM schedule
JOIN events ON schedule.events_id=events.id
JOIN locations ON schedule.locations_id=locations.id
WHERE schedule.conferences_id='{$conference['id']}'
AND schedule.id='{$id}'");
echo mysql_error();
$r=mysql_fetch_object($q);
if($r->title!=$r->name) {
$name="($r->name)";
}
echo "<h3>$r->title $name</h3>";
switch($_GET['tab']) {
case "summary":
echo "<table width=\"95%\" class=\"tableview\">";
echo "<tr>";
echo "<th>".i18n("Time")."</th>\n";
echo "<th>".i18n("Duration")."</th>\n";
echo "<th>".i18n("Location")."</th>\n";
echo "</tr>\n";
echo "<tr>";
echo "<td>".format_time(strtotime($r->hour.":".$r->minute))."</td>\n";
echo "<td>$r->duration minutes</td>\n";
echo "<td>$r->location</td>\n";
echo "</tr></table>\n";
echo "<br />";
echo "<h4>".i18n("Summary")."</h4>\n";
echo nl2br(trim($r->summary));
echo "<br />\n";
echo "<br />\n";
echo "<table width=\"95%\" class=\"tableview\">";
echo "<tr>";
echo "<th>".i18n("Time")."</th>\n";
echo "<th>".i18n("Duration")."</th>\n";
echo "<th>".i18n("Location")."</th>\n";
echo "</tr>\n";
echo "<tr>";
echo "<td>".format_time(strtotime($r->hour.":".$r->minute))."</td>\n";
echo "<td>$r->duration minutes</td>\n";
echo "<td>$r->location</td>\n";
echo "</tr></table>\n";
echo "<br />";
echo "<h4>".i18n("Summary")."</h4>\n";
echo nl2br(trim($r->summary));
echo "<br />\n";
echo "<br />\n";
if($r->website) {
echo "<a target=\"_blank\" href=\"$r->website\">".i18n("Click here for the full event description")."</a> <br />\n";
}
if($r->website) {
echo "<a target=\"_blank\" href=\"$r->website\">".i18n("Click here for the full event description")."</a> <br />\n";
}
break;
case "register":
@ -121,20 +121,19 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){
$scheduleid=intval($_POST['scheduleid']);
$conferenceid=$conference['id'];
$q=mysql_query("SELECT schedule.*,
events.eventtype,
events.website,
events.summary,
events.name,
locations.name AS location
FROM schedule
JOIN events ON schedule.events_id=events.id
JOIN locations ON schedule.locations_id=locations.id
WHERE schedule.conferences_id='{$conference['id']}'
AND schedule.id='{$scheduleid}'");
$schedule=mysql_fetch_object($q);
echo mysql_error();
$q=mysql_query("SELECT schedule.*,
events.eventtype,
events.website,
events.summary,
events.name,
locations.name AS location
FROM schedule
JOIN events ON schedule.events_id=events.id
JOIN locations ON schedule.locations_id=locations.id
WHERE schedule.conferences_id='{$conference['id']}'
AND schedule.id='{$scheduleid}'");
$schedule=mysql_fetch_object($q);
echo mysql_error();
switch($_POST['regaction']) {
case "register":
@ -155,9 +154,34 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){
break;
case "unregister":
$q=mysql_query("SELECT * FROM schedule_registrations WHERE so_teams_id=$teamid AND schedule_id=$scheduleid AND conferences_id=$conferenceid");
if(mysql_num_rows($q)) {
// delete any links between students and this registrationa
$q = mysql_query(
" SELECT users_uid, schedule_registrations_id" .
" FROM schedule_registrations_users_link srul" .
" JOIN schedule_registrations sr ON sr.id = srul.schedule_registrations_id" .
" WHERE sr.so_teams_id = '$teamid'" .
" AND sr.schedule_id='$scheduleid'" .
" AND sr.conferences_id='$conferenceid'"
);
while($r = mysql_fetch_array($q)){
$idSet[] = $r['users_uid'];
$srid = $r['schedule_registrations_id'];
}
if(is_array($idSet)){
$query =
" DELETE FROM schedule_registrations_users_link" .
" WHERE schedule_registrations_id = $srid" .
" AND users_uid IN(" . implode(',', $idSet) . ")";
$q = mysql_query($query);
}
// delete the registrations themselves
mysql_query("DELETE FROM schedule_registrations WHERE so_teams_id='$teamid' AND schedule_id='$scheduleid' AND conferences_id='$conferenceid'");
happy_("Successfully unregistered the team from this scheduled event");
}
else {