CC-4961: Show linking

This commit is contained in:
denise 2013-04-26 13:43:30 -04:00
parent 0f1383d541
commit 52655ab375
11 changed files with 164 additions and 75 deletions

View file

@ -136,17 +136,6 @@ class Application_Service_SchedulerService
return $dt;
}
/**
*
* Enter description here ...
* @param $nextStartDT
* @param $showStamp array of ccSchedule objects
*/
private static function insertItems($showStamp, $ccShow)
{
}
public static function fillLinkedShows($ccShow)
{
if ($ccShow->isLinked()) {
@ -167,40 +156,47 @@ class Application_Service_SchedulerService
->filterByDbInstanceId($ccSchedule->getDbInstanceId())
->orderByDbStarts()
->find();
} else {
break;
}
//need to find out which linked instances are empty
foreach ($ccShow->getCcShowInstancess() as $ccShowInstance) {
$ccSchedules = CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->find();
if ($ccSchedules->isEmpty()) {
$nextStartDT = $ccShowInstance->getDbStarts(null);
//get time_filled so we can update cc_show_instances
$timeFilled = $ccSchedule->getCcShowInstances()->getDbTimeFilled();
foreach ($showStamp as $item) {
$endTimeDT = self::findEndTime($nextStartDT, $item->getDbClipLength());
//need to find out which linked instances are empty
foreach ($ccShow->getCcShowInstancess() as $ccShowInstance) {
$ccSchedules = CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->find();
if ($ccSchedules->isEmpty()) {
$nextStartDT = $ccShowInstance->getDbStarts(null);
$ccSchedule = new CcSchedule();
$ccSchedule
->setDbStarts($nextStartDT)
->setDbEnds($endTimeDT)
->setDbFileId($item->getDbFileId())
->setDbStreamId($item->getDbStreamId())
->setDbClipLength($item->getDbClipLength())
->setDbFadeIn($item->getDbFadeIn())
->setDbFadeOut($item->getDbFadeOut())
->setDbCuein($item->getDbCueIn())
->setDbCueOut($item->getDbCueOut())
->setDbInstanceId($ccShowInstance->getDbId())
->setDbPosition($item->getDbPosition())
foreach ($showStamp as $item) {
$endTimeDT = self::findEndTime($nextStartDT, $item->getDbClipLength());
$ccSchedule = new CcSchedule();
$ccSchedule
->setDbStarts($nextStartDT)
->setDbEnds($endTimeDT)
->setDbFileId($item->getDbFileId())
->setDbStreamId($item->getDbStreamId())
->setDbClipLength($item->getDbClipLength())
->setDbFadeIn($item->getDbFadeIn())
->setDbFadeOut($item->getDbFadeOut())
->setDbCuein($item->getDbCueIn())
->setDbCueOut($item->getDbCueOut())
->setDbInstanceId($ccShowInstance->getDbId())
->setDbPosition($item->getDbPosition())
->save();
$nextStartDT = $endTimeDT;
} //foreach show item
//update time_filled in cc_show_instances
$ccShowInstance
->setDbTimeFilled($timeFilled)
->setDbLastScheduled(gmdate("Y-m-d H:i:s"))
->save();
$nextStartDT = $endTimeDT;
} //foreach show item
}
} //foreach linked instance
}
} //foreach linked instance
} //if at least one linked instance has content
}
}
}

View file

@ -215,6 +215,10 @@ class Application_Service_ShowFormService
'add_show_end_date' => $repeatEndDate->format("Y-m-d"),
'add_show_no_end' => (!$service_show->getRepeatingEndDate()),
'add_show_monthly_repeat_type' => $monthlyRepeatType));
if (!$this->ccShow->isLinkable()) {
$form->getElement('add_show_linked')->setOptions(array('disabled' => true));
}
}
private function populateFormWho($form)
@ -337,7 +341,7 @@ class Application_Service_ShowFormService
* Returns 2 DateTime objects, in the user's local time,
* of the next future repeat show instance start and end time
*/
private function getNextFutureRepeatShowTime()
public function getNextFutureRepeatShowTime()
{
$sql = <<<SQL
SELECT starts, ends FROM cc_show_instances

View file

@ -94,6 +94,13 @@ class Application_Service_ShowService
->setDbModifiedInstance(true)
->save();
$service_showForm = new Application_Service_ShowFormService($showData["add_show_id"]);
list($start, $end) = $service_showForm->getNextFutureRepeatShowTime();
$oldCcShowDay = $oldCcShow->getFirstCcShowDay();
$oldCcShowDay
->setDbFirstShow($start->setTimezone(new DateTimeZone("UTC"))->format("Y-m-d"))
->save();
$con->commit();
Application_Model_RabbitMq::PushSchedule();
} catch (Exception $e) {
@ -108,17 +115,6 @@ class Application_Service_ShowService
$service_user = new Application_Service_UserService();
$currentUser = $service_user->getCurrentUser();
/*if ($showData["add_show_repeats"]) {
$repeatType = $showData["add_show_repeat_type"];
if ($showData["add_show_repeat_type"] == 2) {
$repeatType = $showData["add_show_monthly_repeat_type"];
}
} else {
$repeatType = -1;
}
$isRecorded = (isset($showData['add_show_record']) && $showData['add_show_record']) ? 1 : 0;
$isRebroadcast = (isset($showData['add_show_rebroadcast']) && $showData['add_show_rebroadcast']) ? 1 : 0;*/
$showData["add_show_duration"] = $this->formatShowDuration(
$showData["add_show_duration"]);
@ -860,14 +856,10 @@ SQL;
$ccShowInstance = $this->getInstance($utcStartDateTime);
$newInstance = false;
$updateScheduleStatus = true;
} elseif (in_array($day, $daysAdded)) {
} else {
$newInstance = true;
$ccShowInstance = new CcShowInstances();
$updateScheduleStatus = false;
} else {
//if we get here, an instance was edited on it's own and
//thus became it's own show so there is nothing to update
break 1;
}
} else {
$newInstance = true;
@ -1149,6 +1141,11 @@ SQL;
$ccShow->setDbLiveStreamUsingCustomAuth($showData['cb_custom_auth'] == 1);
$ccShow->setDbLiveStreamUser($showData['custom_username']);
$ccShow->setDbLiveStreamPass($showData['custom_password']);
// Once a show is unlinked it cannot be linked again
if ($ccShow->getDbLinked() && !$showData["add_show_linked"]) {
$ccShow->setDbIsLinkable(false);
}
$ccShow->setDbLinked($showData["add_show_linked"]);
$ccShow->save();