CC-4090: Make code style PSR compliant
-run psr-cs-fixer
This commit is contained in:
parent
5661872034
commit
794cf2c845
40 changed files with 2017 additions and 1874 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Application_Model_Scheduler {
|
||||
|
||||
class Application_Model_Scheduler
|
||||
{
|
||||
private $con;
|
||||
private $fileInfo = array(
|
||||
"id" => "",
|
||||
|
@ -19,14 +19,14 @@ class Application_Model_Scheduler {
|
|||
|
||||
private $checkUserPermissions = true;
|
||||
|
||||
public function __construct() {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
|
||||
|
||||
$this->epochNow = microtime(true);
|
||||
$this->nowDT = DateTime::createFromFormat("U.u", $this->epochNow, new DateTimeZone("UTC"));
|
||||
|
||||
if ($this->nowDT === false){
|
||||
if ($this->nowDT === false) {
|
||||
// DateTime::createFromFormat does not support millisecond string formatting in PHP 5.3.2 (Ubuntu 10.04).
|
||||
// In PHP 5.3.3 (Ubuntu 10.10), this has been fixed.
|
||||
$this->nowDT = DateTime::createFromFormat("U", time(), new DateTimeZone("UTC"));
|
||||
|
@ -35,18 +35,18 @@ class Application_Model_Scheduler {
|
|||
$this->user = Application_Model_User::getCurrentUser();
|
||||
}
|
||||
|
||||
public function setCheckUserPermissions($value) {
|
||||
public function setCheckUserPermissions($value)
|
||||
{
|
||||
$this->checkUserPermissions = $value;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* make sure any incoming requests for scheduling are ligit.
|
||||
*
|
||||
* @param array $items, an array containing pks of cc_schedule items.
|
||||
*/
|
||||
private function validateRequest($items) {
|
||||
|
||||
/*
|
||||
* make sure any incoming requests for scheduling are ligit.
|
||||
*
|
||||
* @param array $items, an array containing pks of cc_schedule items.
|
||||
*/
|
||||
private function validateRequest($items)
|
||||
{
|
||||
$nowEpoch = floatval($this->nowDT->format("U.u"));
|
||||
|
||||
for ($i = 0; $i < count($items); $i++) {
|
||||
|
@ -57,7 +57,7 @@ class Application_Model_Scheduler {
|
|||
$schedInfo[$id] = $items[$i]["instance"];
|
||||
}
|
||||
|
||||
$instanceInfo[$items[$i]["instance"]] = $items[$i]["timestamp"];
|
||||
$instanceInfo[$items[$i]["instance"]] = $items[$i]["timestamp"];
|
||||
}
|
||||
|
||||
if (count($instanceInfo) === 0) {
|
||||
|
@ -73,21 +73,21 @@ class Application_Model_Scheduler {
|
|||
$showInstances = CcShowInstancesQuery::create()->findPKs($instanceIds, $this->con);
|
||||
|
||||
//an item has been deleted
|
||||
if (count($schedIds) !== count($schedItems)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (sched mismatch)");
|
||||
if (count($schedIds) !== count($schedItems)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (sched mismatch)");
|
||||
}
|
||||
|
||||
//a show has been deleted
|
||||
if (count($instanceIds) !== count($showInstances)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (instance mismatch)");
|
||||
//a show has been deleted
|
||||
if (count($instanceIds) !== count($showInstances)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (instance mismatch)");
|
||||
}
|
||||
|
||||
foreach ($schedItems as $schedItem) {
|
||||
$id = $schedItem->getDbId();
|
||||
$instance = $schedItem->getCcShowInstances($this->con);
|
||||
|
||||
if (intval($schedInfo[$id]) !== $instance->getDbId()) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
if (intval($schedInfo[$id]) !== $instance->getDbId()) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,23 +96,23 @@ class Application_Model_Scheduler {
|
|||
$id = $instance->getDbId();
|
||||
$show = $instance->getCcShow($this->con);
|
||||
|
||||
if ($this->checkUserPermissions && $this->user->canSchedule($show->getDbId()) === false) {
|
||||
throw new Exception("You are not allowed to schedule show {$show->getDbName()}.");
|
||||
if ($this->checkUserPermissions && $this->user->canSchedule($show->getDbId()) === false) {
|
||||
throw new Exception("You are not allowed to schedule show {$show->getDbName()}.");
|
||||
}
|
||||
|
||||
$showEndEpoch = floatval($instance->getDbEnds("U.u"));
|
||||
|
||||
if ($showEndEpoch < $nowEpoch) {
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} is over and cannot be scheduled.");
|
||||
$showEndEpoch = floatval($instance->getDbEnds("U.u"));
|
||||
|
||||
if ($showEndEpoch < $nowEpoch) {
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} is over and cannot be scheduled.");
|
||||
}
|
||||
|
||||
$ts = intval($instanceInfo[$id]);
|
||||
$lastSchedTs = intval($instance->getDbLastScheduled("U")) ? : 0;
|
||||
$lastSchedTs = intval($instance->getDbLastScheduled("U")) ? : 0;
|
||||
if ($ts < $lastSchedTs) {
|
||||
Logging::log("ts {$ts} last sched {$lastSchedTs}");
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
Logging::log("ts {$ts} last sched {$lastSchedTs}");
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -121,8 +121,8 @@ class Application_Model_Scheduler {
|
|||
*
|
||||
* @return $files
|
||||
*/
|
||||
private function retrieveMediaFiles($id, $type) {
|
||||
|
||||
private function retrieveMediaFiles($id, $type)
|
||||
{
|
||||
$files = array();
|
||||
|
||||
if ($type === "audioclip") {
|
||||
|
@ -130,8 +130,7 @@ class Application_Model_Scheduler {
|
|||
|
||||
if (is_null($file) || !$file->getDbFileExists()) {
|
||||
throw new Exception("A selected File does not exist!");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$data = $this->fileInfo;
|
||||
$data["id"] = $id;
|
||||
$data["cliplength"] = $file->getDbLength();
|
||||
|
@ -146,8 +145,7 @@ class Application_Model_Scheduler {
|
|||
|
||||
$files[] = $data;
|
||||
}
|
||||
}
|
||||
else if ($type === "playlist") {
|
||||
} elseif ($type === "playlist") {
|
||||
|
||||
$contents = CcPlaylistcontentsQuery::create()
|
||||
->orderByDbPosition()
|
||||
|
@ -186,8 +184,8 @@ class Application_Model_Scheduler {
|
|||
*
|
||||
* @return DateTime endDT in UTC
|
||||
*/
|
||||
private function findEndTime($p_startDT, $p_duration) {
|
||||
|
||||
private function findEndTime($p_startDT, $p_duration)
|
||||
{
|
||||
$startEpoch = $p_startDT->format("U.u");
|
||||
$durationSeconds = Application_Model_Playlist::playlistTimeToSeconds($p_duration);
|
||||
|
||||
|
@ -205,70 +203,68 @@ class Application_Model_Scheduler {
|
|||
return $dt;
|
||||
}
|
||||
|
||||
private function findNextStartTime($DT, $instance) {
|
||||
|
||||
$sEpoch = $DT->format("U.u");
|
||||
private function findNextStartTime($DT, $instance)
|
||||
{
|
||||
$sEpoch = $DT->format("U.u");
|
||||
$nEpoch = $this->epochNow;
|
||||
|
||||
//check for if the show has started.
|
||||
if (bccomp( $nEpoch , $sEpoch , 6) === 1) {
|
||||
//need some kind of placeholder for cc_schedule.
|
||||
//playout_status will be -1.
|
||||
|
||||
//check for if the show has started.
|
||||
if (bccomp( $nEpoch , $sEpoch , 6) === 1) {
|
||||
//need some kind of placeholder for cc_schedule.
|
||||
//playout_status will be -1.
|
||||
$nextDT = $this->nowDT;
|
||||
|
||||
$length = bcsub($nEpoch , $sEpoch , 6);
|
||||
$cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
|
||||
|
||||
//fillers are for only storing a chunk of time space that has already passed.
|
||||
$filler = new CcSchedule();
|
||||
$filler->setDbStarts($DT)
|
||||
->setDbEnds($this->nowDT)
|
||||
->setDbClipLength($cliplength)
|
||||
->setDbPlayoutStatus(-1)
|
||||
->setDbInstanceId($instance->getDbId())
|
||||
->save($this->con);
|
||||
}
|
||||
else {
|
||||
$nextDT = $DT;
|
||||
$length = bcsub($nEpoch , $sEpoch , 6);
|
||||
$cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
|
||||
|
||||
//fillers are for only storing a chunk of time space that has already passed.
|
||||
$filler = new CcSchedule();
|
||||
$filler->setDbStarts($DT)
|
||||
->setDbEnds($this->nowDT)
|
||||
->setDbClipLength($cliplength)
|
||||
->setDbPlayoutStatus(-1)
|
||||
->setDbInstanceId($instance->getDbId())
|
||||
->save($this->con);
|
||||
} else {
|
||||
$nextDT = $DT;
|
||||
}
|
||||
|
||||
return $nextDT;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param int $showInstance
|
||||
* @param array $exclude
|
||||
* ids of sched items to remove from the calulation.
|
||||
*/
|
||||
private function removeGaps($showInstance, $exclude=null) {
|
||||
|
||||
Logging::log("removing gaps from show instance #".$showInstance);
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
|
||||
if (is_null($instance)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
|
||||
$itemStartDT = $instance->getDbStarts(null);
|
||||
|
||||
$schedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($showInstance)
|
||||
->filterByDbId($exclude, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
|
||||
foreach ($schedule as $item) {
|
||||
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($itemStartDT)
|
||||
->setDbEnds($itemEndDT);
|
||||
|
||||
$itemStartDT = $itemEndDT;
|
||||
/*
|
||||
* @param int $showInstance
|
||||
* @param array $exclude
|
||||
* ids of sched items to remove from the calulation.
|
||||
*/
|
||||
private function removeGaps($showInstance, $exclude=null)
|
||||
{
|
||||
Logging::log("removing gaps from show instance #".$showInstance);
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
|
||||
if (is_null($instance)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
|
||||
$schedule->save($this->con);
|
||||
$itemStartDT = $instance->getDbStarts(null);
|
||||
|
||||
$schedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($showInstance)
|
||||
->filterByDbId($exclude, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
foreach ($schedule as $item) {
|
||||
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($itemStartDT)
|
||||
->setDbEnds($itemEndDT);
|
||||
|
||||
$itemStartDT = $itemEndDT;
|
||||
}
|
||||
|
||||
$schedule->save($this->con);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -276,8 +272,8 @@ class Application_Model_Scheduler {
|
|||
* @param array $fileIds
|
||||
* @param array $playlistIds
|
||||
*/
|
||||
private function insertAfter($scheduleItems, $schedFiles, $adjustSched = true) {
|
||||
|
||||
private function insertAfter($scheduleItems, $schedFiles, $adjustSched = true)
|
||||
{
|
||||
try {
|
||||
|
||||
$affectedShowInstances = array();
|
||||
|
@ -326,12 +322,12 @@ class Application_Model_Scheduler {
|
|||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
$pend = microtime(true);
|
||||
Logging::debug("finding all following items.");
|
||||
$pend = microtime(true);
|
||||
Logging::debug("finding all following items.");
|
||||
Logging::debug(floatval($pend) - floatval($pstart));
|
||||
}
|
||||
|
||||
foreach($schedFiles as $file) {
|
||||
foreach ($schedFiles as $file) {
|
||||
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
|
||||
|
||||
|
@ -339,8 +335,7 @@ class Application_Model_Scheduler {
|
|||
//need to keep same id for resources if we want REST.
|
||||
if (isset($file['sched_id'])) {
|
||||
$sched = CcScheduleQuery::create()->findPK($file['sched_id'], $this->con);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sched = new CcSchedule();
|
||||
}
|
||||
Logging::log(print_r($file,true));
|
||||
|
@ -374,13 +369,13 @@ class Application_Model_Scheduler {
|
|||
}
|
||||
|
||||
$pend = microtime(true);
|
||||
Logging::debug("adjusting all following items.");
|
||||
Logging::debug("adjusting all following items.");
|
||||
Logging::debug(floatval($pend) - floatval($pstart));
|
||||
}
|
||||
}
|
||||
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("finished adding scheduled items.");
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("finished adding scheduled items.");
|
||||
Logging::debug(floatval($endProfile) - floatval($startProfile));
|
||||
|
||||
//update the status flag in cc_schedule.
|
||||
|
@ -394,8 +389,8 @@ class Application_Model_Scheduler {
|
|||
$instance->updateScheduleStatus($this->con);
|
||||
}
|
||||
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("updating show instances status.");
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("updating show instances status.");
|
||||
Logging::debug(floatval($endProfile) - floatval($startProfile));
|
||||
|
||||
$startProfile = microtime(true);
|
||||
|
@ -405,11 +400,10 @@ class Application_Model_Scheduler {
|
|||
->filterByPrimaryKeys($affectedShowInstances)
|
||||
->update(array('DbLastScheduled' => new DateTime("now", new DateTimeZone("UTC"))), $this->con);
|
||||
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("updating last scheduled timestamp.");
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("updating last scheduled timestamp.");
|
||||
Logging::debug(floatval($endProfile) - floatval($startProfile));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
Logging::debug($e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
|
@ -419,8 +413,8 @@ class Application_Model_Scheduler {
|
|||
* @param array $scheduleItems
|
||||
* @param array $mediaItems
|
||||
*/
|
||||
public function scheduleAfter($scheduleItems, $mediaItems, $adjustSched = true) {
|
||||
|
||||
public function scheduleAfter($scheduleItems, $mediaItems, $adjustSched = true)
|
||||
{
|
||||
$this->con->beginTransaction();
|
||||
|
||||
$schedFiles = array();
|
||||
|
@ -437,8 +431,7 @@ class Application_Model_Scheduler {
|
|||
$this->con->commit();
|
||||
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
@ -448,8 +441,8 @@ class Application_Model_Scheduler {
|
|||
* @param array $selectedItem
|
||||
* @param array $afterItem
|
||||
*/
|
||||
public function moveItem($selectedItems, $afterItems, $adjustSched = true) {
|
||||
|
||||
public function moveItem($selectedItems, $afterItems, $adjustSched = true)
|
||||
{
|
||||
$startProfile = microtime(true);
|
||||
|
||||
$this->con->beginTransaction();
|
||||
|
@ -460,11 +453,11 @@ class Application_Model_Scheduler {
|
|||
$this->validateRequest($selectedItems);
|
||||
$this->validateRequest($afterItems);
|
||||
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("validating move request took:");
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("validating move request took:");
|
||||
Logging::debug(floatval($endProfile) - floatval($startProfile));
|
||||
|
||||
$afterInstance = CcShowInstancesQuery::create()->findPK($afterItems[0]["instance"], $this->con);
|
||||
|
||||
$afterInstance = CcShowInstancesQuery::create()->findPK($afterItems[0]["instance"], $this->con);
|
||||
|
||||
//map show instances to cc_schedule primary keys.
|
||||
$modifiedMap = array();
|
||||
|
@ -473,16 +466,16 @@ class Application_Model_Scheduler {
|
|||
//prepare each of the selected items.
|
||||
for ($i = 0; $i < count($selectedItems); $i++) {
|
||||
|
||||
$selected = CcScheduleQuery::create()->findPk($selectedItems[$i]["id"], $this->con);
|
||||
$selectedInstance = $selected->getCcShowInstances($this->con);
|
||||
$selected = CcScheduleQuery::create()->findPk($selectedItems[$i]["id"], $this->con);
|
||||
$selectedInstance = $selected->getCcShowInstances($this->con);
|
||||
|
||||
$data = $this->fileInfo;
|
||||
$data["id"] = $selected->getDbFileId();
|
||||
$data["cliplength"] = $selected->getDbClipLength();
|
||||
$data["cuein"] = $selected->getDbCueIn();
|
||||
$data["cueout"] = $selected->getDbCueOut();
|
||||
$data["fadein"] = $selected->getDbFadeIn();
|
||||
$data["fadeout"] = $selected->getDbFadeOut();
|
||||
$data = $this->fileInfo;
|
||||
$data["id"] = $selected->getDbFileId();
|
||||
$data["cliplength"] = $selected->getDbClipLength();
|
||||
$data["cuein"] = $selected->getDbCueIn();
|
||||
$data["cueout"] = $selected->getDbCueOut();
|
||||
$data["fadein"] = $selected->getDbFadeIn();
|
||||
$data["fadeout"] = $selected->getDbFadeOut();
|
||||
$data["sched_id"] = $selected->getDbId();
|
||||
|
||||
$movedData[] = $data;
|
||||
|
@ -492,8 +485,7 @@ class Application_Model_Scheduler {
|
|||
$schedId = $selected->getDbId();
|
||||
if (isset($modifiedMap[$showInstanceId])) {
|
||||
array_push($modifiedMap[$showInstanceId], $schedId);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$modifiedMap[$showInstanceId] = array($schedId);
|
||||
}
|
||||
}
|
||||
|
@ -504,8 +496,8 @@ class Application_Model_Scheduler {
|
|||
|
||||
$this->removeGaps($instance, $schedIds);
|
||||
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("removing gaps from instance $instance:");
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("removing gaps from instance $instance:");
|
||||
Logging::debug(floatval($endProfile) - floatval($startProfile));
|
||||
}
|
||||
|
||||
|
@ -513,14 +505,14 @@ class Application_Model_Scheduler {
|
|||
|
||||
$this->insertAfter($afterItems, $movedData, $adjustSched);
|
||||
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("inserting after removing gaps.");
|
||||
$endProfile = microtime(true);
|
||||
Logging::debug("inserting after removing gaps.");
|
||||
Logging::debug(floatval($endProfile) - floatval($startProfile));
|
||||
|
||||
$afterInstanceId = $afterInstance->getDbId();
|
||||
$afterInstanceId = $afterInstance->getDbId();
|
||||
$modified = array_keys($modifiedMap);
|
||||
//need to adjust shows we have moved items from.
|
||||
foreach($modified as $instanceId) {
|
||||
foreach ($modified as $instanceId) {
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($instanceId, $this->con);
|
||||
$instance->updateScheduleStatus($this->con);
|
||||
|
@ -530,15 +522,14 @@ class Application_Model_Scheduler {
|
|||
$this->con->commit();
|
||||
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeItems($scheduledItems, $adjustSched = true) {
|
||||
|
||||
public function removeItems($scheduledItems, $adjustSched = true)
|
||||
{
|
||||
$showInstances = array();
|
||||
$this->con->beginTransaction();
|
||||
|
||||
|
@ -564,7 +555,7 @@ class Application_Model_Scheduler {
|
|||
$nEpoch = $this->epochNow;
|
||||
$sEpoch = $removedItem->getDbStarts('U.u');
|
||||
|
||||
$length = bcsub($nEpoch , $sEpoch , 6);
|
||||
$length = bcsub($nEpoch , $sEpoch , 6);
|
||||
$cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
|
||||
|
||||
$cueinSec = Application_Model_Playlist::playlistTimeToSeconds($removedItem->getDbCueIn());
|
||||
|
@ -575,8 +566,7 @@ class Application_Model_Scheduler {
|
|||
->setDbClipLength($cliplength)
|
||||
->setDbEnds($this->nowDT)
|
||||
->save($this->con);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$removedItem->delete($this->con);
|
||||
}
|
||||
}
|
||||
|
@ -613,8 +603,7 @@ class Application_Model_Scheduler {
|
|||
$this->con->commit();
|
||||
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
@ -625,8 +614,8 @@ class Application_Model_Scheduler {
|
|||
*
|
||||
* @param $p_id id of the show instance to cancel.
|
||||
*/
|
||||
public function cancelShow($p_id) {
|
||||
|
||||
public function cancelShow($p_id)
|
||||
{
|
||||
$this->con->beginTransaction();
|
||||
|
||||
try {
|
||||
|
@ -635,28 +624,27 @@ class Application_Model_Scheduler {
|
|||
|
||||
if (!$instance->getDbRecord()) {
|
||||
|
||||
$items = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($p_id)
|
||||
->filterByDbEnds($this->nowDT, Criteria::GREATER_THAN)
|
||||
->find($this->con);
|
||||
$items = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($p_id)
|
||||
->filterByDbEnds($this->nowDT, Criteria::GREATER_THAN)
|
||||
->find($this->con);
|
||||
|
||||
if (count($items) > 0) {
|
||||
$remove = array();
|
||||
$ts = $this->nowDT->format('U');
|
||||
|
||||
for($i = 0; $i < count($items); $i++) {
|
||||
$remove[$i]["instance"] = $p_id;
|
||||
$remove[$i]["timestamp"] = $ts;
|
||||
$remove[$i]["id"] = $items[$i]->getDbId();
|
||||
}
|
||||
|
||||
$remove = array();
|
||||
$ts = $this->nowDT->format('U');
|
||||
|
||||
for ($i = 0; $i < count($items); $i++) {
|
||||
$remove[$i]["instance"] = $p_id;
|
||||
$remove[$i]["timestamp"] = $ts;
|
||||
$remove[$i]["id"] = $items[$i]->getDbId();
|
||||
}
|
||||
|
||||
$this->removeItems($remove, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$rebroadcasts = $instance->getCcShowInstancessRelatedByDbId(null, $this->con);
|
||||
$rebroadcasts->delete($this->con);
|
||||
}
|
||||
}
|
||||
|
||||
$instance->setDbEnds($this->nowDT);
|
||||
$instance->save($this->con);
|
||||
|
@ -666,10 +654,9 @@ class Application_Model_Scheduler {
|
|||
if ($instance->getDbRecord()) {
|
||||
Application_Model_RabbitMq::SendMessageToShowRecorder("cancel_recording");
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$this->con->rollback();
|
||||
throw $e;
|
||||
} catch (Exception $e) {
|
||||
$this->con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue