diff --git a/admin/schedule.php b/admin/schedule.php index 31fad7f..7c8bf3d 100644 --- a/admin/schedule.php +++ b/admin/schedule.php @@ -155,10 +155,15 @@ exit; } else if($_GET['action']=="deleteevent") { - //FIXME: dont let it delete an event that is already in use! - //FIXME: and if we do, delete everything that its been linked to! $id=intval($_POST['id']); - mysql_query("DELETE FROM schedule WHERE conferences_id='{$conference['id']}' AND id='{$id}'"); + $q=mysql_query("SELECT * FROM schedule_registrations WHERE schedule_id='{$id}' AND conferences_id='{$conference['id']}'"); + if(mysql_num_rows($q)) { + error_("Cannot remove an event that has teams registered for it. Remove the teams first"); + } + else { + mysql_query("DELETE FROM schedule WHERE conferences_id='{$conference['id']}' AND id='{$id}'"); + happy_("Event successfully removed from the schedule"); + } exit; } else { @@ -289,7 +294,7 @@ function deleteEvent(event,id) { event.stopPropagation(); - if(confirmClick('Are you sure you want to delete this event from the schedule?')) { + if(confirmClick('Are you sure you want to remove this event from the schedule?')) { $("#debug").load('schedule.php?action=deleteevent',{id:id},function() { changeDate(); });