Merge branch 'saas-pullreq77' into saas
This commit is contained in:
commit
3247f6992a
|
@ -12,6 +12,7 @@ require_once 'Preference.php';
|
|||
require_once 'Locale.php';
|
||||
require_once "DateHelper.php";
|
||||
require_once "LocaleHelper.php";
|
||||
require_once "HTTPHelper.php";
|
||||
require_once "OsPath.php";
|
||||
require_once "Database.php";
|
||||
require_once "Timezone.php";
|
||||
|
|
|
@ -443,5 +443,59 @@ class Application_Common_DateHelper
|
|||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns date fields from give start and end teimstamp strings
|
||||
* if no start or end parameter is passed start will be set to 1
|
||||
* in the past and end to now
|
||||
*
|
||||
* @param string startTimestamp Y-m-d H:i:s
|
||||
* @param string endTImestamp Y-m-d H:i:s
|
||||
* @param string timezone (ex UTC) of the start and end parameters
|
||||
* @return array (start DateTime, end DateTime) in UTC timezone
|
||||
*/
|
||||
public static function getStartEnd($startTimestamp, $endTimestamp, $timezone)
|
||||
{
|
||||
$prefTimezone = Application_Model_Preference::GetTimezone();
|
||||
$utcTimezone = new DateTimeZone("UTC");
|
||||
$utcNow = new DateTime("now", $utcTimezone);
|
||||
|
||||
if (empty($timezone)) {
|
||||
$userTimezone = new DateTimeZone($prefTimezone);
|
||||
} else {
|
||||
$userTimezone = new DateTimeZone($timezone);
|
||||
}
|
||||
|
||||
// default to 1 day
|
||||
if (empty($startTimestamp) || empty($endTimestamp)) {
|
||||
$startsDT = clone $utcNow;
|
||||
$startsDT->sub(new DateInterval("P1D"));
|
||||
$endsDT = clone $utcNow;
|
||||
} else {
|
||||
|
||||
try {
|
||||
$startsDT = new DateTime($startTimestamp, $userTimezone);
|
||||
$startsDT->setTimezone($utcTimezone);
|
||||
|
||||
$endsDT = new DateTime($endTimestamp, $userTimezone);
|
||||
$endsDT->setTimezone($utcTimezone);
|
||||
|
||||
if ($startsDT > $endsDT) {
|
||||
throw new Exception("start greater than end");
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
Logging::info($e->getMessage());
|
||||
|
||||
$startsDT = clone $utcNow;
|
||||
$startsDT->sub(new DateInterval("P1D"));
|
||||
$endsDT = clone $utcNow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return array($startsDT, $endsDT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
class Application_Common_HTTPHelper
|
||||
{
|
||||
/**
|
||||
* Returns start and end DateTime vars from given
|
||||
* HTTP Request object
|
||||
*
|
||||
* @param Request
|
||||
* @return array(start DateTime, end DateTime)
|
||||
*/
|
||||
public static function getStartEndFromRequest($request)
|
||||
{
|
||||
return Application_Common_DateHelper::getStartEnd(
|
||||
$request->getParam("start", null),
|
||||
$request->getParam("end", null),
|
||||
$request->getParam("timezone", null)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -5,8 +5,19 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
public function init()
|
||||
{
|
||||
$ignoreAuth = array("live-info", "live-info-v2", "week-info",
|
||||
"station-metadata", "station-logo", "show-logo");
|
||||
$ignoreAuth = array("live-info",
|
||||
"live-info-v2",
|
||||
"week-info",
|
||||
"station-metadata",
|
||||
"station-logo",
|
||||
"show-history-feed",
|
||||
"item-history-feed",
|
||||
"shows",
|
||||
"show-tracks",
|
||||
"show-schedules",
|
||||
"station-logo",
|
||||
"show-logo"
|
||||
);
|
||||
|
||||
$params = $this->getRequest()->getParams();
|
||||
if (!in_array($params['action'], $ignoreAuth)) {
|
||||
|
@ -274,10 +285,10 @@ class ApiController extends Zend_Controller_Action
|
|||
$utcTimeEnd = $end->format("Y-m-d H:i:s");
|
||||
|
||||
$result = array(
|
||||
"env" => APPLICATION_ENV,
|
||||
"schedulerTime" => $utcTimeNow,
|
||||
"currentShow" => Application_Model_Show::getCurrentShow($utcTimeNow),
|
||||
"nextShow" => Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd)
|
||||
"env" => APPLICATION_ENV,
|
||||
"schedulerTime" => $utcTimeNow,
|
||||
"currentShow" => Application_Model_Show::getCurrentShow($utcTimeNow),
|
||||
"nextShow" => Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd)
|
||||
);
|
||||
} else {
|
||||
$result = Application_Model_Schedule::GetPlayOrderRangeOld($limit);
|
||||
|
@ -487,9 +498,9 @@ class ApiController extends Zend_Controller_Action
|
|||
$shows,
|
||||
array("starts", "ends", "start_timestamp","end_timestamp"),
|
||||
$timezone
|
||||
);
|
||||
);
|
||||
|
||||
$result[$dow[$i]] = $shows;
|
||||
$result[$dow[$i]] = $shows;
|
||||
}
|
||||
|
||||
// XSS exploit prevention
|
||||
|
@ -1420,4 +1431,175 @@ class ApiController extends Zend_Controller_Action
|
|||
Application_Model_StreamSetting::SetListenerStatError($k, $v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* display played items for a given time range and show instance_id
|
||||
*
|
||||
* @return json array
|
||||
*/
|
||||
public function itemHistoryFeedAction()
|
||||
{
|
||||
try {
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getParams();
|
||||
$instance = $request->getParam("instance_id", null);
|
||||
|
||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$results = $historyService->getPlayedItemData($startsDT, $endsDT, $params, $instance);
|
||||
|
||||
$this->_helper->json->sendJson($results['history']);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
Logging::info($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* display show schedules for a given time range and show instance_id
|
||||
*
|
||||
* @return json array
|
||||
*/
|
||||
public function showHistoryFeedAction()
|
||||
{
|
||||
try {
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getParams();
|
||||
$userId = $request->getParam("user_id", null);
|
||||
|
||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$shows = $historyService->getShowList($startsDT, $endsDT, $userId);
|
||||
|
||||
$this->_helper->json->sendJson($shows);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
Logging::info($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* display show info (without schedule) for given show_id
|
||||
*
|
||||
* @return json array
|
||||
*/
|
||||
public function showsAction()
|
||||
{
|
||||
try {
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getParams();
|
||||
$showId = $request->getParam("show_id", null);
|
||||
$results = array();
|
||||
|
||||
if (empty($showId)) {
|
||||
$shows = CcShowQuery::create()->find();
|
||||
foreach($shows as $show) {
|
||||
$results[] = $show->getShowInfo();
|
||||
}
|
||||
} else {
|
||||
$show = CcShowQuery::create()->findPK($showId);
|
||||
$results[] = $show->getShowInfo();
|
||||
}
|
||||
|
||||
$this->_helper->json->sendJson($results);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
Logging::info($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* display show schedule for given show_id
|
||||
*
|
||||
* @return json array
|
||||
*/
|
||||
public function showSchedulesAction()
|
||||
{
|
||||
try {
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getParams();
|
||||
$showId = $request->getParam("show_id", null);
|
||||
|
||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
|
||||
|
||||
if ((!isset($showId)) || (!is_numeric($showId))) {
|
||||
//if (!isset($showId)) {
|
||||
$this->_helper->json->sendJson(
|
||||
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);
|
||||
|
||||
// is this a valid show?
|
||||
if (empty($shows)) {
|
||||
$this->_helper->json->sendJson(
|
||||
array("jsonrpc" => "2.0", "error" => array("code" => 204, "message" => "no content for requested show_id"))
|
||||
);
|
||||
}
|
||||
|
||||
$this->_helper->json->sendJson($shows);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
Logging::info($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* displays track listing for given instance_id
|
||||
*
|
||||
* @return json array
|
||||
*/
|
||||
public function showTracksAction()
|
||||
{
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
$prefTimezone = Application_Model_Preference::GetTimezone();
|
||||
|
||||
$instanceId = $this->_getParam('instance_id');
|
||||
|
||||
if ((!isset($instanceId)) || (!is_numeric($instanceId))) {
|
||||
$this->_helper->json->sendJson(
|
||||
array("jsonrpc" => "2.0", "error" => array("code" => 400, "message" => "missing invalid type for required instance_id parameter. use type int"))
|
||||
);
|
||||
}
|
||||
|
||||
$showInstance = new Application_Model_ShowInstance($instanceId);
|
||||
$showInstanceContent = $showInstance->getShowListContent($prefTimezone);
|
||||
|
||||
// is this a valid show instance with content?
|
||||
if (empty($showInstanceContent)) {
|
||||
$this->_helper->json->sendJson(
|
||||
array("jsonrpc" => "2.0", "error" => array("code" => 204, "message" => "no content for requested instance_id"))
|
||||
);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$position = 0;
|
||||
foreach ($showInstanceContent as $track) {
|
||||
|
||||
$elementMap = array(
|
||||
'title' => isset($track['track_title']) ? $track['track_title'] : "",
|
||||
'artist' => isset($track['creator']) ? $track['creator'] : "",
|
||||
'position' => $position,
|
||||
'id' => ++$position,
|
||||
'mime' => isset($track['mime'])?$track['mime']:"",
|
||||
'starts' => isset($track['starts']) ? $track['starts'] : "",
|
||||
'length' => isset($track['length']) ? $track['length'] : "",
|
||||
'file_id' => ($track['type'] == 0) ? $track['item_id'] : $track['filepath']
|
||||
);
|
||||
|
||||
$result[] = $elementMap;
|
||||
}
|
||||
|
||||
$this->_helper->json($result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,49 +10,6 @@ class ListenerstatController extends Zend_Controller_Action
|
|||
->initContext();
|
||||
}
|
||||
|
||||
private function getStartEnd()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
|
||||
$utcTimezone = new DateTimeZone("UTC");
|
||||
$utcNow = new DateTime("now", $utcTimezone);
|
||||
|
||||
$start = $request->getParam("start");
|
||||
$end = $request->getParam("end");
|
||||
|
||||
if (empty($start) || empty($end)) {
|
||||
$startsDT = clone $utcNow;
|
||||
$startsDT->sub(new DateInterval("P1D"));
|
||||
$endsDT = clone $utcNow;
|
||||
}
|
||||
else {
|
||||
|
||||
try {
|
||||
$startsDT = new DateTime($start, $userTimezone);
|
||||
$startsDT->setTimezone($utcTimezone);
|
||||
|
||||
$endsDT = new DateTime($end, $userTimezone);
|
||||
$endsDT->setTimezone($utcTimezone);
|
||||
|
||||
if ($startsDT > $endsDT) {
|
||||
throw new Exception("start greater than end");
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
Logging::info($e->getMessage());
|
||||
|
||||
$startsDT = clone $utcNow;
|
||||
$startsDT->sub(new DateInterval("P1D"));
|
||||
$endsDT = clone $utcNow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return array($startsDT, $endsDT);
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
|
@ -69,7 +26,7 @@ class ListenerstatController extends Zend_Controller_Action
|
|||
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
|
||||
|
||||
list($startsDT, $endsDT) = $this->getStartEnd();
|
||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
|
||||
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
|
||||
$startsDT->setTimezone($userTimezone);
|
||||
$endsDT->setTimezone($userTimezone);
|
||||
|
@ -98,7 +55,7 @@ class ListenerstatController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
public function getDataAction(){
|
||||
list($startsDT, $endsDT) = $this->getStartEnd();
|
||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest());
|
||||
|
||||
$data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format("Y-m-d H:i:s"), $endsDT->format("Y-m-d H:i:s"));
|
||||
$this->_helper->json->sendJson($data);
|
||||
|
|
|
@ -19,56 +19,13 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
->initContext();
|
||||
}
|
||||
|
||||
private function getStartEnd()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
|
||||
$utcTimezone = new DateTimeZone("UTC");
|
||||
$utcNow = new DateTime("now", $utcTimezone);
|
||||
|
||||
$start = $request->getParam("start");
|
||||
$end = $request->getParam("end");
|
||||
|
||||
if (empty($start) || empty($end)) {
|
||||
$startsDT = clone $utcNow;
|
||||
$startsDT->sub(new DateInterval("P1D"));
|
||||
$endsDT = clone $utcNow;
|
||||
}
|
||||
else {
|
||||
|
||||
try {
|
||||
$startsDT = new DateTime($start, $userTimezone);
|
||||
$startsDT->setTimezone($utcTimezone);
|
||||
|
||||
$endsDT = new DateTime($end, $userTimezone);
|
||||
$endsDT->setTimezone($utcTimezone);
|
||||
|
||||
if ($startsDT > $endsDT) {
|
||||
throw new Exception("start greater than end");
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
Logging::info($e->getMessage());
|
||||
|
||||
$startsDT = clone $utcNow;
|
||||
$startsDT->sub(new DateInterval("P1D"));
|
||||
$endsDT = clone $utcNow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return array($startsDT, $endsDT);
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
|
||||
list($startsDT, $endsDT) = $this->getStartEnd();
|
||||
|
||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest());
|
||||
|
||||
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
|
||||
$startsDT->setTimezone($userTimezone);
|
||||
$endsDT->setTimezone($userTimezone);
|
||||
|
@ -123,7 +80,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
$params = $request->getParams();
|
||||
$instance = $request->getParam("instance_id", null);
|
||||
|
||||
list($startsDT, $endsDT) = $this->getStartEnd();
|
||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$r = $historyService->getFileSummaryData($startsDT, $endsDT, $params);
|
||||
|
@ -146,7 +103,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
$params = $request->getParams();
|
||||
$instance = $request->getParam("instance_id", null);
|
||||
|
||||
list($startsDT, $endsDT) = $this->getStartEnd();
|
||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$r = $historyService->getPlayedItemData($startsDT, $endsDT, $params, $instance);
|
||||
|
@ -169,7 +126,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
$params = $request->getParams();
|
||||
$instance = $request->getParam("instance_id", null);
|
||||
|
||||
list($startsDT, $endsDT) = $this->getStartEnd();
|
||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$shows = $historyService->getShowList($startsDT, $endsDT);
|
||||
|
|
|
@ -244,49 +244,6 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
$this->view->dialog = $this->view->render('showbuilder/builderDialog.phtml');
|
||||
}
|
||||
|
||||
private function getStartEnd()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
|
||||
$utcTimezone = new DateTimeZone("UTC");
|
||||
$utcNow = new DateTime("now", $utcTimezone);
|
||||
|
||||
$start = $request->getParam("start");
|
||||
$end = $request->getParam("end");
|
||||
|
||||
if (empty($start) || empty($end)) {
|
||||
$startsDT = clone $utcNow;
|
||||
$startsDT->sub(new DateInterval("P1D"));
|
||||
$endsDT = clone $utcNow;
|
||||
}
|
||||
else {
|
||||
|
||||
try {
|
||||
$startsDT = new DateTime($start, $userTimezone);
|
||||
$startsDT->setTimezone($utcTimezone);
|
||||
|
||||
$endsDT = new DateTime($end, $userTimezone);
|
||||
$endsDT->setTimezone($utcTimezone);
|
||||
|
||||
if ($startsDT > $endsDT) {
|
||||
throw new Exception("start greater than end");
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
Logging::info($e->getMessage());
|
||||
|
||||
$startsDT = clone $utcNow;
|
||||
$startsDT->sub(new DateInterval("P1D"));
|
||||
$endsDT = clone $utcNow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return array($startsDT, $endsDT);
|
||||
}
|
||||
|
||||
public function checkBuilderFeedAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
@ -295,7 +252,7 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
$timestamp = intval($request->getParam("timestamp", -1));
|
||||
$instances = $request->getParam("instances", array());
|
||||
|
||||
list($startsDT, $endsDT) = $this->getStartEnd();
|
||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
|
||||
|
||||
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
|
||||
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
|
||||
|
@ -315,7 +272,7 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
$show_instance_filter = intval($request->getParam("showInstanceFilter", 0));
|
||||
$my_shows = intval($request->getParam("myShows", 0));
|
||||
|
||||
list($startsDT, $endsDT) = $this->getStartEnd();
|
||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
|
||||
|
||||
$opts = array("myShows" => $my_shows,
|
||||
"showFilter" => $show_filter,
|
||||
|
|
|
@ -862,9 +862,11 @@ SQL;
|
|||
* In UTC time.
|
||||
* @param unknown_type $excludeInstance
|
||||
* @param boolean $onlyRecord
|
||||
* @param int $showId
|
||||
* limits the results to instances of a given showId only
|
||||
* @return array
|
||||
*/
|
||||
public static function getShows($start_timestamp, $end_timestamp, $onlyRecord=FALSE)
|
||||
public static function getShows($start_timestamp, $end_timestamp, $onlyRecord=FALSE, $showId=null)
|
||||
{
|
||||
self::createAndFillShowInstancesPastPopulatedUntilDate($end_timestamp);
|
||||
|
||||
|
@ -898,13 +900,21 @@ SQL;
|
|||
//only want shows that are starting at the time or later.
|
||||
$start_string = $start_timestamp->format("Y-m-d H:i:s");
|
||||
$end_string = $end_timestamp->format("Y-m-d H:i:s");
|
||||
|
||||
$params = array();
|
||||
|
||||
if ($showId) {
|
||||
$sql .= " AND (si1.show_id = :show_id)";
|
||||
$params[':show_id'] = $showId;
|
||||
}
|
||||
|
||||
if ($onlyRecord) {
|
||||
$sql .= " AND (si1.starts >= :start::TIMESTAMP AND si1.starts < :end::TIMESTAMP)";
|
||||
$sql .= " AND (si1.record = 1)";
|
||||
|
||||
return Application_Common_Database::prepareAndExecute( $sql,
|
||||
array( ':start' => $start_string,
|
||||
':end' => $end_string ), 'all');
|
||||
$params[':start'] = $start_string;
|
||||
$params[':end'] = $end_string;
|
||||
return Application_Common_Database::prepareAndExecute( $sql, $params, 'all');
|
||||
|
||||
} else {
|
||||
$sql .= " ". <<<SQL
|
||||
|
@ -913,15 +923,16 @@ AND ((si1.starts >= :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.
|
||||
|
@ -1457,4 +1468,5 @@ SQL;
|
|||
|
||||
return array($start, $end);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue