From 1de4777de325302b49ebad3b6ab0b1cf577ea3e9 Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 6 Jun 2011 12:20:44 -0400 Subject: [PATCH] cc-2362: upload to soundcloud with the wrong name after show rename. -make sure to remove all rebroadcasts of recorded shows when editing. --- airtime_mvc/application/models/Shows.php | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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) &&