From b3448b7c7c4be7da99ea1bab46e3ba6a86b0893a Mon Sep 17 00:00:00 2001 From: jacob Date: Tue, 22 Jun 2010 19:35:36 +0000 Subject: [PATCH] updated to delete links between schedule registrations and users when a schedule registration is deleted --- schoolschedule_event_tab.php | 126 +++++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 51 deletions(-) diff --git a/schoolschedule_event_tab.php b/schoolschedule_event_tab.php index 094814c..4c2823b 100644 --- a/schoolschedule_event_tab.php +++ b/schoolschedule_event_tab.php @@ -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 "

$r->title $name

"; + $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 "

$r->title $name

"; switch($_GET['tab']) { case "summary": - echo ""; - echo ""; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo ""; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
".i18n("Time")."".i18n("Duration")."".i18n("Location")."
".format_time(strtotime($r->hour.":".$r->minute))."$r->duration minutes$r->location
\n"; - echo "
"; - echo "

".i18n("Summary")."

\n"; - echo nl2br(trim($r->summary)); - echo "
\n"; - echo "
\n"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
".i18n("Time")."".i18n("Duration")."".i18n("Location")."
".format_time(strtotime($r->hour.":".$r->minute))."$r->duration minutes$r->location
\n"; + echo "
"; + echo "

".i18n("Summary")."

\n"; + echo nl2br(trim($r->summary)); + echo "
\n"; + echo "
\n"; - if($r->website) { - echo "website\">".i18n("Click here for the full event description")."
\n"; - } + if($r->website) { + echo "website\">".i18n("Click here for the full event description")."
\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 {