CC-1985: Automatic rebroadcast of recorded content
populates rebroadcast show instances now, added a new table cc_show_rebroadcast, added columns record, rebroadcast, instance_id, file_id to cc_show_instances table. added column record to cc_show_days.
This commit is contained in:
parent
eb2caf0adc
commit
6ef4169315
36 changed files with 4776 additions and 155 deletions
|
@ -117,8 +117,16 @@ class Show {
|
|||
|
||||
$showId = $show->getDbId();
|
||||
|
||||
if($data['add_show_record']){
|
||||
$isRecorded = 1;
|
||||
}
|
||||
else {
|
||||
$isRecorded = 0;
|
||||
}
|
||||
|
||||
//don't set day for monthly repeat type, it's invalid.
|
||||
if($data['add_show_repeats'] && $data["add_show_repeat_type"] == 2) {
|
||||
|
||||
$showDay = new CcShowDays();
|
||||
$showDay->setDbFirstShow($data['add_show_start_date']);
|
||||
$showDay->setDbLastShow($endDate);
|
||||
|
@ -126,7 +134,9 @@ class Show {
|
|||
$showDay->setDbDuration($data['add_show_duration']);
|
||||
$showDay->setDbRepeatType($repeat_type);
|
||||
$showDay->setDbShowId($showId);
|
||||
$showDay->setDbRecord($isRecorded);
|
||||
$showDay->save();
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -157,10 +167,20 @@ class Show {
|
|||
$showDay->setDbDay($day);
|
||||
$showDay->setDbRepeatType($repeat_type);
|
||||
$showDay->setDbShowId($showId);
|
||||
$showDay->setDbRecord($isRecorded);
|
||||
$showDay->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($data['add_show_rebroadcast']) {
|
||||
|
||||
$showRebroad = new CcShowRebroadcast();
|
||||
$showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_1']);
|
||||
$showRebroad->setDbStartTime($data['add_show_start_time_1']);
|
||||
$showRebroad->setDbShowId($showId);
|
||||
$showRebroad->save();
|
||||
}
|
||||
|
||||
if(is_array($data['add_show_hosts'])) {
|
||||
//add selected hosts to cc_show_hosts table.
|
||||
|
@ -178,7 +198,8 @@ class Show {
|
|||
public static function getShows($start_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=FALSE) {
|
||||
global $CC_DBC;
|
||||
|
||||
$sql = "SELECT starts, ends, show_id, name, description, color, background_color, cc_show_instances.id AS instance_id
|
||||
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name, description,
|
||||
color, background_color, cc_show_instances.id AS instance_id
|
||||
FROM cc_show_instances
|
||||
LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id";
|
||||
|
||||
|
@ -210,8 +231,21 @@ class Show {
|
|||
return $CC_DBC->GetAll($sql);
|
||||
}
|
||||
|
||||
//for a show with repeat_type == -1
|
||||
private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $end_timestamp) {
|
||||
private static function setNextPop($next_date, $show_id, $day) {
|
||||
|
||||
$nextInfo = explode(" ", $next_date);
|
||||
|
||||
$repeatInfo = CcShowDaysQuery::create()
|
||||
->filterByDbShowId($show_id)
|
||||
->filterByDbDay($day)
|
||||
->findOne();
|
||||
|
||||
$repeatInfo->setDbNextPopDate($nextInfo[0])
|
||||
->save();
|
||||
}
|
||||
|
||||
//for a show with repeat_type == -1
|
||||
private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp) {
|
||||
global $CC_DBC;
|
||||
|
||||
$next_date = $first_show." ".$start_time;
|
||||
|
@ -227,25 +261,14 @@ class Show {
|
|||
$newShow->setDbShowId($show_id);
|
||||
$newShow->setDbStarts($start);
|
||||
$newShow->setDbEnds($end);
|
||||
$newShow->setDbRecord($record);
|
||||
$newShow->save();
|
||||
}
|
||||
}
|
||||
|
||||
private static function setNextPop($next_date, $show_id, $day) {
|
||||
|
||||
$nextInfo = explode(" ", $next_date);
|
||||
|
||||
$repeatInfo = CcShowDaysQuery::create()
|
||||
->filterByDbShowId($show_id)
|
||||
->filterByDbDay($day)
|
||||
->findOne();
|
||||
|
||||
$repeatInfo->setDbNextPopDate($nextInfo[0])
|
||||
->save();
|
||||
}
|
||||
|
||||
//for a show with repeat_type == 0
|
||||
private static function populateWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
|
||||
//for a show with repeat_type == 0,1,2
|
||||
private static function populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
||||
$start_time, $duration, $day, $record, $end_timestamp, $interval) {
|
||||
global $CC_DBC;
|
||||
|
||||
if(isset($next_pop_date)) {
|
||||
|
@ -255,6 +278,9 @@ class Show {
|
|||
$next_date = $first_show." ".$start_time;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
|
||||
while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
|
||||
|
||||
$start = $next_date;
|
||||
|
@ -266,90 +292,55 @@ class Show {
|
|||
$newShow->setDbShowId($show_id);
|
||||
$newShow->setDbStarts($start);
|
||||
$newShow->setDbEnds($end);
|
||||
$newShow->setDbRecord($record);
|
||||
$newShow->save();
|
||||
|
||||
$sql = "SELECT timestamp '{$start}' + interval '7 days'";
|
||||
$show_instance_id = $newShow->getDbId();
|
||||
|
||||
foreach($rebroadcasts as $rebroadcast) {
|
||||
|
||||
$timeinfo = explode(" ", $next_date);
|
||||
|
||||
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
|
||||
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
|
||||
|
||||
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
|
||||
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
|
||||
|
||||
$newRebroadcastInstance = new CcShowInstances();
|
||||
$newRebroadcastInstance->setDbShowId($show_id);
|
||||
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
|
||||
$newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
|
||||
$newRebroadcastInstance->setDbRecord(0);
|
||||
$newRebroadcastInstance->setDbRebroadcast(1);
|
||||
$newRebroadcastInstance->setDbOriginalShow($show_instance_id);
|
||||
$newRebroadcastInstance->save();
|
||||
}
|
||||
|
||||
$sql = "SELECT timestamp '{$start}' + interval '{$interval}'";
|
||||
$next_date = $CC_DBC->GetOne($sql);
|
||||
}
|
||||
|
||||
Show::setNextPop($next_date, $show_id, $day);
|
||||
}
|
||||
|
||||
//for a show with repeat_type == 1
|
||||
private static function populateBiWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
|
||||
global $CC_DBC;
|
||||
|
||||
if(isset($next_pop_date)) {
|
||||
$next_date = $next_pop_date." ".$start_time;
|
||||
}
|
||||
else {
|
||||
$next_date = $first_show." ".$start_time;
|
||||
}
|
||||
|
||||
while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
|
||||
|
||||
$start = $next_date;
|
||||
|
||||
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
||||
$end = $CC_DBC->GetOne($sql);
|
||||
|
||||
$newShow = new CcShowInstances();
|
||||
$newShow->setDbShowId($show_id);
|
||||
$newShow->setDbStarts($start);
|
||||
$newShow->setDbEnds($end);
|
||||
$newShow->save();
|
||||
|
||||
$sql = "SELECT timestamp '{$start}' + interval '14 days'";
|
||||
$next_date = $CC_DBC->GetOne($sql);
|
||||
}
|
||||
|
||||
Show::setNextPop($next_date, $show_id, $day);
|
||||
}
|
||||
|
||||
//for a show with repeat_type == 2
|
||||
private static function populateMonthlyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
|
||||
global $CC_DBC;
|
||||
|
||||
if(isset($next_pop_date)) {
|
||||
$next_date = $next_pop_date." ".$start_time;
|
||||
}
|
||||
else {
|
||||
$next_date = $first_show." ".$start_time;
|
||||
}
|
||||
|
||||
while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
|
||||
|
||||
$start = $next_date;
|
||||
|
||||
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
||||
$end = $CC_DBC->GetOne($sql);
|
||||
|
||||
$newShow = new CcShowInstances();
|
||||
$newShow->setDbShowId($show_id);
|
||||
$newShow->setDbStarts($start);
|
||||
$newShow->setDbEnds($end);
|
||||
$newShow->save();
|
||||
|
||||
$sql = "SELECT timestamp '{$start}' + interval '1 month'";
|
||||
$next_date = $CC_DBC->GetOne($sql);
|
||||
}
|
||||
|
||||
Show::setNextPop($next_date, $show_id, $day);
|
||||
}
|
||||
|
||||
private static function populateShow($repeat_type, $show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
|
||||
private static function populateShow($repeat_type, $show_id, $next_pop_date,
|
||||
$first_show, $last_show, $start_time, $duration, $day, $record, $end_timestamp) {
|
||||
|
||||
if($repeat_type == -1) {
|
||||
Show::populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $end_timestamp);
|
||||
Show::populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp);
|
||||
}
|
||||
else if($repeat_type == 0) {
|
||||
Show::populateWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp);
|
||||
Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
||||
$start_time, $duration, $day, $record, $end_timestamp, '7 days');
|
||||
}
|
||||
else if($repeat_type == 1) {
|
||||
Show::populateBiWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp);
|
||||
Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
||||
$start_time, $duration, $day, $record, $end_timestamp, '14 days');
|
||||
}
|
||||
else if($repeat_type == 2) {
|
||||
Show::populateMonthlyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp);
|
||||
Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
||||
$start_time, $duration, $day, $record, $end_timestamp, '1 month');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,7 +354,7 @@ class Show {
|
|||
|
||||
foreach($res as $row) {
|
||||
Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
|
||||
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $showsPopUntil);
|
||||
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $showsPopUntil);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,7 +378,7 @@ class Show {
|
|||
|
||||
foreach($res as $row) {
|
||||
Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
|
||||
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $end_timestamp);
|
||||
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $end_timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,9 +410,16 @@ class Show {
|
|||
private static function makeFullCalendarEvent($show, $options=array()) {
|
||||
global $CC_DBC;
|
||||
|
||||
if($show["rebroadcast"]) {
|
||||
$title = "REBROADCAST ".$show["name"];
|
||||
}
|
||||
else {
|
||||
$title = $show["name"];
|
||||
}
|
||||
|
||||
$event = array(
|
||||
"id" => $show["instance_id"],
|
||||
"title" => $show["name"],
|
||||
"title" => $title,
|
||||
"start" => $show["starts"],
|
||||
"end" => $show["ends"],
|
||||
"allDay" => false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue