diff --git a/airtime_mvc/application/common/UsabilityHints.php b/airtime_mvc/application/common/UsabilityHints.php index 84f670c68..74c448fb0 100644 --- a/airtime_mvc/application/common/UsabilityHints.php +++ b/airtime_mvc/application/common/UsabilityHints.php @@ -24,17 +24,9 @@ class Application_Common_UsabilityHints */ public static function isFutureOrCurrentShowScheduled() { - $now = new DateTime("now", new DateTimeZone("UTC")); - $futureShow = CcShowInstancesQuery::create() - ->filterByDbStarts($now, Criteria::GREATER_THAN) - ->filterByDbModifiedInstance(false) - ->findOne(); + $futureShow = self::getNextFutureShow(); + $currentShow = self::getCurrentShow(); - $currentShow = CcShowInstancesQuery::create() - ->filterByDbStarts($now, Criteria::LESS_THAN) - ->filterByDbEnds($now, Criteria::GREATER_THAN) - ->filterByDbModifiedInstance(false) - ->findOne(); if (is_null($futureShow) && is_null($currentShow)) { return false; } else { @@ -50,23 +42,22 @@ class Application_Common_UsabilityHints */ public static function isCurrentOrNextShowEmpty() { - $schedule = Application_Model_Schedule::GetPlayOrderRange(); - $shows = $schedule["shows"]; + $futureShow = self::getNextFutureShow(); + $currentShow = self::getCurrentShow(); - if (empty($shows["current"]) && empty($shows["next"])) { + if (is_null($futureShow) && is_null($currentShow)) { return false; } else { - if ($shows["current"]) { + if ($currentShow) { $scheduledTracks = CcScheduleQuery::create() - ->filterByDbInstanceId($shows["current"]["instance_id"]) + ->filterByDbInstanceId($currentShow->getDbId()) ->find(); if ($scheduledTracks->count() == 0) { return true; } - } else if ($shows["next"]) { - $nextShow = $shows["next"][0]; + } else if ($futureShow) { $scheduledTracks = CcScheduleQuery::create() - ->filterByDbInstanceId($nextShow["instance_id"]) + ->filterByDbInstanceId($futureShow->getDbId()) ->find(); if ($scheduledTracks->count() == 0) { return true; @@ -74,4 +65,26 @@ class Application_Common_UsabilityHints } } } + + private static function getCurrentShow() + { + $now = new DateTime("now", new DateTimeZone("UTC")); + + return CcShowInstancesQuery::create() + ->filterByDbStarts($now, Criteria::LESS_THAN) + ->filterByDbEnds($now, Criteria::GREATER_THAN) + ->filterByDbModifiedInstance(false) + ->findOne(); + } + + private static function getNextFutureShow() + { + $now = new DateTime("now", new DateTimeZone("UTC")); + + return CcShowInstancesQuery::create() + ->filterByDbStarts($now, Criteria::GREATER_THAN) + ->filterByDbModifiedInstance(false) + ->orderByDbStarts() + ->findOne(); + } } \ No newline at end of file