Merge pull request #734 from mikeopensauce/726apionairfix

Bugfix for #726. Fixes onAirLightAction returning 500 error
This commit is contained in:
Kyle Robbertze 2019-02-17 18:45:10 +02:00 committed by GitHub
commit e13fc6b3d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 74 additions and 73 deletions

View File

@ -15,12 +15,12 @@ class ApiController extends Zend_Controller_Action
} }
//Ignore API key and session authentication for these APIs: //Ignore API key and session authentication for these APIs:
$ignoreAuth = array("live-info", $ignoreAuth = array("live-info",
"live-info-v2", "live-info-v2",
"week-info", "week-info",
"station-metadata", "station-metadata",
"station-logo", "station-logo",
"show-history-feed", "show-history-feed",
"item-history-feed", "item-history-feed",
"shows", "shows",
"show-tracks", "show-tracks",
@ -178,6 +178,7 @@ class ApiController extends Zend_Controller_Action
//Used by the SaaS monitoring //Used by the SaaS monitoring
public function onAirLightAction() public function onAirLightAction()
{ {
$request = $this->getRequest();
$this->view->layout()->disableLayout(); $this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true); $this->_helper->viewRenderer->setNoRender(true);
@ -188,9 +189,9 @@ class ApiController extends Zend_Controller_Action
$range = Application_Model_Schedule::GetPlayOrderRange(); $range = Application_Model_Schedule::GetPlayOrderRange();
$isItemCurrentlyScheduled = !is_null($range["current"]) && count($range["currentShow"]) > 0 ? true : false; $isItemCurrentlyScheduled = !is_null($range["tracks"]["current"]) && count($range["tracks"]["current"]) > 0 ? true : false;
$isCurrentItemPlaying = $range["current"]["media_item_played"] ? true : false; $isCurrentItemPlaying = $range["tracks"]["current"]["media_item_played"] ? true : false;
if ($isItemCurrentlyScheduled || if ($isItemCurrentlyScheduled ||
Application_Model_Preference::GetSourceSwitchStatus("live_dj") == "on" || Application_Model_Preference::GetSourceSwitchStatus("live_dj") == "on" ||
@ -212,7 +213,7 @@ class ApiController extends Zend_Controller_Action
$this->returnJsonOrJsonp($request, $result); $this->returnJsonOrJsonp($request, $result);
} }
/** /**
* Retrieve the currently playing show as well as upcoming shows. * Retrieve the currently playing show as well as upcoming shows.
* Number of shows returned and the time interval in which to * Number of shows returned and the time interval in which to
@ -234,18 +235,18 @@ class ApiController extends Zend_Controller_Action
// disable the view and the layout // disable the view and the layout
$this->view->layout()->disableLayout(); $this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true); $this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest(); $request = $this->getRequest();
$utcTimeNow = gmdate(DEFAULT_TIMESTAMP_FORMAT); $utcTimeNow = gmdate(DEFAULT_TIMESTAMP_FORMAT);
$utcTimeEnd = ""; // if empty, getNextShows will use interval instead of end of day $utcTimeEnd = ""; // if empty, getNextShows will use interval instead of end of day
// default to the station timezone // default to the station timezone
$timezone = Application_Model_Preference::GetDefaultTimezone(); $timezone = Application_Model_Preference::GetDefaultTimezone();
$userDefinedTimezone = strtolower($request->getParam('timezone')); $userDefinedTimezone = strtolower($request->getParam('timezone'));
$upcase = false; // only upcase the timezone abbreviations $upcase = false; // only upcase the timezone abbreviations
$this->updateTimezone($userDefinedTimezone, $timezone, $upcase); $this->updateTimezone($userDefinedTimezone, $timezone, $upcase);
$type = $request->getParam('type'); $type = $request->getParam('type');
$limit = $request->getParam('limit'); $limit = $request->getParam('limit');
if ($limit == "" || !is_numeric($limit)) { if ($limit == "" || !is_numeric($limit)) {
@ -255,12 +256,12 @@ class ApiController extends Zend_Controller_Action
* we are using two entirely different codepaths for very similar functionality (type = endofday * we are using two entirely different codepaths for very similar functionality (type = endofday
* vs type = interval). Needs to be fixed for 2.3 - MK */ * vs type = interval). Needs to be fixed for 2.3 - MK */
if ($type == "endofday") { if ($type == "endofday") {
// make getNextShows use end of day // make getNextShows use end of day
$end = Application_Common_DateHelper::getTodayStationEndDateTime(); $end = Application_Common_DateHelper::getTodayStationEndDateTime();
$end->setTimezone(new DateTimeZone("UTC")); $end->setTimezone(new DateTimeZone("UTC"));
$utcTimeEnd = $end->format(DEFAULT_TIMESTAMP_FORMAT); $utcTimeEnd = $end->format(DEFAULT_TIMESTAMP_FORMAT);
$result = array( $result = array(
"env" => APPLICATION_ENV, "env" => APPLICATION_ENV,
"schedulerTime" => $utcTimeNow, "schedulerTime" => $utcTimeNow,
@ -282,7 +283,7 @@ class ApiController extends Zend_Controller_Action
array("starts", "ends", "start_timestamp","end_timestamp"), array("starts", "ends", "start_timestamp","end_timestamp"),
$timezone $timezone
); );
//Convert the UTC scheduler time ("now") to the user-defined timezone. //Convert the UTC scheduler time ("now") to the user-defined timezone.
$result["schedulerTime"] = Application_Common_DateHelper::UTCStringToTimezoneString($result["schedulerTime"], $timezone); $result["schedulerTime"] = Application_Common_DateHelper::UTCStringToTimezoneString($result["schedulerTime"], $timezone);
$result["timezone"] = $upcase ? strtoupper($timezone) : $timezone; $result["timezone"] = $upcase ? strtoupper($timezone) : $timezone;
@ -326,13 +327,13 @@ class ApiController extends Zend_Controller_Action
$this->_helper->viewRenderer->setNoRender(true); $this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest(); $request = $this->getRequest();
// default to the station timezone // default to the station timezone
$timezone = Application_Model_Preference::GetDefaultTimezone(); $timezone = Application_Model_Preference::GetDefaultTimezone();
$userDefinedTimezone = strtolower($request->getParam('timezone')); $userDefinedTimezone = strtolower($request->getParam('timezone'));
$upcase = false; // only upcase the timezone abbreviations $upcase = false; // only upcase the timezone abbreviations
$this->updateTimezone($userDefinedTimezone, $timezone, $upcase); $this->updateTimezone($userDefinedTimezone, $timezone, $upcase);
$daysToRetrieve = $request->getParam('days'); $daysToRetrieve = $request->getParam('days');
$showsToRetrieve = $request->getParam('shows'); $showsToRetrieve = $request->getParam('shows');
if ($daysToRetrieve == "" || !is_numeric($daysToRetrieve)) { if ($daysToRetrieve == "" || !is_numeric($daysToRetrieve)) {
@ -341,7 +342,7 @@ class ApiController extends Zend_Controller_Action
if ($showsToRetrieve == "" || !is_numeric($showsToRetrieve)) { if ($showsToRetrieve == "" || !is_numeric($showsToRetrieve)) {
$showsToRetrieve = self::DEFAULT_SHOWS_TO_RETRIEVE; $showsToRetrieve = self::DEFAULT_SHOWS_TO_RETRIEVE;
} }
// set the end time to the day's start n days from now. // set the end time to the day's start n days from now.
// days=1 will return shows until the end of the current day, // days=1 will return shows until the end of the current day,
// days=2 will return shows until the end of tomorrow, etc. // days=2 will return shows until the end of tomorrow, etc.
@ -350,7 +351,7 @@ class ApiController extends Zend_Controller_Action
$utcTimeEnd = $end->format(DEFAULT_TIMESTAMP_FORMAT); $utcTimeEnd = $end->format(DEFAULT_TIMESTAMP_FORMAT);
$result = Application_Model_Schedule::GetPlayOrderRange($utcTimeEnd, $showsToRetrieve); $result = Application_Model_Schedule::GetPlayOrderRange($utcTimeEnd, $showsToRetrieve);
// apply user-defined timezone, or default to station // apply user-defined timezone, or default to station
$this->applyLiveTimezoneAdjustments($result, $timezone, $upcase); $this->applyLiveTimezoneAdjustments($result, $timezone, $upcase);
@ -359,7 +360,7 @@ class ApiController extends Zend_Controller_Action
// convert image paths to point to api endpoints // convert image paths to point to api endpoints
WidgetHelper::findAndConvertPaths($result); WidgetHelper::findAndConvertPaths($result);
// used by caller to determine if the airtime they are running or widgets in use is out of date. // used by caller to determine if the airtime they are running or widgets in use is out of date.
$result["station"]["AIRTIME_API_VERSION"] = AIRTIME_API_VERSION; $result["station"]["AIRTIME_API_VERSION"] = AIRTIME_API_VERSION;
@ -370,12 +371,12 @@ class ApiController extends Zend_Controller_Action
exit; exit;
} }
} }
/** /**
* Check that the value for the timezone the user gave is valid. * Check that the value for the timezone the user gave is valid.
* If it is, override the default (station) timezone. * If it is, override the default (station) timezone.
* If it's an abbreviation (pst, edt) we upcase the output. * If it's an abbreviation (pst, edt) we upcase the output.
* *
* @param string $userDefinedTimezone the requested timezone value * @param string $userDefinedTimezone the requested timezone value
* @param string $timezone the default timezone * @param string $timezone the default timezone
* @param boolean $upcase whether the timezone output should be upcased * @param boolean $upcase whether the timezone output should be upcased
@ -396,28 +397,28 @@ class ApiController extends Zend_Controller_Action
$timezone = $userDefinedTimezone; $timezone = $userDefinedTimezone;
} }
} }
/** /**
* If the user passed in a timezone parameter, adjust timezone-dependent * If the user passed in a timezone parameter, adjust timezone-dependent
* variables in the result to reflect the given timezone. * variables in the result to reflect the given timezone.
* *
* @param array $result reference to the object to send back to the user * @param array $result reference to the object to send back to the user
* @param string $timezone the user's timezone parameter value * @param string $timezone the user's timezone parameter value
* @param boolean $upcase whether the timezone output should be upcased * @param boolean $upcase whether the timezone output should be upcased
*/ */
private function applyLiveTimezoneAdjustments(&$result, $timezone, $upcase) private function applyLiveTimezoneAdjustments(&$result, $timezone, $upcase)
{ {
Application_Common_DateHelper::convertTimestampsToTimezone( Application_Common_DateHelper::convertTimestampsToTimezone(
$result, $result,
array("starts", "ends", "start_timestamp","end_timestamp"), array("starts", "ends", "start_timestamp","end_timestamp"),
$timezone $timezone
); );
//Convert the UTC scheduler time ("now") to the user-defined timezone. //Convert the UTC scheduler time ("now") to the user-defined timezone.
$result["station"]["schedulerTime"] = Application_Common_DateHelper::UTCStringToTimezoneString($result["station"]["schedulerTime"], $timezone); $result["station"]["schedulerTime"] = Application_Common_DateHelper::UTCStringToTimezoneString($result["station"]["schedulerTime"], $timezone);
$result["station"]["timezone"] = $upcase ? strtoupper($timezone) : $timezone; $result["station"]["timezone"] = $upcase ? strtoupper($timezone) : $timezone;
} }
public function weekInfoAction() public function weekInfoAction()
{ {
if (Application_Model_Preference::GetAllow3rdPartyApi() || $this->checkAuth()) { if (Application_Model_Preference::GetAllow3rdPartyApi() || $this->checkAuth()) {
@ -438,11 +439,11 @@ class ApiController extends Zend_Controller_Action
exit; exit;
} }
} }
/** /**
* API endpoint to display the show logo * API endpoint to display the show logo
*/ */
public function showLogoAction() public function showLogoAction()
{ {
// Disable the view and the layout // Disable the view and the layout
$this->view->layout()->disableLayout(); $this->view->layout()->disableLayout();
@ -459,7 +460,7 @@ class ApiController extends Zend_Controller_Action
if (empty($show)) { if (empty($show)) {
throw new ZendActionHttpException($this, 400, "ERROR: No show with ID $showId exists."); throw new ZendActionHttpException($this, 400, "ERROR: No show with ID $showId exists.");
} }
$path = $show->getDbImagePath(); $path = $show->getDbImagePath();
try { try {
$mime_type = mime_content_type($path); $mime_type = mime_content_type($path);
@ -488,9 +489,9 @@ class ApiController extends Zend_Controller_Action
header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.0 401 Unauthorized');
print _('You are not allowed to access this resource. '); print _('You are not allowed to access this resource. ');
exit; exit;
} }
} }
/** /**
* API endpoint to provide station metadata * API endpoint to provide station metadata
*/ */
@ -500,18 +501,18 @@ class ApiController extends Zend_Controller_Action
// disable the view and the layout // disable the view and the layout
$this->view->layout()->disableLayout(); $this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true); $this->_helper->viewRenderer->setNoRender(true);
$CC_CONFIG = Config::getConfig(); $CC_CONFIG = Config::getConfig();
$baseDir = Application_Common_OsPath::formatDirectoryWithDirectorySeparators($CC_CONFIG['baseDir']); $baseDir = Application_Common_OsPath::formatDirectoryWithDirectorySeparators($CC_CONFIG['baseDir']);
$path = 'http://'.$_SERVER['HTTP_HOST'].$baseDir."api/station-logo"; $path = 'http://'.$_SERVER['HTTP_HOST'].$baseDir."api/station-logo";
$result["name"] = Application_Model_Preference::GetStationName(); $result["name"] = Application_Model_Preference::GetStationName();
$result["logo"] = $path; $result["logo"] = $path;
$result["description"] = Application_Model_Preference::GetStationDescription(); $result["description"] = Application_Model_Preference::GetStationDescription();
$result["timezone"] = Application_Model_Preference::GetDefaultTimezone(); $result["timezone"] = Application_Model_Preference::GetDefaultTimezone();
$result["locale"] = Application_Model_Preference::GetDefaultLocale(); $result["locale"] = Application_Model_Preference::GetDefaultLocale();
$result["stream_data"] = Application_Model_StreamSetting::getEnabledStreamData(); $result["stream_data"] = Application_Model_StreamSetting::getEnabledStreamData();
// used by caller to determine if the airtime they are running or widgets in use is out of date. // used by caller to determine if the airtime they are running or widgets in use is out of date.
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION;
@ -526,27 +527,27 @@ class ApiController extends Zend_Controller_Action
/** /**
* API endpoint to display the current station logo * API endpoint to display the current station logo
*/ */
public function stationLogoAction() public function stationLogoAction()
{ {
if (Application_Model_Preference::GetAllow3rdPartyApi() || $this->checkAuth()) { if (Application_Model_Preference::GetAllow3rdPartyApi() || $this->checkAuth()) {
// disable the view and the layout // disable the view and the layout
$this->view->layout()->disableLayout(); $this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true); $this->_helper->viewRenderer->setNoRender(true);
$logo = Application_Model_Preference::GetStationLogo(); $logo = Application_Model_Preference::GetStationLogo();
// if there's no logo, just die - redirects to a 404 // if there's no logo, just die - redirects to a 404
if (!$logo || $logo === '') { if (!$logo || $logo === '') {
return; return;
} }
// we're passing this as an image instead of using it in a data uri, so decode it // we're passing this as an image instead of using it in a data uri, so decode it
$blob = base64_decode($logo); $blob = base64_decode($logo);
// use finfo to get the mimetype from the decoded blob // use finfo to get the mimetype from the decoded blob
$f = finfo_open(); $f = finfo_open();
$mime_type = finfo_buffer($f, $blob, FILEINFO_MIME_TYPE); $mime_type = finfo_buffer($f, $blob, FILEINFO_MIME_TYPE);
finfo_close($f); finfo_close($f);
header("Content-Type: " . $mime_type); header("Content-Type: " . $mime_type);
echo $blob; echo $blob;
} else { } else {
@ -555,7 +556,7 @@ class ApiController extends Zend_Controller_Action
exit; exit;
} }
} }
public function scheduleAction() public function scheduleAction()
{ {
$this->view->layout()->disableLayout(); $this->view->layout()->disableLayout();
@ -571,13 +572,13 @@ class ApiController extends Zend_Controller_Action
public function notifyMediaItemStartPlayAction() public function notifyMediaItemStartPlayAction()
{ {
$media_id = $this->_getParam("media_id"); $media_id = $this->_getParam("media_id");
// We send a fake media id when playing on-demand ads; // We send a fake media id when playing on-demand ads;
// in this case, simply return // in this case, simply return
if ($media_id === '0' || $media_id === '-1') { if ($media_id === '0' || $media_id === '-1') {
return; return;
} }
Logging::debug("Received notification of new media item start: $media_id"); Logging::debug("Received notification of new media item start: $media_id");
Application_Model_Schedule::UpdateMediaPlayedStatus($media_id); Application_Model_Schedule::UpdateMediaPlayedStatus($media_id);
@ -619,7 +620,7 @@ class ApiController extends Zend_Controller_Action
$this->_helper->json->sendJson(array("status"=>1, "message"=>"")); $this->_helper->json->sendJson(array("status"=>1, "message"=>""));
} }
public function recordedShowsAction() public function recordedShowsAction()
{ {
$utcTimezone = new DateTimeZone("UTC"); $utcTimezone = new DateTimeZone("UTC");
@ -637,7 +638,7 @@ class ApiController extends Zend_Controller_Action
$this->view->server_timezone = Application_Model_Preference::GetDefaultTimezone(); $this->view->server_timezone = Application_Model_Preference::GetDefaultTimezone();
$rows = Application_Model_Show::getCurrentShow(); $rows = Application_Model_Show::getCurrentShow();
if (count($rows) > 0) { if (count($rows) > 0) {
$this->view->is_recording = ($rows[0]['record'] == 1); $this->view->is_recording = ($rows[0]['record'] == 1);
} }
@ -664,7 +665,7 @@ class ApiController extends Zend_Controller_Action
try { try {
$show_inst = new Application_Model_ShowInstance($show_instance_id); $show_inst = new Application_Model_ShowInstance($show_instance_id);
$show_inst->setRecordedFile($file_id); $show_inst->setRecordedFile($file_id);
} }
catch (Exception $e) { catch (Exception $e) {
//we've reached here probably because the show was //we've reached here probably because the show was
//cancelled, and therefore the show instance does not exist //cancelled, and therefore the show instance does not exist
@ -717,7 +718,7 @@ class ApiController extends Zend_Controller_Action
if ($md['is_record'] != 0) { if ($md['is_record'] != 0) {
$this->uploadRecordedActionParam($md['MDATA_KEY_TRACKNUMBER'], $file->getId()); $this->uploadRecordedActionParam($md['MDATA_KEY_TRACKNUMBER'], $file->getId());
} }
} elseif ($mode == "modify") { } elseif ($mode == "modify") {
$filepath = $md['MDATA_KEY_FILEPATH']; $filepath = $md['MDATA_KEY_FILEPATH'];
$file = Application_Model_StoredFile::RecallByFilepath($filepath, $con); $file = Application_Model_StoredFile::RecallByFilepath($filepath, $con);
@ -830,7 +831,7 @@ class ApiController extends Zend_Controller_Action
} catch (Exception $e) { } catch (Exception $e) {
Logging::warn($e->getMessage()); Logging::warn($e->getMessage());
Logging::warn(gettype($e)); Logging::warn(gettype($e));
} }
// We tack on the 'key' back to every request in case the would like to associate // We tack on the 'key' back to every request in case the would like to associate
// his requests with particular responses // his requests with particular responses
$response['key'] = $k; $response['key'] = $k;
@ -1085,7 +1086,7 @@ class ApiController extends Zend_Controller_Action
} elseif ($djtype == "dj") { } elseif ($djtype == "dj") {
//check against show dj auth //check against show dj auth
$showInfo = Application_Model_Show::getCurrentShow(); $showInfo = Application_Model_Show::getCurrentShow();
// there is current playing show // there is current playing show
if (isset($showInfo[0]['id'])) { if (isset($showInfo[0]['id'])) {
$current_show_id = $showInfo[0]['id']; $current_show_id = $showInfo[0]['id'];
@ -1139,12 +1140,12 @@ class ApiController extends Zend_Controller_Action
$this->_helper->json->sendJson($rows); $this->_helper->json->sendJson($rows);
} }
public function getFilesWithoutSilanValueAction() public function getFilesWithoutSilanValueAction()
{ {
//connect to db and get get sql //connect to db and get get sql
$rows = Application_Model_StoredFile::getAllFilesWithoutSilan(); $rows = Application_Model_StoredFile::getAllFilesWithoutSilan();
$this->_helper->json->sendJson($rows); $this->_helper->json->sendJson($rows);
} }
@ -1163,7 +1164,7 @@ class ApiController extends Zend_Controller_Action
$this->_helper->json->sendJson(array()); $this->_helper->json->sendJson(array());
} }
public function updateCueValuesBySilanAction() public function updateCueValuesBySilanAction()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
@ -1213,12 +1214,12 @@ class ApiController extends Zend_Controller_Action
$data = $request->getParam("data"); $data = $request->getParam("data");
$media_id = intval($request->getParam("media_id")); $media_id = intval($request->getParam("media_id"));
$data_arr = json_decode($data); $data_arr = json_decode($data);
//$media_id is -1 sometimes when a stream has stopped playing //$media_id is -1 sometimes when a stream has stopped playing
if (!is_null($media_id) && $media_id > 0) { if (!is_null($media_id) && $media_id > 0) {
if (isset($data_arr->title)) { if (isset($data_arr->title)) {
$data_title = substr($data_arr->title, 0, 1024); $data_title = substr($data_arr->title, 0, 1024);
$previous_metadata = CcWebstreamMetadataQuery::create() $previous_metadata = CcWebstreamMetadataQuery::create()
@ -1235,20 +1236,20 @@ class ApiController extends Zend_Controller_Action
} }
if ($do_insert) { if ($do_insert) {
$startDT = new DateTime("now", new DateTimeZone("UTC")); $startDT = new DateTime("now", new DateTimeZone("UTC"));
$webstream_metadata = new CcWebstreamMetadata(); $webstream_metadata = new CcWebstreamMetadata();
$webstream_metadata->setDbInstanceId($media_id); $webstream_metadata->setDbInstanceId($media_id);
$webstream_metadata->setDbStartTime($startDT); $webstream_metadata->setDbStartTime($startDT);
$webstream_metadata->setDbLiquidsoapData($data_title); $webstream_metadata->setDbLiquidsoapData($data_title);
$webstream_metadata->save(); $webstream_metadata->save();
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$historyService->insertWebstreamMetadata($media_id, $startDT, $data_arr); $historyService->insertWebstreamMetadata($media_id, $startDT, $data_arr);
} }
} }
} }
$this->view->response = $data; $this->view->response = $data;
$this->view->media_id = $media_id; $this->view->media_id = $media_id;
@ -1271,11 +1272,11 @@ class ApiController extends Zend_Controller_Action
Application_Model_ListenerStat::insertDataPoints($data); Application_Model_ListenerStat::insertDataPoints($data);
$this->view->data = $data; $this->view->data = $data;
} }
public function updateStreamSettingTableAction() { public function updateStreamSettingTableAction() {
$request = $this->getRequest(); $request = $this->getRequest();
$data = json_decode($request->getParam("data"), true); $data = json_decode($request->getParam("data"), true);
foreach ($data as $k=>$v) { foreach ($data as $k=>$v) {
Application_Model_StreamSetting::SetListenerStatError($k, $v); Application_Model_StreamSetting::SetListenerStatError($k, $v);
} }
@ -1317,9 +1318,9 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getParams(); $params = $request->getParams();
$userId = $request->getParam("user_id", null); $userId = $request->getParam("user_id", null);
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request); list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$shows = $historyService->getShowList($startsDT, $endsDT, $userId); $shows = $historyService->getShowList($startsDT, $endsDT, $userId);
@ -1343,8 +1344,8 @@ class ApiController extends Zend_Controller_Action
$params = $request->getParams(); $params = $request->getParams();
$showId = $request->getParam("show_id", null); $showId = $request->getParam("show_id", null);
$results = array(); $results = array();
if (empty($showId)) { if (empty($showId)) {
$shows = CcShowQuery::create()->find(); $shows = CcShowQuery::create()->find();
foreach($shows as $show) { foreach($shows as $show) {
$results[] = $show->getShowInfo(); $results[] = $show->getShowInfo();
@ -1361,19 +1362,19 @@ class ApiController extends Zend_Controller_Action
Logging::info($e->getMessage()); Logging::info($e->getMessage());
} }
} }
/** /**
* display show schedule for given show_id * display show schedule for given show_id
* *
* @return json array * @return json array
*/ */
public function showSchedulesAction() public function showSchedulesAction()
{ {
try { try {
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getParams(); $params = $request->getParams();
$showId = $request->getParam("show_id", null); $showId = $request->getParam("show_id", null);
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request); list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
if ((!isset($showId)) || (!is_numeric($showId))) { if ((!isset($showId)) || (!is_numeric($showId))) {
@ -1382,7 +1383,7 @@ class ApiController extends Zend_Controller_Action
array("jsonrpc" => "2.0", "error" => array("code" => 400, "message" => "missing invalid type for required show_id parameter. use type int.".$showId)) array("jsonrpc" => "2.0", "error" => array("code" => 400, "message" => "missing invalid type for required show_id parameter. use type int.".$showId))
); );
} }
$shows = Application_Model_Show::getShows($startsDT, $endsDT, FALSE, $showId); $shows = Application_Model_Show::getShows($startsDT, $endsDT, FALSE, $showId);
// is this a valid show? // is this a valid show?
@ -1400,7 +1401,7 @@ class ApiController extends Zend_Controller_Action
} }
} }
/** /**
* displays track listing for given instance_id * displays track listing for given instance_id
* *
@ -1421,7 +1422,7 @@ class ApiController extends Zend_Controller_Action
$showInstance = new Application_Model_ShowInstance($instanceId); $showInstance = new Application_Model_ShowInstance($instanceId);
$showInstanceContent = $showInstance->getShowListContent($prefTimezone); $showInstanceContent = $showInstance->getShowListContent($prefTimezone);
// is this a valid show instance with content? // is this a valid show instance with content?
if (empty($showInstanceContent)) { if (empty($showInstanceContent)) {
$this->_helper->json->sendJson( $this->_helper->json->sendJson(