CC-3094 : Rebroadcast editing problems
This commit is contained in:
parent
878fa3461d
commit
198340ac67
2 changed files with 58 additions and 34 deletions
|
@ -105,6 +105,13 @@ class Application_Model_Show {
|
|||
return $res;
|
||||
}
|
||||
|
||||
//remove everything about this show.
|
||||
public function deleteShow()
|
||||
{
|
||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||
$show->delete();
|
||||
}
|
||||
|
||||
public function resizeShow($deltaDay, $deltaMin)
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
@ -280,7 +287,7 @@ class Application_Model_Show {
|
|||
$showId = $this->getId();
|
||||
|
||||
$sql = "SELECT starts FROM cc_show_instances "
|
||||
."WHERE instance_id = $showId "
|
||||
."WHERE show_id = $showId AND rebroadcast = 1"
|
||||
."ORDER BY starts";
|
||||
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
|
@ -1229,8 +1236,10 @@ class Application_Model_Show {
|
|||
$showInstance->correctScheduleStartTimes();
|
||||
}
|
||||
|
||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
||||
|
||||
//don't create rebroadcasts for a deleted recorded show.
|
||||
if ($ccShowInstance->getDbModifiedInstance() == false) {
|
||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
||||
}
|
||||
|
||||
if ($p_interval == 'P1M'){
|
||||
/* When adding months, there is a problem if we are on January 31st and add one month with PHP.
|
||||
|
|
|
@ -31,7 +31,7 @@ class Application_Model_ShowInstance {
|
|||
|
||||
/* This function is weird. It should return a boolean, but instead returns
|
||||
* an integer if it is a rebroadcast, or returns null if it isn't. You can convert
|
||||
* it to boolean by using is_null(isRebroadcast), where true means isn't and false
|
||||
* it to boolean by using is_null(isRebroadcast), where true means isn't and false
|
||||
* means that it is. */
|
||||
public function isRebroadcast()
|
||||
{
|
||||
|
@ -399,40 +399,55 @@ class Application_Model_ShowInstance {
|
|||
global $CC_DBC;
|
||||
|
||||
// see if it was recording show
|
||||
$recording = CcShowInstancesQuery::create()
|
||||
->findPK($this->_instanceId)
|
||||
->getDbRecord();
|
||||
$recording = $this->isRecorded();
|
||||
// get show id
|
||||
$showId = CcShowInstancesQuery::create()
|
||||
->findPK($this->_instanceId)
|
||||
->getDbShowId();
|
||||
$showId = $this->getShowId();
|
||||
|
||||
CcShowInstancesQuery::create()
|
||||
->findPK($this->_instanceId)
|
||||
->setDbModifiedInstance(true)
|
||||
->save();
|
||||
|
||||
/* Automatically delete all files scheduled in cc_schedules table. */
|
||||
CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($this->_instanceId)
|
||||
->delete();
|
||||
$show = $this->getShow();
|
||||
|
||||
// check if we can safely delete the show
|
||||
$showInstancesRow = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->filterByDbModifiedInstance(false)
|
||||
->findOne();
|
||||
|
||||
|
||||
$current_timestamp = gmdate("Y-m-d H:i");
|
||||
|
||||
/* If we didn't find any instances of the show that haven't
|
||||
* been deleted, then just erase everything related to that show.
|
||||
* We can just delete, the show and the foreign key-constraint should
|
||||
* take care of deleting all of its instances. */
|
||||
if(is_null($showInstancesRow)){
|
||||
CcShowQuery::create()
|
||||
->filterByDbId($showId)
|
||||
->delete();
|
||||
if ($current_timestamp < $this->getShowInstanceStart()) {
|
||||
|
||||
if ($show->isRepeating()) {
|
||||
|
||||
CcShowInstancesQuery::create()
|
||||
->findPK($this->_instanceId)
|
||||
->setDbModifiedInstance(true)
|
||||
->save();
|
||||
|
||||
//delete the rebroadcasts of the removed recorded show.
|
||||
if ($recording) {
|
||||
CcShowInstancesQuery::create()
|
||||
->filterByDbOriginalShow($this->_instanceId)
|
||||
->delete();
|
||||
}
|
||||
|
||||
/* Automatically delete all files scheduled in cc_schedules table. */
|
||||
CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($this->_instanceId)
|
||||
->delete();
|
||||
|
||||
// check if we can safely delete the show
|
||||
$showInstancesRow = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->filterByDbModifiedInstance(false)
|
||||
->findOne();
|
||||
|
||||
/* If we didn't find any instances of the show that haven't
|
||||
* been deleted, then just erase everything related to that show.
|
||||
* We can just delete, the show and the foreign key-constraint should
|
||||
* take care of deleting all of its instances. */
|
||||
if(is_null($showInstancesRow)){
|
||||
CcShowQuery::create()
|
||||
->filterByDbId($showId)
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
$show->deleteShow();
|
||||
}
|
||||
}
|
||||
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue