can schedule in a show (just one playlist currently), schedule table is cleared of shows contents when a show is deleted, can clear a show of contents.

This commit is contained in:
Naomi 2010-12-16 15:15:43 -05:00
parent 1b216c16dd
commit d95c4ab0fc
24 changed files with 2825 additions and 300 deletions

View file

@ -3,10 +3,12 @@
class Show {
private $_user;
private $_showId;
public function __construct($user=NULL)
public function __construct($user=NULL, $showId=NULL)
{
$this->_user = $user;
$this->_user = $user;
$this->_showId = $showId;
}
//end dates are non inclusive.
@ -187,7 +189,27 @@ class Show {
}
public function scheduleShow($start, $plId) {
if($this->_user->isHost($this->_showId)) {
$sched = new ScheduleGroup();
$groupId = $sched->add($start, null, $plId);
$groupsched = new CcShowSchedule();
$groupsched->setDbShowId($this->_showId);
$groupsched->setDbGroupId($groupId);
$groupsched->save();
}
}
public function deleteShow($showId, $dayId=NULL) {
$groups = CcShowScheduleQuery::create()->filterByDbShowId($showId)->find();
foreach($groups as $group) {
$groupId = $group->getDbGroupId();
CcScheduleQuery::create()->filterByDbGroupId($groupId)->delete();
}
CcShowQuery::create()->filterByDbId($showId)->delete();
}
@ -258,55 +280,52 @@ class Show {
foreach($res as $row) {
if(!is_null($start)) {
$timeDiff = "SELECT date '{$start}' - date '{$row["first_show"]}' as diff";
$diff = $CC_DBC->GetOne($timeDiff);
$timeDiff = "SELECT date '{$start}' - date '{$row["first_show"]}' as diff";
$diff = $CC_DBC->GetOne($timeDiff);
if($diff > 0) {
if($diff > 0) {
$add = ($diff % 7 === 0) ? $diff : $diff + (7 - $diff % 7);
$add = ($diff % 7 === 0) ? $diff : $diff + (7 - $diff % 7);
$new = "SELECT date '{$row["first_show"]}' + integer '{$add}'";
$newDate = $CC_DBC->GetOne($new);
}
else {
$newDate = $row["first_show"];
}
$new = "SELECT date '{$row["first_show"]}' + integer '{$add}'";
$newDate = $CC_DBC->GetOne($new);
}
else {
$newDate = $row["first_show"];
$shows[] = $this->makeFullCalendarEvent($row, $newDate);
$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"])) {
$show_end_epoch = strtotime($row["last_show"]);
}
$shows[] = $this->makeFullCalendarEvent($row, $newDate);
$end_epoch = strtotime($end);
while(true) {
//add repeating events until the show end is reached or fullcalendar's end date is reached.
if($row["repeats"]) {
$diff = "SELECT date '{$newDate}' + integer '7'";
$repeatDate = $CC_DBC->GetOne($diff);
$repeat_epoch = strtotime($repeatDate);
if(!is_null($row["last_show"])) {
$show_end_epoch = strtotime($row["last_show"]);
//show has finite duration.
if (isset($show_end_epoch) && $repeat_epoch < $show_end_epoch && $repeat_epoch < $end_epoch) {
$shows[] = $this->makeFullCalendarEvent($row, $repeatDate);
}
//case for non-ending shows.
else if(!isset($show_end_epoch) && $repeat_epoch < $end_epoch) {
$shows[] = $this->makeFullCalendarEvent($row, $repeatDate);
}
else {
break;
}
while(true) {
$diff = "SELECT date '{$newDate}' + integer '7'";
$repeatDate = $CC_DBC->GetOne($diff);
$repeat_epoch = strtotime($repeatDate);
//show has finite duration.
if (isset($show_end_epoch) && $repeat_epoch < $show_end_epoch && $repeat_epoch < $end_epoch) {
$shows[] = $this->makeFullCalendarEvent($row, $repeatDate);
}
//case for non-ending shows.
else if(!isset($show_end_epoch) && $repeat_epoch < $end_epoch) {
$shows[] = $this->makeFullCalendarEvent($row, $repeatDate);
}
else {
break;
}
$newDate = $repeatDate;
}
}
}
$newDate = $repeatDate;
}
}
}
return $shows;