diff --git a/airtime_mvc/application/models/Shows.php b/airtime_mvc/application/models/Shows.php index 4c9d522d9..2a7869073 100644 --- a/airtime_mvc/application/models/Shows.php +++ b/airtime_mvc/application/models/Shows.php @@ -312,6 +312,26 @@ class Show { $CC_DBC->query($sql); } + + /** + * Deletes all future rebroadcast instances of the current + * show object from the show_instances table. + * + */ + public function deleteAllRebroadcasts(){ + global $CC_DBC; + + $date = new DateHelper; + $timestamp = $date->getTimestamp(); + + $showId = $this->getId(); + $sql = "DELETE FROM cc_show_instances" + ." WHERE starts > TIMESTAMP '$timestamp'" + ." AND show_id = $showId" + ." AND rebroadcast = 1"; + + $CC_DBC->query($sql); + } /** * Deletes all show instances of current show after a @@ -567,6 +587,14 @@ class Show { //duration has changed $this->updateDurationTime($p_data); } + + if ($isRecorded){ + //delete all rebroadcasts. They will simply be recreated later + //in the execution of this PHP script. This simplifies having to + //reason about whether we should keep individual rebroadcasts or + //delete them or move them around etc. + $this->deleteAllRebroadcasts(); + } if ($p_data['add_show_repeats']){ if (($repeatType == 1 || $repeatType == 2) &&