= :start1::TIMESTAMP AND si1.starts < :end1::TIMESTAMP)
OR (si1.starts <= :start3::TIMESTAMP AND si1.ends >= :end3::TIMESTAMP))
ORDER BY si1.starts
SQL;
- return Application_Common_Database::prepareAndExecute( $sql,
- array(
+ $params = array_merge($params, array(
'start1' => $start_string,
'start2' => $start_string,
'start3' => $start_string,
'end1' => $end_string,
'end2' => $end_string,
'end3' => $end_string
- ), 'all');
+ )
+ );
+ return Application_Common_Database::prepareAndExecute( $sql, $params, 'all');
}
}
@@ -1016,10 +1027,10 @@ SQL;
//for putting the now playing icon on the show.
if ($now > $startsDT && $now < $endsDT) {
- $event["nowPlaying"] = true;
+ $event["nowPlaying"] = true;
}
else {
- $event["nowPlaying"] = false;
+ $event["nowPlaying"] = false;
}
//event colouring
@@ -1048,9 +1059,9 @@ SQL;
**/
private static function getPercentScheduled($p_starts, $p_ends, $p_time_filled)
{
- $utcTimezone = new DatetimeZone("UTC");
- $startDt = new DateTime($p_starts, $utcTimezone);
- $endDt = new DateTime($p_ends, $utcTimezone);
+ $utcTimezone = new DatetimeZone("UTC");
+ $startDt = new DateTime($p_starts, $utcTimezone);
+ $endDt = new DateTime($p_ends, $utcTimezone);
$durationSeconds = intval($endDt->format("U")) - intval($startDt->format("U"));
$time_filled = Application_Common_DateHelper::playlistTimeToSeconds($p_time_filled);
if ($durationSeconds != 0) { //Prevent division by zero if the show duration somehow becomes zero.
@@ -1311,7 +1322,6 @@ SQL;
$results['nextShow'][0] = array(
"id" => $rows[$i]['id'],
"instance_id" => $rows[$i]['instance_id'],
- "instance_description" => $rows[$i]['instance_description'],
"name" => $rows[$i]['name'],
"description" => $rows[$i]['description'],
"url" => $rows[$i]['url'],
@@ -1458,4 +1468,5 @@ SQL;
return array($start, $end);
}
+
}
diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php
index c3b423af6..c15cdc631 100644
--- a/airtime_mvc/application/models/ShowInstance.php
+++ b/airtime_mvc/application/models/ShowInstance.php
@@ -555,7 +555,7 @@ SQL;
}
- public function getShowListContent()
+ public function getShowListContent($timezone = null)
{
$con = Propel::getConnection();
@@ -606,9 +606,14 @@ SQL;
':instance_id2' => $this->_instanceId
));
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
-
- $userTimezone = Application_Model_Preference::GetUserTimezone();
- $displayTimezone = new DateTimeZone($userTimezone);
+
+ if (isset($timezone)) {
+ $displayTimezone = new DateTimeZone($timezone);
+ } else {
+ $userTimezone = Application_Model_Preference::GetUserTimezone();
+ $displayTimezone = new DateTimeZone($userTimezone);
+ }
+
$utcTimezone = new DateTimeZone("UTC");
foreach ($results as &$row) {
diff --git a/airtime_mvc/application/models/Webstream.php b/airtime_mvc/application/models/Webstream.php
index 21c794b07..a7e7d82b1 100644
--- a/airtime_mvc/application/models/Webstream.php
+++ b/airtime_mvc/application/models/Webstream.php
@@ -309,7 +309,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
$media_url = self::getXspfUrl($url);
} elseif (preg_match("/pls\+xml/", $mime) || preg_match("/x-scpls/", $mime)) {
$media_url = self::getPlsUrl($url);
- } elseif (preg_match("/(mpeg|ogg|audio\/aacp)/", $mime)) {
+ } elseif (preg_match("/(mpeg|ogg|audio\/aacp|audio\/aac)/", $mime)) {
if ($content_length_found) {
throw new Exception(_("Invalid webstream - This appears to be a file download."));
}
diff --git a/airtime_mvc/application/models/airtime/CcShow.php b/airtime_mvc/application/models/airtime/CcShow.php
index b9f140e3e..ee0c75454 100644
--- a/airtime_mvc/application/models/airtime/CcShow.php
+++ b/airtime_mvc/application/models/airtime/CcShow.php
@@ -304,4 +304,23 @@ class CcShow extends BaseCcShow {
->filterByDbId($instanceId, Criteria::NOT_EQUAL)
->find();
}
+
+ public function getShowInfo()
+ {
+ $info = array();
+ if ($this->getDbId() == null) {
+ return $info;
+ } else {
+ $info['name'] = $this->getDbName();
+ $info['id'] = $this->getDbId();
+ $info['url'] = $this->getDbUrl();
+ $info['genre'] = $this->getDbGenre();
+ $info['description'] = $this->getDbDescription();
+ $info['color'] = $this->getDbColor();
+ $info['background_color'] = $this->getDbBackgroundColor();
+ $info['linked'] = $this->getDbLinked();
+ return $info;
+ }
+
+ }
} // CcShow
diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php
index e29402974..d0a015f16 100644
--- a/airtime_mvc/application/modules/rest/controllers/MediaController.php
+++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php
@@ -79,35 +79,6 @@ class Rest_MediaController extends Zend_Rest_Controller
$this->fileNotFoundResponse();
}
}
-
- public function clearAction()
- {
- if (!$this->verifyAuth(true, true))
- {
- return;
- }
-
- //set file_exists flag to false for every file
- $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
- $selectCriteria = new Criteria();
- $selectCriteria->add(CcFilesPeer::FILE_EXISTS, true);
- $updateCriteria = new Criteria();
- $updateCriteria->add(CcFilesPeer::FILE_EXISTS, false);
- BasePeer::doUpdate($selectCriteria, $updateCriteria, $con);
-
- //delete all files and directories under .../imported
- $path = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."/srv/airtime/stor/imported/*" : "/srv/airtime/stor/imported/*";
- exec("rm -rf $path");
-
- //update disk_usage value in cc_pref
- $storDir = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."srv/airtime/stor" : "/srv/airtime/stor";
- $diskUsage = shell_exec("du -sb $storDir | awk '{print $1}'");
- Application_Model_Preference::setDiskUsage($diskUsage);
-
- $this->getResponse()
- ->setHttpResponseCode(200)
- ->appendBody("Library has been cleared");
- }
public function getAction()
{
diff --git a/airtime_mvc/application/services/HistoryService.php b/airtime_mvc/application/services/HistoryService.php
index 73821ce92..181e55a67 100644
--- a/airtime_mvc/application/services/HistoryService.php
+++ b/airtime_mvc/application/services/HistoryService.php
@@ -204,30 +204,34 @@ class Application_Service_HistoryService
//------------------------------------------------------------------------
//Using Datatables parameters to sort the data.
- $numOrderColumns = $opts["iSortingCols"];
- $orderBys = array();
+ if (empty($opts["iSortingCols"])) {
+ $orderBys = array();
+ } else {
+ $numOrderColumns = $opts["iSortingCols"];
+ $orderBys = array();
- for ($i = 0; $i < $numOrderColumns; $i++) {
+ for ($i = 0; $i < $numOrderColumns; $i++) {
- $colNum = $opts["iSortCol_".$i];
- $key = $opts["mDataProp_".$colNum];
- $sortDir = $opts["sSortDir_".$i];
+ $colNum = $opts["iSortCol_".$i];
+ $key = $opts["mDataProp_".$colNum];
+ $sortDir = $opts["sSortDir_".$i];
- if (in_array($key, $required)) {
+ if (in_array($key, $required)) {
- $orderBys[] = "history_range.{$key} {$sortDir}";
- }
- else if (in_array($key, $filemd_keys)) {
+ $orderBys[] = "history_range.{$key} {$sortDir}";
+ }
+ else if (in_array($key, $filemd_keys)) {
- $orderBys[] = "file_info.{$key} {$sortDir}";
- }
- else if (in_array($key, $general_keys)) {
+ $orderBys[] = "file_info.{$key} {$sortDir}";
+ }
+ else if (in_array($key, $general_keys)) {
- $orderBys[] = "{$key}_filter.{$key} {$sortDir}";
- }
- else {
- //throw new Exception("Error: $key is not part of the template.");
- }
+ $orderBys[] = "{$key}_filter.{$key} {$sortDir}";
+ }
+ else {
+ //throw new Exception("Error: $key is not part of the template.");
+ }
+ }
}
if (count($orderBys) > 0) {
@@ -241,7 +245,7 @@ class Application_Service_HistoryService
//---------------------------------------------------------------
//using Datatables parameters to add limits/offsets
- $displayLength = intval($opts["iDisplayLength"]);
+ $displayLength = empty($opts["iDisplayLength"]) ? -1 : intval($opts["iDisplayLength"]);
//limit the results returned.
if ($displayLength !== -1) {
$mainSqlQuery.=
@@ -275,14 +279,14 @@ class Application_Service_HistoryService
foreach ($fields as $index=>$field) {
if ($field["type"] == TEMPLATE_BOOLEAN) {
- $boolCast[] = $field["name"];
+ $boolCast[] = $field;
}
}
foreach ($rows as $index => &$result) {
- foreach ($boolCast as $name) {
- $result[$name] = (bool) $result[$name];
+ foreach ($boolCast as $field) {
+ $result[$field['label']] = (bool) $result[$field['name']];
}
//need to display the results in the station's timezone.
@@ -311,7 +315,7 @@ class Application_Service_HistoryService
}
return array(
- "sEcho" => intval($opts["sEcho"]),
+ "sEcho" => empty($opts["sEcho"]) ? null : intval($opts["sEcho"]),
//"iTotalDisplayRecords" => intval($totalDisplayRows),
"iTotalDisplayRecords" => intval($totalRows),
"iTotalRecords" => intval($totalRows),
@@ -445,9 +449,13 @@ class Application_Service_HistoryService
);
}
- public function getShowList($startDT, $endDT)
+ public function getShowList($startDT, $endDT, $userId = null)
{
- $user = Application_Model_User::getCurrentUser();
+ if (empty($userId)) {
+ $user = Application_Model_User::getCurrentUser();
+ } else {
+ $user = new Application_Model_User($userId);
+ }
$shows = Application_Model_Show::getShows($startDT, $endDT);
Logging::info($startDT->format("Y-m-d H:i:s"));
@@ -456,7 +464,7 @@ class Application_Service_HistoryService
Logging::info($shows);
//need to filter the list to only their shows
- if ($user->isHost()) {
+ if ((!empty($user)) && ($user->isHost())) {
$showIds = array();
@@ -1524,4 +1532,4 @@ class Application_Service_HistoryService
throw $e;
}
}
-}
\ No newline at end of file
+}
diff --git a/airtime_mvc/application/views/scripts/form/preferences.phtml b/airtime_mvc/application/views/scripts/form/preferences.phtml
index f32167ea7..475f86928 100644
--- a/airtime_mvc/application/views/scripts/form/preferences.phtml
+++ b/airtime_mvc/application/views/scripts/form/preferences.phtml
@@ -1,10 +1,5 @@
diff --git a/airtime_mvc/application/views/scripts/form/preferences_general.phtml b/airtime_mvc/application/views/scripts/form/preferences_general.phtml
index c8ab6bdb8..2cbe40c78 100644
--- a/airtime_mvc/application/views/scripts/form/preferences_general.phtml
+++ b/airtime_mvc/application/views/scripts/form/preferences_general.phtml
@@ -1,156 +1,25 @@
diff --git a/airtime_mvc/application/views/scripts/form/register-dialog.phtml b/airtime_mvc/application/views/scripts/form/register-dialog.phtml
index 999eb045d..358cc692a 100644
--- a/airtime_mvc/application/views/scripts/form/register-dialog.phtml
+++ b/airtime_mvc/application/views/scripts/form/register-dialog.phtml
@@ -3,10 +3,10 @@