diff --git a/src/modules/htmlUI/var/ui_scheduler.class.php b/src/modules/htmlUI/var/ui_scheduler.class.php
index eb3b61a79..b944c61d3 100644
--- a/src/modules/htmlUI/var/ui_scheduler.class.php
+++ b/src/modules/htmlUI/var/ui_scheduler.class.php
@@ -308,18 +308,28 @@ class uiScheduler extends uiCalendar {
$items = array();
foreach ($arr as $key => $val) {
- $id = BasicStor::IdFromGunid($val['playlistId']);
+ if ($val["count"] == "1") {
+ $track = StoredFile::Recall($val["file_id"]);
+ $trackMetadata = $track->getMetadata();
+ $title = $trackMetadata["track_title"];
+ $creator = $trackMetadata["artist_name"];
+ } else {
+ $title = $val["name"];
+ $creator = $val["creator"];
+ }
+
+ $id = $val["group_id"]; //BasicStor::IdFromGunid($val['playlistId']);
$startDay = strftime('%d', self::datetimeToTimestamp($val['start']));
$startHour = number_format(strftime('%H', self::datetimeToTimestamp($val['start'])));
$items[$startDay][$startHour][]= array (
'id' => $id,
- 'scheduleid'=> $val['id'],
- 'start' => substr($val['start'], strpos($val['start'], 'T')+1),
- 'end' => substr($val['end'], strpos($val['end'], 'T')+1),
+ 'scheduleid'=> $id, //$val['id'],
+ 'start' => substr($val['start'], strpos($val['start'], ' ')+1),
+ 'end' => substr($val['end'], strpos($val['end'], ' ')+1),
'start_stamp' => self::datetimeToTimestamp($val['start']),
'end_stamp' => self::datetimeToTimestamp($val['end']),
- 'title' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE),
- 'creator' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR),
+ 'title' => $title,
+ 'creator' => $creator,
'type' => 'Playlist'
);
}
@@ -358,11 +368,16 @@ class uiScheduler extends uiCalendar {
$endHour = (int)strftime('%H', $end);
$startTime = substr($val['start'], strpos($val['start'], ' ')+1);
$endTime = substr($val['end'], strpos($val['end'], ' ') + 1);
- $track = StoredFile::Recall($val["file_id"]);
- $trackMetadata = $track->getMetadata();
- $title = $trackMetadata["track_title"];
- $creator = $trackMetadata["artist_name"];
+ if ($val["count"] == "1") {
+ $track = StoredFile::Recall($val["file_id"]);
+ $trackMetadata = $track->getMetadata();
+ $title = $trackMetadata["track_title"];
+ $creator = $trackMetadata["artist_name"];
+ } else {
+ $title = $val["name"];
+ $creator = $val["creator"];
+ }
// Item starts today
if (strftime('%Y-%m-%d', $start) === $thisDay) {
$endsToday = (strftime('%d', $start) === strftime('%d', $end)) ? TRUE : FALSE;
@@ -1088,9 +1103,9 @@ class uiScheduler extends uiCalendar {
* In the format "YYYY-MM-DD HH:MM:SS.nnnnnn"
* @return array|false
*/
- function displayScheduleMethod($from, $to)
+ function displayScheduleMethod($p_from, $p_to, $p_playlistsOnly = true)
{
- $items = Schedule::GetItems($from, $to);
+ $items = Schedule::GetItems($p_from, $p_to, $p_playlistsOnly);
//$_SESSION["debug"] = $items;
return $items;
} // fn displayScheduleMethod
diff --git a/src/modules/storageServer/var/Schedule.php b/src/modules/storageServer/var/Schedule.php
index f771fbd4a..9d84a7464 100644
--- a/src/modules/storageServer/var/Schedule.php
+++ b/src/modules/storageServer/var/Schedule.php
@@ -235,26 +235,55 @@ class Schedule {
/**
* Returns array indexed numberically of:
- * "playlistId" (gunid)
- * "start"
- * "end"
- * "id" (DB id)
+ * "playlistId"/"playlist_id" (aliases to the same thing)
+ * "start"/"starts" (aliases to the same thing)
+ * "end"/"ends" (aliases to the same thing)
+ * "group_id"/"id" (aliases to the same thing)
+ * "clip_length"
+ * "name" (playlist only)
+ * "creator" (playlist only)
+ * "file_id" (audioclip only)
+ * "count" (number of items in the playlist, always 1 for audioclips.
+ * Note that playlists with one item will also have count = 1.
*
- * @param $fromDateTime
+ * @param string $p_fromDateTime
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
- * @param $toDateTime
+ * @param string $p_toDateTime
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
+ * @param boolean $p_playlistsOnly
+ * Retreive playlists as a single item.
*/
- public static function GetItems($fromDateTime, $toDateTime, $playlistsOnly = true) {
+ public static function GetItems($p_fromDateTime, $p_toDateTime, $p_playlistsOnly = true) {
global $CC_CONFIG, $CC_DBC;
- $sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
- ." WHERE (starts >= TIMESTAMP '$fromDateTime') "
- ." AND (ends <= TIMESTAMP '$toDateTime')";
- $rows = $CC_DBC->GetAll($sql);
- foreach ($rows as &$row) {
- $row["playlistId"] = $row["playlist_id"];
- $row["start"] = $row["starts"];
- $row["end"] = $row["ends"];
+ if (!$p_playlistsOnly) {
+ $sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
+ ." WHERE (starts >= TIMESTAMP '$p_fromDateTime') "
+ ." AND (ends <= TIMESTAMP '$p_toDateTime')";
+ $rows = $CC_DBC->GetAll($sql);
+ foreach ($rows as &$row) {
+ $row["count"] = "1";
+ $row["playlistId"] = $row["playlist_id"];
+ $row["start"] = $row["starts"];
+ $row["end"] = $row["ends"];
+ $row["id"] = $row["group_id"];
+ }
+ } else {
+ $sql = "SELECT MIN(name) AS name, MIN(creator) AS creator, group_id, "
+ ." SUM(clip_length) AS clip_length,"
+ ." MIN(file_id) AS file_id, COUNT(*) as count,"
+ ." MIN(playlist_id) AS playlist_id, MIN(starts) AS starts, MAX(ends) AS ends"
+ ." FROM ".$CC_CONFIG["scheduleTable"]
+ ." LEFT JOIN ".$CC_CONFIG["playListTable"]." ON playlist_id = ".$CC_CONFIG["playListTable"].".id"
+ ." WHERE (starts >= TIMESTAMP '$p_fromDateTime') AND (ends <= TIMESTAMP '$p_toDateTime')"
+ ." GROUP BY group_id"
+ ." ORDER BY starts";
+ $rows = $CC_DBC->GetAll($sql);
+ foreach ($rows as &$row) {
+ $row["playlistId"] = $row["playlist_id"];
+ $row["start"] = $row["starts"];
+ $row["end"] = $row["ends"];
+ $row["id"] = $row["group_id"];
+ }
}
return $rows;
}