From 2ff9765fdf6c196599434d696ec72f52da4c8b60 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Wed, 19 Jan 2011 16:50:30 -0500 Subject: [PATCH] fixed bug when generating shows for calendar. --- application/models/Shows.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/application/models/Shows.php b/application/models/Shows.php index ec35cfcd0..ab78b5feb 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -540,17 +540,22 @@ class Show { $newDate = $row["first_show"]; } - $shows[] = $this->makeFullCalendarEvent($row, $newDate); - + $new_epoch = strtotime($newDate); $end_epoch = strtotime($end); + if(!is_null($row["last_show"])) { + $show_end_epoch = strtotime($row["last_show"]); + } + + if(isset($show_end_epoch) && $show_end_epoch <= $new_epoch) { + continue; + } + + $shows[] = $this->makeFullCalendarEvent($row, $newDate); + //add repeating events until the show end is reached or fullcalendar's end date is reached. if($row["repeats"]) { - if(!is_null($row["last_show"])) { - $show_end_epoch = strtotime($row["last_show"]); - } - while(true) { $diff = "SELECT date '{$newDate}' + integer '7'"; @@ -562,7 +567,7 @@ class Show { $shows[] = $this->makeFullCalendarEvent($row, $repeatDate); } //case for non-ending shows. - else if(!isset($show_end_epoch) && $repeat_epoch < $end_epoch) { + else if(is_null($show_end_epoch) && $repeat_epoch < $end_epoch) { $shows[] = $this->makeFullCalendarEvent($row, $repeatDate); } else { @@ -571,7 +576,9 @@ class Show { $newDate = $repeatDate; } - } + } + + unset($show_end_epoch); } return $shows;