CC-3451 : Ability to delete the currently playing clip
This commit is contained in:
parent
275faa1881
commit
10e4ae781f
5 changed files with 154 additions and 122 deletions
|
@ -111,7 +111,7 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
$item = CcScheduleQuery::create()->findPK($id);
|
||||
$instance = $item->getCcShowInstances();
|
||||
|
||||
if ($now < intval($item->getDbStarts("U")) && $user->canSchedule($instance->getDbShowId())) {
|
||||
if ($now < intval($item->getDbEnds("U")) && $user->canSchedule($instance->getDbShowId())) {
|
||||
$menu["del"] = array("name"=> "Delete", "icon" => "delete", "url" => "/showbuilder/schedule-remove");
|
||||
}
|
||||
|
||||
|
|
|
@ -130,11 +130,11 @@ class Application_Model_Scheduler {
|
|||
//fillers are for only storing a chunk of time space that has already passed.
|
||||
$filler = new CcSchedule();
|
||||
$filler->setDbStarts($DT)
|
||||
->setDbEnds($nowDT)
|
||||
->setDbClipLength($cliplength)
|
||||
->setDbPlayoutStatus(-1)
|
||||
->setDbInstanceId($instance->getDbId())
|
||||
->save($this->con);
|
||||
->setDbEnds($nowDT)
|
||||
->setDbClipLength($cliplength)
|
||||
->setDbPlayoutStatus(-1)
|
||||
->setDbInstanceId($instance->getDbId())
|
||||
->save($this->con);
|
||||
}
|
||||
else {
|
||||
$nextDT = $DT;
|
||||
|
@ -425,6 +425,8 @@ class Application_Model_Scheduler {
|
|||
|
||||
$removedItems = CcScheduleQuery::create()->findPks(array_keys($scheduledIds));
|
||||
|
||||
//check to see if the current item is being deleted so we can truncate the record.
|
||||
$currentItem = null;
|
||||
//check to make sure all items selected are up to date
|
||||
foreach ($removedItems as $removedItem) {
|
||||
$ts = $scheduledIds[$removedItem->getDbId()];
|
||||
|
@ -438,10 +440,25 @@ class Application_Model_Scheduler {
|
|||
$show = $instance->getCcShow($this->con);
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
|
||||
//check to truncate the currently playing item instead of deleting it.
|
||||
if ($removedItem->isCurrentItem()) {
|
||||
$now = new DateTime("now", new DateTimeZone("UTC"));
|
||||
|
||||
$nEpoch = $now->format('U');
|
||||
$sEpoch = $removedItem->getDbStarts('U');
|
||||
$length = $nEpoch - $sEpoch;
|
||||
$cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
|
||||
|
||||
$removedItem->setDbClipLength($cliplength);
|
||||
$removedItem->setDbEnds($now);
|
||||
$removedItem->save($this->con);
|
||||
}
|
||||
else {
|
||||
$removedItem->delete($this->con);
|
||||
}
|
||||
}
|
||||
|
||||
$removedItems->delete($this->con);
|
||||
|
||||
if ($adjustSched === true) {
|
||||
//get the show instances of the shows we must adjust times for.
|
||||
foreach ($removedItems as $item) {
|
||||
|
|
|
@ -62,20 +62,9 @@ class Application_Model_ShowBuilder {
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
|
||||
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
|
||||
$schedStartDT = new DateTime($p_item["sched_starts"], new DateTimeZone("UTC"));
|
||||
|
||||
$showStartEpoch = intval($showStartDT->format('U'));
|
||||
$showEndEpoch = intval($showEndDT->format('U'));
|
||||
$schedStartEpoch = intval($schedStartDT->format('U'));
|
||||
*/
|
||||
|
||||
if ($this->user->canSchedule($p_item["show_id"]) == true) {
|
||||
$row["allowed"] = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function getItemColor($p_item, &$row) {
|
||||
|
|
|
@ -223,5 +223,18 @@ class CcSchedule extends BaseCcSchedule {
|
|||
|
||||
return $this;
|
||||
} // setDbEnds()
|
||||
|
||||
public function isCurrentItem() {
|
||||
|
||||
$epochNow = time();
|
||||
$epochStart = intval($this->getDbStarts('U'));
|
||||
$epochEnd = intval($this->getDbEnds('U'));
|
||||
|
||||
if ($epochStart < $epochNow && $epochEnd > $epochNow) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // CcSchedule
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue