CC-1665: Scheduled stream rebroadcasting and recording
-code cleanup
This commit is contained in:
parent
7cde4ba2ba
commit
ebed110429
|
@ -75,39 +75,38 @@ class Application_Model_Schedule
|
|||
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = 'Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played, si.ends as show_ends
|
||||
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id LEFT JOIN cc_show_instances si on st.instance_id = si.id
|
||||
WHERE ';
|
||||
$sql = "SELECT %%columns%% st.starts as starts, st.ends as ends, st.media_item_played as media_item_played, si.ends as show_ends
|
||||
FROM cc_schedule st JOIN %%tables%% LEFT JOIN cc_show_instances si ON st.instance_id = si.id
|
||||
WHERE ";
|
||||
|
||||
/* Alternate SQL...merge conflict and I'm not sure which on is right.... -MK
|
||||
$sql = 'Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played, si.ends as show_ends
|
||||
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id
|
||||
WHERE ';
|
||||
*/
|
||||
$fileColumns = "ft.artist_name, ft.track_title, ";
|
||||
$streamColumns = "ws.login as artist_name, ws.name as track_title, ";
|
||||
|
||||
$fileJoin = "cc_files ft ON st.file_id = ft.id";
|
||||
$streamJoin = "cc_webstream ws ON st.stream_id = ws.id";
|
||||
|
||||
$predicateArr = array();
|
||||
if (isset($p_previousShowID)) {
|
||||
if (isset($p_nextShowID) || isset($p_currentShowID))
|
||||
$sql .= '(';
|
||||
$sql .= 'st.instance_id = '.$p_previousShowID;
|
||||
$predicateArr[] = 'st.instance_id = '.$p_previousShowID;
|
||||
}
|
||||
if ($p_currentShowID != null) {
|
||||
if ($p_previousShowID != null)
|
||||
$sql .= ' OR ';
|
||||
else if($p_nextShowID != null)
|
||||
$sql .= '(';
|
||||
$sql .= 'st.instance_id = '.$p_currentShowID;
|
||||
if (isset($p_currentShowID)) {
|
||||
$predicateArr[] = 'st.instance_id = '.$p_currentShowID;
|
||||
}
|
||||
if (isset($p_nextShowID)) {
|
||||
$predicateArr[] = 'st.instance_id = '.$p_nextShowID;
|
||||
}
|
||||
if ($p_nextShowID != null) {
|
||||
if ($p_previousShowID != null || $p_currentShowID != null)
|
||||
$sql .= ' OR ';
|
||||
$sql .= 'st.instance_id = '.$p_nextShowID;
|
||||
if($p_previousShowID != null || $p_currentShowID != null)
|
||||
$sql .= ')';
|
||||
} else if($p_previousShowID != null && $p_currentShowID != null)
|
||||
$sql .= ')';
|
||||
|
||||
$sql .= " (".implode(" OR ", $predicateArr).") ";
|
||||
$sql .= ' AND st.playout_status > 0 ORDER BY st.starts';
|
||||
|
||||
$filesSql = str_replace("%%columns%%", $fileColumns, $sql);
|
||||
$filesSql = str_replace("%%tables%%", $fileJoin, $filesSql);
|
||||
|
||||
$streamSql = str_replace("%%columns%%", $streamColumns, $sql);
|
||||
$streamSql = str_replace("%%tables%%", $streamJoin, $streamSql);
|
||||
|
||||
$sql = "SELECT * FROM (($filesSql) UNION ($streamSql)) AS unioned ORDER BY starts";
|
||||
|
||||
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
$numberOfRows = count($rows);
|
||||
|
@ -122,6 +121,8 @@ class Application_Model_Schedule
|
|||
if ($rows[$i]['ends'] > $rows[$i]["show_ends"]) {
|
||||
$rows[$i]['ends'] = $rows[$i]["show_ends"];
|
||||
}
|
||||
|
||||
|
||||
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)) {
|
||||
if ($i - 1 >= 0) {
|
||||
$results['previous'] = array("name"=>$rows[$i-1]["artist_name"]." - ".$rows[$i-1]["track_title"],
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<button id="spl_new" class="ui-button ui-widget ui-state-default" role="button" aria-disabled="false">New</button>
|
||||
<button id="ws_new" class="ui-button ui-widget ui-state-default" role="button" aria-disabled="false">New Stream</button>
|
||||
<?php if (isset($this->obj)) : ?>
|
||||
<button id="spl_delete" class="ui-button ui-widget ui-state-default" role="button" aria-disabled="false">Delete</button>
|
||||
<a href="#" id="spl_crossfade" class="ui-button ui-button-icon-only ui-widget ui-state-default crossfade-main-button">
|
||||
|
|
|
@ -796,21 +796,19 @@ var AIRTIME = (function(AIRTIME){
|
|||
|
||||
mod.init = function() {
|
||||
$.contextMenu({
|
||||
selector: '#spl_new',
|
||||
selector: '#spl_new, #ws_new',
|
||||
trigger: "left",
|
||||
ignoreRightClick: true,
|
||||
items: {
|
||||
"sp": {name: "New Playlist", callback: AIRTIME.playlist.fnNew},
|
||||
"sb": {name: "New Smart Playlist", callback: AIRTIME.playlist.fnNewBlock}
|
||||
"sb": {name: "New Smart Playlist", callback: AIRTIME.playlist.fnNewBlock},
|
||||
"ws": {name: "New Webstream", callback: AIRTIME.playlist.fnWsNew}
|
||||
}
|
||||
});
|
||||
/*
|
||||
$pl.delegate("#spl_new",
|
||||
{"click": AIRTIME.playlist.fnNew});*/
|
||||
|
||||
$pl.delegate("#ws_new",
|
||||
{"click": AIRTIME.playlist.fnWsNew});
|
||||
|
||||
$pl.delegate("#spl_delete", {"click": function(ev){
|
||||
AIRTIME.playlist.fnDelete();
|
||||
}});
|
||||
|
|
Loading…
Reference in New Issue