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:
parent
4f5d7869d8
commit
cf2ed25bfb
5 changed files with 71 additions and 61 deletions
|
@ -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 {}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue