From cf2ed25bfb5ac4dcc1c604d811a3f78765016405 Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 30 Jan 2013 16:53:59 -0500 Subject: [PATCH] CC-4900: Indicate in the library if a webstream is scheduled in the future or belongs to a playlist -done --- airtime_mvc/application/models/Playlist.php | 19 +++++- airtime_mvc/application/models/Schedule.php | 20 +++++++ airtime_mvc/application/models/StoredFile.php | 33 +++++++++-- airtime_mvc/public/css/styles.css | 2 +- .../public/js/airtime/library/library.js | 58 ++----------------- 5 files changed, 71 insertions(+), 61 deletions(-) diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index ea3bf5b53..7aaea5243 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -955,12 +955,13 @@ SQL; return $result; } - public static function getAllPlaylistContent() + public static function getAllPlaylistFiles() { $con = Propel::getConnection(); $sql = <<query($sql)->fetchAll(); $real_files = array(); @@ -970,6 +971,22 @@ SQL; return $real_files; } + public static function getAllPlaylistStreams() + { + $con = Propel::getConnection(); + $sql = <<query($sql)->fetchAll(); + $real_streams = array(); + foreach ($streams as $s) { + $real_streams[] = $s['stream_id']; + } + return $real_streams; + } + } // class Playlist class PlaylistNotFoundException extends Exception {} diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index c0fd53f4b..ca31a4378 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -27,14 +27,34 @@ SQL; SELECT distinct(file_id) FROM cc_schedule WHERE ends > now() AT TIME ZONE 'UTC' +AND file_id is not null SQL; $files = $con->query($sql)->fetchAll(); $real_files = array(); foreach ($files as $f) { $real_files[] = $f['file_id']; } + return $real_files; } + + public static function getAllFutureScheduledWebstreams() + { + $con = Propel::getConnection(); + $sql = << now() AT TIME ZONE 'UTC' +AND stream_id is not null +SQL; + $streams = $con->query($sql)->fetchAll(); + $real_streams = array(); + foreach ($streams as $s) { + $real_streams[] = $s['stream_id']; + } + + return $real_streams; + } /** * Returns data related to the scheduled items. * diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index a9bc15955..92a46f9c0 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -773,9 +773,14 @@ SQL; $results = Application_Model_Datatables::findEntries($con, $displayColumns, $fromTable, $datatables); $futureScheduledFiles = Application_Model_Schedule::getAllFutureScheduledFiles(); - $playlistBlockFiles = array_merge(Application_Model_Playlist::getAllPlaylistContent(), + // we are only interested in which files belong to playlists and blocks + $playlistBlockFiles = array_merge(Application_Model_Playlist::getAllPlaylistFiles(), Application_Model_Block::getAllBlockContent()); + $futureScheduledStreams = Application_Model_Schedule::getAllFutureScheduledWebstreams(); + // here we are only interested in which streams belong to a playlist + $playlistStreams = Application_Model_Playlist::getAllPlaylistStreams(); + foreach ($results['aaData'] as &$row) { $row['id'] = intval($row['id']); @@ -792,18 +797,34 @@ SQL; //soundcloud status $file = Application_Model_StoredFile::Recall($row['id']); $row['soundcloud_status'] = $file->getSoundCloudId(); - + //file 'in use' status if (in_array($row['id'], $futureScheduledFiles) && in_array($row['id'], $playlistBlockFiles)) { - $row['status_scheduled_pl_bl'] = true; + $row['status_in_use'] = true; + $row['status_msg'] = _("This track is scheduled in the future and belongs to a playlist or smart block"); } elseif (in_array($row['id'], $futureScheduledFiles)) { - $row['status_scheduled'] = true; + $row['status_in_use'] = true; + $row['status_msg'] = _("This track is scheduled in the future"); } elseif (in_array($row['id'], $playlistBlockFiles)) { - $row['status_pl_bl'] = true; + $row['status_in_use'] = true; + $row['status_msg'] = _("This track belongs to a playlist or smart block"); } - + // for audio preview $row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION); + } else if ($row['ftype'] === "stream") { + $row['audioFile'] = $row['id']; + + if (in_array($row['id'], $futureScheduledStreams) && in_array($row['id'], $playlistStreams)) { + $row['status_in_use'] = true; + $row['status_msg'] = _("This webstream is scheduled in the future and belongs to a playlist"); + } elseif (in_array($row['id'], $futureScheduledStreams)) { + $row['status_in_use'] = true; + $row['status_msg'] = _("This webstream is scheduled in the future"); + } elseif (in_array($row['id'], $playlistStreams)) { + $row['status_in_use'] = true; + $row['status_msg'] = _("This webstream belongs to a playlist"); + } } else { $row['audioFile'] = $row['id']; } diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index bd42e4da6..31b85797d 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -1999,7 +1999,7 @@ span.errors.sp-errors{ .small-icon.show-empty { background:url(images/icon_alert_cal_alt.png) no-repeat 0 0; } -.small-icon.show-partial-filled { +.small-icon.show-partial-filled, .small-icon.media-item-in-use { background:url(images/icon_alert_cal_alt2.png) no-repeat 0 0; } .medium-icon { diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 4f64b6f70..042a7d1cf 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -580,16 +580,8 @@ var AIRTIME = (function(AIRTIME) { $(nRow).find('td.library_type').html(''); } - // add status icon - $status = $(nRow).find("td.library_status"); - if (aData.status_scheduled_pl_bl !== null && aData.status_scheduled_pl_bl) { - $status.html(''); - } - if (aData.status_scheduled !== null && aData.status_scheduled) { - $status.html(''); - } - if (aData.status_pl_bl !== null && aData.status_pl_bl) { - $status.html(''); + if (aData.status_in_use !== null && aData.status_in_use) { + $(nRow).find("td.library_status").html(''); } // add the play function to the library_type td @@ -641,9 +633,9 @@ var AIRTIME = (function(AIRTIME) { return false; }); - $(nRow).find(".track-scheduled").qtip({ + $(nRow).find(".media-item-in-use").qtip({ content: { - text: $.i18n._("This track is scheduled in the future") + text: aData.status_msg }, hide: { delay: 500, @@ -661,47 +653,7 @@ var AIRTIME = (function(AIRTIME) { at: "right center" }, }); - $(nRow).find(".track-sched-pl-bl").qtip({ - content: { - text: $.i18n._("This track is scheduled in the future and belongs to a playlist or smart block") - }, - hide: { - delay: 500, - fixed: true - }, - style: { - border: { - width: 0, - radius: 4 - }, - classes: "ui-tooltip-dark ui-tooltip-rounded" - }, - position: { - my: "left bottom", - at: "right center" - }, - }); - $(nRow).find(".track-pl-bl").qtip({ - content: { - text: $.i18n._("This track belongs to a playlist or smart block") - }, - hide: { - delay: 500, - fixed: true - }, - style: { - border: { - width: 0, - radius: 4 - }, - classes: "ui-tooltip-dark ui-tooltip-rounded" - }, - position: { - my: "left bottom", - at: "right center" - }, - }); - + // add a tool tip to appear when the user clicks on the type // icon. $(nRow).find("td:not(.library_checkbox, .library_type)").qtip({