added shows, show-schedules, show-preview, show-history-feed, item-history-feed endpoints to the HTTP api to be used via NewscoopAirtimePlugin

This commit is contained in:
Mark Lewis 2014-11-17 21:53:31 +01:00 committed by Albert Santoni
parent 05c9e21e48
commit 44b4faf6d9
4 changed files with 307 additions and 48 deletions

View file

@ -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.=
@ -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;
}
}
}
}