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

@ -135,7 +135,6 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){
$schedule=mysql_fetch_object($q);
echo mysql_error();
switch($_POST['regaction']) {
case "register":
$q=mysql_query("SELECT * FROM schedule_registrations WHERE so_teams_id=$teamid AND schedule_id=$scheduleid AND conferences_id=$conferenceid");
@ -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 {