From f8d3a8c8bb3d9b33c38964690b06542aa5096109 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 22 Mar 2012 16:23:59 -0400 Subject: [PATCH] CC-3449: Live Stream: Kick out live dj at the end of the show - PHP side implementation --- airtime_mvc/application/models/Preference.php | 6 +++++- airtime_mvc/application/models/Schedule.php | 5 +++++ airtime_mvc/application/models/ShowInstance.php | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 10dee81a0..b6fbd550b 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -163,7 +163,11 @@ class Application_Model_Preference } public static function GetDefaultTransitionFade() { - return self::GetValue("default_transition_fade"); + $transition_fade = self::GetValue("default_transition_fade"); + if($transition_fade == ""){ + $transition_fade = "00.000000"; + } + return $transition_fade; } public static function SetStreamLabelFormat($type){ diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 204d5d983..a84d224bd 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -633,6 +633,11 @@ class Application_Model_Schedule { $data["status"] = array(); $data["media"] = array(); + $data["harbor"] = array(); + + + $data["harbor"]['next_live_dj_show_end'] = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ(); + $data["harbor"]['transition_fade'] = Application_Model_Preference::GetDefaultTransitionFade(); foreach ($items as $item){ diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index d6849a323..8fa3d5149 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -827,4 +827,20 @@ class Application_Model_ShowInstance { $sql = "SELECT count(*) as cnt FROM $CC_CONFIG[showInstances] WHERE ends < '$day'"; return $CC_DBC->GetOne($sql); } + + // this returns end timestamp of next show that has live DJ set up + public static function GetEndTimeOfNextShowWithLiveDJ(){ + global $CC_CONFIG, $CC_DBC; + + $date = new Application_Model_DateHelper; + $utcTimeNow = $date->getUtcTimestamp(); + + $sql = "SELECT ends + FROM cc_show_instances as si + JOIN cc_show as sh ON si.show_id = sh.id + WHERE si.ends > '$utcTimeNow' and (sh.live_stream_using_airtime_auth or live_stream_using_custom_auth) + ORDER BY si.ends"; + + return $CC_DBC->GetOne($sql); + } }