From 553299e9f543fa7e01a7960b872ecc7e882e801e Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Mon, 23 Nov 2015 14:55:37 -0500 Subject: [PATCH] Try to fix some schedule bugs --- airtime_mvc/application/models/Preference.php | 3 +++ airtime_mvc/application/models/Scheduler.php | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 82731f524..5757171b0 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -1572,6 +1572,9 @@ class Application_Model_Preference self::setValue("station_podcast_download_counter", empty($c) ? 0 : --$c); } + /** + * @return int either 0 (public) or 1 (private) + */ public static function getStationPodcastPrivacy() { if (!Billing::isStationPodcastAllowed()) { // return private setting diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index de3b73ca1..f3f0c508c 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -482,10 +482,15 @@ class Application_Model_Scheduler ->orderByDbStarts() ->find($this->con); + $now = new DateTime("now", new DateTimeZone("UTC")); $itemStartDT = $instance->getDbStarts(null); foreach ($schedule as $item) { $itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength()); - Logging::info($itemEndDT); + // If the track has already ended, don't change it. + if ($itemEndDT < $now) { + $itemStartDT = $itemEndDT; + continue; + } $item->setDbStarts($itemStartDT) ->setDbEnds($itemEndDT) ->save($this->con); @@ -515,10 +520,15 @@ class Application_Model_Scheduler ->orderByDbStarts() ->find($this->con); + $now = new DateTime("now", new DateTimeZone("UTC")); $itemStartDT = $instance->getDbStarts(null); foreach ($schedule as $item) { - $itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength()); + // If the track has already ended, don't change it. + if ($itemEndDT < $now) { + $itemStartDT = $itemEndDT; + continue; + } $item->setDbStarts($itemStartDT) ->setDbEnds($itemEndDT); @@ -1191,7 +1201,7 @@ class Application_Model_Scheduler foreach ($removedItems as $removedItem) { $instance = $removedItem->getCcShowInstances($this->con); - $effectedInstanceIds[] = $instance->getDbId(); + $effectedInstanceIds[$instance->getDbId()] = $instance->getDbId(); //check if instance is linked and if so get the schedule items //for all linked instances so we can delete them too