fixed bug when generating shows for calendar.

This commit is contained in:
naomiaro 2011-01-19 16:50:30 -05:00
parent 909e37934f
commit 2ff9765fdf

View file

@ -540,17 +540,22 @@ class Show {
$newDate = $row["first_show"]; $newDate = $row["first_show"];
} }
$shows[] = $this->makeFullCalendarEvent($row, $newDate); $new_epoch = strtotime($newDate);
$end_epoch = strtotime($end); $end_epoch = strtotime($end);
//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"])) { if(!is_null($row["last_show"])) {
$show_end_epoch = strtotime($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"]) {
while(true) { while(true) {
$diff = "SELECT date '{$newDate}' + integer '7'"; $diff = "SELECT date '{$newDate}' + integer '7'";
@ -562,7 +567,7 @@ class Show {
$shows[] = $this->makeFullCalendarEvent($row, $repeatDate); $shows[] = $this->makeFullCalendarEvent($row, $repeatDate);
} }
//case for non-ending shows. //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); $shows[] = $this->makeFullCalendarEvent($row, $repeatDate);
} }
else { else {
@ -572,6 +577,8 @@ class Show {
$newDate = $repeatDate; $newDate = $repeatDate;
} }
} }
unset($show_end_epoch);
} }
return $shows; return $shows;