From f61afb0216b392c4d989896366b23fd3b51c8fc4 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Fri, 2 Mar 2012 14:01:02 +0100 Subject: [PATCH] CC-3373 : Timeline: only lock the currently playing track and the one after --- airtime_mvc/application/models/Schedule.php | 9 ++++++--- airtime_mvc/application/models/ShowBuilder.php | 9 +++++++-- airtime_mvc/public/js/airtime/showbuilder/builder.js | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 59e5bbde4..f5bd01517 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -222,7 +222,7 @@ class Application_Model_Schedule { * @return array $scheduledItems * */ - public static function GetScheduleDetailItems($p_startDateTime, $p_endDateTime, $p_shows) + public static function GetScheduleDetailItems($p_start, $p_end, $p_shows) { global $CC_CONFIG, $CC_DBC; @@ -250,8 +250,11 @@ class Application_Model_Schedule { WHERE si.modified_instance = false AND - si.starts >= '{$p_startDateTime}' AND si.starts < '{$p_endDateTime}'"; - + ((si.starts >= '{$p_start}' AND si.starts < '{$p_end}') + OR (si.ends > '{$p_start}' AND si.ends <= '{$p_end}') + OR (si.starts <= '{$p_start}' AND si.ends >= '{$p_end}'))"; + + if (count($p_shows) > 0) { $sql .= " AND show_id IN (".implode(",", $p_shows).")"; } diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index 9acc44fba..140d23cff 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -58,9 +58,14 @@ class Application_Model_ShowBuilder { } $showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC")); + $schedStartDT = new DateTime($p_item["sched_starts"], new DateTimeZone("UTC")); + + $showStartEpoch = intval($showStartDT->format('U')); + $schedStartEpoch = intval($schedStartDT->format('U')); - //can only schedule the show if it hasn't started and you are allowed. - if ($this->epoch_now < $showStartDT->format('U') && $this->user->canSchedule($p_item["show_id"]) == true) { + //can only schedule the show if item hasn't started and you are allowed. + if ($this->epoch_now < max($showStartEpoch, $schedStartEpoch) + && $this->user->canSchedule($p_item["show_id"]) == true) { $row["allowed"] = true; } } diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js index f64d0914e..cc7678589 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js @@ -270,7 +270,7 @@ var AIRTIME = (function(AIRTIME){ td; //create cursor arrows. - tableDiv.find("tr:not(:first, .sb-footer, .sb-empty, .sb-not-allowed)").each(function(i, el) { + tableDiv.find("tr.sb-now-playing, tr:not(:first, .sb-footer, .sb-empty, .sb-not-allowed)").each(function(i, el) { td = $(el).find("td:first"); if (td.hasClass("dataTables_empty")) { return false; @@ -429,7 +429,7 @@ var AIRTIME = (function(AIRTIME){ var prev = ui.item.prev(); //can't add items outside of shows. - if (!prev.hasClass("sb-allowed")) { + if (prev.hasClass("sb-footer") || prev.find("td:first").hasClass("dataTables_empty")) { alert("Cannot schedule outside a show."); ui.item.remove(); return;