From c173744929fbb0e023c96f2d3ce8db030f7a0477 Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 14 May 2013 10:58:06 -0400 Subject: [PATCH] CC-5090: Unscheduled tracks are still marked at Scheduled in linked show --- airtime_mvc/application/models/Schedule.php | 20 +++++++++++++++++- airtime_mvc/application/models/StoredFile.php | 21 ++++++++++++++----- .../application/models/airtime/CcShow.php | 8 +++++++ .../application/services/SchedulerService.php | 7 +++++-- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 9a1572b6c..7e344d698 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -20,7 +20,7 @@ SQL; return (is_numeric($count) && ($count != '0')); } - public static function getAllFutureScheduledFiles() + public static function getAllFutureScheduledFiles($instanceId=null) { $sql = << now() AT TIME ZONE 'UTC' AND file_id is not null SQL; + /* If an instance id gets passed into this function we need to check + * if it is a repeating show. If it is a repeating show, we need to + * check for any files scheduled in the future in the linked instances + * as well + */ + if (!is_null($instanceId)) { + $excludeIds = array(); + $ccShow = CcShowInstancesQuery::create() + ->findPk($instanceId) + ->getCcShow(); + if ($ccShow->isLinked()) { + foreach ($ccShow->getOtherInstances($instanceId) as $instance) { + $excludeIds[] = $instance->getDbId(); + } + $sql .= " AND instance_id IN (".implode(",", $excludeIds).")"; + } + } + $files = Application_Common_Database::prepareAndExecute( $sql, array()); $real_files = array(); diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 5db22107c..e21f918b1 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -1322,7 +1322,9 @@ SQL; } } - public static function setIsScheduled($p_scheduleItem, $p_status, $p_fileId=null) { + public static function setIsScheduled($p_scheduleItem, $p_status, + $p_fileId=null, $instanceId=null) { + if (is_null($p_fileId)) { $fileId = Application_Model_Schedule::GetFileId($p_scheduleItem); } else { @@ -1331,7 +1333,8 @@ SQL; $file = self::RecallById($fileId); $updateIsScheduled = false; - if (!is_null($fileId) && !in_array($fileId, Application_Model_Schedule::getAllFutureScheduledFiles())) { + if (!is_null($fileId) && !in_array($fileId, + Application_Model_Schedule::getAllFutureScheduledFiles($instanceId))) { $file->_file->setDbIsScheduled($p_status)->save(); $updateIsScheduled = true; } @@ -1341,15 +1344,23 @@ SQL; public static function updatePastFilesIsScheduled() { + /* Retrieve files that are scheduled in the past OR that belong + * to a show that has ended. We need to check if the show has + * ended incase a track is overbooked, since that alone will + * indicate the show is still scheduled in the future + */ $sql = <<filterByCcShow($this) + ->filterByDbId($instanceId, Criteria::NOT_IN) + ->find(); + } } // CcShow diff --git a/airtime_mvc/application/services/SchedulerService.php b/airtime_mvc/application/services/SchedulerService.php index 69f046153..c5eb0a504 100644 --- a/airtime_mvc/application/services/SchedulerService.php +++ b/airtime_mvc/application/services/SchedulerService.php @@ -41,8 +41,11 @@ class Application_Service_SchedulerService /** * - * Enter description here ... - * @param array $instanceIds + * Applies the show start difference to any scheduled items + * + * @param $instanceIds + * @param $diff + * @param $newStart */ public static function updateScheduleStartTime($instanceIds, $diff=null, $newStart=null) {