CC-4900: Indicate in the library if a webstream is scheduled in the future or belongs to a playlist

-done
This commit is contained in:
denise 2013-01-30 16:53:59 -05:00
parent 4f5d7869d8
commit cf2ed25bfb
5 changed files with 71 additions and 61 deletions

View file

@ -955,12 +955,13 @@ SQL;
return $result;
}
public static function getAllPlaylistContent()
public static function getAllPlaylistFiles()
{
$con = Propel::getConnection();
$sql = <<<SQL
SELECT distinct(file_id)
FROM cc_playlistcontents
WHERE file_id is not null
SQL;
$files = $con->query($sql)->fetchAll();
$real_files = array();
@ -970,6 +971,22 @@ SQL;
return $real_files;
}
public static function getAllPlaylistStreams()
{
$con = Propel::getConnection();
$sql = <<<SQL
SELECT distinct(stream_id)
FROM cc_playlistcontents
WHERE 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;
}
} // class Playlist
class PlaylistNotFoundException extends Exception {}

View file

@ -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 = <<<SQL
SELECT distinct(stream_id)
FROM cc_schedule
WHERE ends > 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.
*

View file

@ -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']);
@ -795,15 +800,31 @@ SQL;
//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'];
}

View file

@ -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 {

View file

@ -580,16 +580,8 @@ var AIRTIME = (function(AIRTIME) {
$(nRow).find('td.library_type').html('<img title="'+$.i18n._("Webstream preview")+'" src="'+baseUrl+'css/images/icon_webstream.png">');
}
// add status icon
$status = $(nRow).find("td.library_status");
if (aData.status_scheduled_pl_bl !== null && aData.status_scheduled_pl_bl) {
$status.html('<span class="small-icon show-partial-filled track-sched-pl-bl"></span>');
}
if (aData.status_scheduled !== null && aData.status_scheduled) {
$status.html('<span class="small-icon show-partial-filled track-scheduled"></span>');
}
if (aData.status_pl_bl !== null && aData.status_pl_bl) {
$status.html('<span class="small-icon show-partial-filled track-pl-bl"></span>');
if (aData.status_in_use !== null && aData.status_in_use) {
$(nRow).find("td.library_status").html('<span class="small-icon media-item-in-use"></span>');
}
// add the play function to the library_type td
@ -641,49 +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")
},
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-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")
text: aData.status_msg
},
hide: {
delay: 500,