Merge branch '2.5.x' into cc-5709-airtime-analyzer

Conflicts:
	airtime_mvc/locale/de_DE/LC_MESSAGES/airtime.po
	airtime_mvc/locale/es_ES/LC_MESSAGES/airtime.po
	airtime_mvc/locale/hr_HR/LC_MESSAGES/airtime.po
	airtime_mvc/locale/hu_HU/LC_MESSAGES/airtime.po
	airtime_mvc/locale/sr_RS/LC_MESSAGES/airtime.po
	airtime_mvc/locale/sr_RS@latin/LC_MESSAGES/airtime.po
This commit is contained in:
Naomi 2014-04-23 15:58:39 -04:00
commit fe20cc7f63
59 changed files with 51180 additions and 50667 deletions

View file

@ -9,6 +9,49 @@ class ListenerstatController extends Zend_Controller_Action
->addActionContext('get-data', 'json')
->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()
{
@ -26,25 +69,17 @@ class ListenerstatController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
//default time is the last 24 hours.
$now = time();
$from = $request->getParam("from", $now - (24*60*60));
$to = $request->getParam("to", $now);
$utcTimezone = new DateTimeZone("UTC");
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
list($startsDT, $endsDT) = $this->getStartEnd();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$startsDT->setTimezone($userTimezone);
$endsDT->setTimezone($userTimezone);
$form = new Application_Form_DateRange();
$form->populate(array(
'his_date_start' => $start->format("Y-m-d"),
'his_time_start' => $start->format("H:i"),
'his_date_end' => $end->format("Y-m-d"),
'his_time_end' => $end->format("H:i")
'his_date_start' => $startsDT->format("Y-m-d"),
'his_time_start' => $startsDT->format("H:i"),
'his_date_end' => $endsDT->format("Y-m-d"),
'his_time_end' => $endsDT->format("H:i")
));
$errorStatus = Application_Model_StreamSetting::GetAllListenerStatErrors();
@ -63,17 +98,8 @@ class ListenerstatController extends Zend_Controller_Action
}
public function getDataAction(){
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("startTimestamp", $current_time - (60*60*24));
$ends_epoch = $request->getParam("endTimestamp", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
list($startsDT, $endsDT) = $this->getStartEnd();
$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);
}

View file

@ -17,35 +17,68 @@ class PlayouthistoryController extends Zend_Controller_Action
->addActionContext('update-list-item', 'json')
->addActionContext('update-file-item', 'json')
->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();
$request = $this->getRequest();
$baseUrl = Application_Common_OsPath::getBaseDir();
//default time is the last 24 hours.
$now = time();
$from = $request->getParam("from", $now - (24*60*60));
$to = $request->getParam("to", $now);
$utcTimezone = new DateTimeZone("UTC");
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
list($startsDT, $endsDT) = $this->getStartEnd();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$startsDT->setTimezone($userTimezone);
$endsDT->setTimezone($userTimezone);
$form = new Application_Form_DateRange();
$form->populate(array(
'his_date_start' => $start->format("Y-m-d"),
'his_time_start' => $start->format("H:i"),
'his_date_end' => $end->format("Y-m-d"),
'his_time_end' => $end->format("H:i")
'his_date_start' => $startsDT->format("Y-m-d"),
'his_time_start' => $startsDT->format("H:i"),
'his_date_end' => $endsDT->format("Y-m-d"),
'his_time_end' => $endsDT->format("H:i")
));
$this->view->date_form = $form;
@ -87,15 +120,10 @@ class PlayouthistoryController extends Zend_Controller_Action
{
try {
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$params = $request->getParams();
$instance = $request->getParam("instance_id", null);
list($startsDT, $endsDT) = $this->getStartEnd();
$historyService = new Application_Service_HistoryService();
$r = $historyService->getFileSummaryData($startsDT, $endsDT, $params);
@ -114,18 +142,12 @@ class PlayouthistoryController extends Zend_Controller_Action
public function itemHistoryFeedAction()
{
try {
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$instance = $request->getParam("instance_id", null);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$request = $this->getRequest();
$params = $request->getParams();
$instance = $request->getParam("instance_id", null);
list($startsDT, $endsDT) = $this->getStartEnd();
$historyService = new Application_Service_HistoryService();
$r = $historyService->getPlayedItemData($startsDT, $endsDT, $params, $instance);
@ -144,12 +166,10 @@ class PlayouthistoryController extends Zend_Controller_Action
{
try {
$request = $this->getRequest();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$params = $request->getParams();
$instance = $request->getParam("instance_id", null);
list($startsDT, $endsDT) = $this->getStartEnd();
$historyService = new Application_Service_HistoryService();
$shows = $historyService->getShowList($startsDT, $endsDT);

View file

@ -230,29 +230,66 @@ class ShowbuilderController extends Zend_Controller_Action
$end_time = $end->format("Y-m-d H:i:s");
$this->view->title = "{$show_name}: {$start_time} - {$end_time}";
$this->view->start = $instance->getDbStarts("U");
$this->view->end = $instance->getDbEnds("U");
$this->view->start = $start_time;
$this->view->end = $end_time;
$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();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time);
//default ends is 24 hours after starts.
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
$request = $this->getRequest();
$show_filter = intval($request->getParam("showFilter", 0));
$my_shows = intval($request->getParam("myShows", 0));
$timestamp = intval($request->getParam("timestamp", -1));
$instances = $request->getParam("instances", array());
$my_shows = intval($request->getParam("myShows", 0));
$timestamp = intval($request->getParam("timestamp", -1));
$instances = $request->getParam("instances", array());
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
list($startsDT, $endsDT) = $this->getStartEnd();
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
//only send the schedule back if updates have been made.
@ -263,18 +300,14 @@ class ShowbuilderController extends Zend_Controller_Action
public function builderFeedAction()
{
$request = $this->getRequest();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time);
//default ends is 24 hours after starts.
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
$current_time = time();
$request = $this->getRequest();
$show_filter = intval($request->getParam("showFilter", 0));
$show_instance_filter = intval($request->getParam("showInstanceFilter", 0));
$my_shows = intval($request->getParam("myShows", 0));
$my_shows = intval($request->getParam("myShows", 0));
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
list($startsDT, $endsDT) = $this->getStartEnd();
$opts = array("myShows" => $my_shows,
"showFilter" => $show_filter,

View file

@ -641,6 +641,11 @@ class Application_Model_Preference
{
return self::getValue("logoImage");
}
public static function SetUniqueId($id)
{
self::setValue("uniqueId", $id);
}
public static function GetUniqueId()
{
@ -896,6 +901,11 @@ class Application_Model_Preference
return self::getValue("enable_stream_conf");
}
public static function SetAirtimeVersion($version)
{
self::setValue("system_version", $version);
}
public static function GetAirtimeVersion()
{

View file

@ -590,15 +590,14 @@ class Application_Model_Scheduler
* to that show
*/
if ($linked) {
$instance_sql = "SELECT * FROM cc_show_instances ".
"WHERE show_id = ".$ccShow["id"];
$instances = Application_Common_Database::prepareAndExecute(
$instance_sql);
$instances = CcShowInstancesQuery::create()
->filterByDbShowId($ccShow["id"])
->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN)
->find();
} else {
$instance_sql = "SELECT * FROM cc_show_instances ".
"WHERE id = ".$schedule["instance"];
$instances = Application_Common_Database::prepareAndExecute(
$instance_sql);
$instances = CcShowInstancesQuery::create()
->filterByDbId($schedule["instance"])
->find();
}
$excludePositions = array();
@ -606,7 +605,8 @@ class Application_Model_Scheduler
//reset
$this->applyCrossfades = true;
$instanceId = $instance["id"];
//$instanceId = $instance["id"];
$instanceId = $instance->getDbId();
if ($id !== 0) {
/* We use the selected cursor's position to find the same
* positions in every other linked instance
@ -632,7 +632,7 @@ class Application_Model_Scheduler
//show instance has no scheduled tracks
if (empty($pos)) {
$pos = 0;
$nextStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC"));
$nextStartDT = new DateTime($instance->getDbStarts(), new DateTimeZone("UTC"));
} else {
$linkedItem_sql = "SELECT ends FROM cc_schedule ".
@ -658,7 +658,7 @@ class Application_Model_Scheduler
}
//selected empty row to add after
else {
$showStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC"));
$showStartDT = new DateTime($instance->getDbStarts(), new DateTimeZone("UTC"));
$nextStartDT = $this->findNextStartTime($showStartDT, $instanceId);
//first item in show so start position counter at 0

View file

@ -47,8 +47,8 @@ class CcShow extends BaseCcShow {
*/
public function getFirstCcShowDay($criteria = null, PropelPDO $con = null)
{
CcShowPeer::clearInstancePool();
CcShowPeer::clearRelatedInstancePool();
/*CcShowPeer::clearInstancePool();
CcShowPeer::clearRelatedInstancePool();*/
if(null === $this->collCcShowDayss || null !== $criteria) {
if ($this->isNew() && null === $this->collCcShowDayss) {

View file

@ -304,24 +304,20 @@ class Application_Service_SchedulerService
private static function replaceInstanceContentCheck($currentShowStamp, $showStamp)
{
/*$currentShowStamp = CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->orderByDbStarts()
->find();*/
$counter = 0;
foreach ($showStamp as $item) {
if ($item["file_id"] != $currentShowStamp[$counter]["file_id"] ||
$item["stream_id"] != $currentShowStamp[$counter]["stream_id"]) {
/*CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->delete();*/
$delete_sql = "DELETE FROM cc_schedule ".
"WHERE instance_id = {$currentShowStamp[$counter]["instance_id"]}";
Application_Common_Database::prepareAndExecute(
$delete_sql, array(), Application_Common_Database::EXECUTE);
return true;
}
/*CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->delete();*/
$delete_sql = "DELETE FROM cc_schedule ".
"WHERE instance_id = {$currentShowStamp[$counter]["instance_id"]}";
Application_Common_Database::prepareAndExecute(
$delete_sql, array(), Application_Common_Database::EXECUTE);
return true;
}
$counter += 1;
}
/* If we get here, the content in the show instance is the same

View file

@ -20,6 +20,7 @@ class Application_Service_ShowService
private $localShowStartHour;
private $localShowStartMin;
private $origCcShowDay;
private $origShowRepeatStatus;
private $instanceIdsForScheduleUpdates;
public function __construct($showId=null, $showData=null, $isUpdate=false)
@ -158,8 +159,10 @@ class Application_Service_ShowService
{
if ($this->ccShow->isRepeating()) {
$this->origCcShowDay = clone $this->ccShow->getFirstRepeatingCcShowDay();
$this->origShowRepeatStatus = true;
} else {
$this->origCcShowDay = clone $this->ccShow->getFirstCcShowDay();
$this->origShowRepeatStatus = false;
}
$this->oldShowTimezone = $this->origCcShowDay->getDbTimezone();
@ -183,6 +186,7 @@ class Application_Service_ShowService
if (!$currentUser->isAdminOrPM()) {
throw new Exception("Permission denied");
}
//update ccShow
$this->setCcShow($showData);
@ -220,12 +224,15 @@ class Application_Service_ShowService
$this->delegateInstanceCreation($daysAdded);
if ($this->isUpdate) {
/* Set the show's start date to the start date of the first instance.
* We need to do this so we get the correct time diff for
* updating show content. CC-5696
/* If the show is repeating and the start date changes we need
* to ignore that difference when re-calculating schedule start times.
* Otherwise it might calculate a difference of a week, for example.
*/
$showData["add_show_start_date"] = $this->ccShow->getFirstCcShowDay()->getDbFirstShow();
$showData["add_show_start_time"] = $this->ccShow->getFirstCcShowDay()->getDbStartTime();
if ($this->ccShow->isRepeating() &&
$this->origCcShowDay->getLocalStartDateAndTime()->format("Y-m-d") != $showData["add_show_start_date"]) {
$showData["add_show_start_date"] = $this->origCcShowDay->getLocalStartDateAndTime()->format("Y-m-d");
}
$this->adjustSchedule($showData);
}
@ -411,6 +418,13 @@ SQL;
':timestamp' => gmdate("Y-m-d H:i:s")), 'execute');
}
private function deleteAllShowDays($showId)
{
CcShowDaysQuery::create()
->filterByDbShowId($showId)
->delete();
}
/**
* TODO: This function is messy. Needs refactoring
*
@ -432,8 +446,14 @@ SQL;
//CcShowDay object
if ($this->ccShow->isRepeating()) {
$currentShowDay = $this->ccShow->getFirstRepeatingCcShowDay();
//all cc_show_days
$ccShowDays = $this->ccShow->getRepeatingCcShowDays();
} else {
$currentShowDay = $this->ccShow->getFirstCcShowDay();
//all cc_show_days
$ccShowDays = $this->ccShow->getCcShowDayss();
}
//new end date in the show's timezone (from the select box)
@ -442,6 +462,11 @@ SQL;
//repeat option was toggled
if ($showData['add_show_repeats'] != $currentShowDay->isRepeating()) {
$this->deleteAllRepeatInstances($currentShowDay, $showId);
if (!$showData["add_show_repeats"]) {
$this->deleteAllShowDays($showId);
}
//if repeat option was checked we need to treat the current show day
//as a new show day so the repeat instances get created properly
//in createWeeklyRepeatInstances()
@ -473,17 +498,13 @@ SQL;
//and the repeat type changed
if ($currentRepeatType != -1 && $this->repeatType != $currentRepeatType) {
$this->deleteAllInstances($showId);
$this->deleteAllShowDays($showId);
// when repeating by day of the month (1st, 2nd, etc.) we do not store the repeat week days
} elseif ($currentRepeatType != 2) {
//repeat type is the same, check if the days of the week are the same
$repeatingDaysChanged = false;
if ($this->ccShow->isRepeating()) {
$ccShowDays = $this->ccShow->getRepeatingCcShowDays();
} else {
$ccShowDays = $this->ccShow->getCcShowDayss();
}
$showDays = array();
foreach ($ccShowDays as $day) {
$showDays[] = $day->getDbDay();
@ -534,12 +555,11 @@ SQL;
//check if this is null if "no end"
$currentShowEndDateTime = $this->getRepeatingEndDate();
if ($currentShowEndDateTime != $endDateTime) {
if ($endDateTime && $currentShowEndDateTime != $endDateTime) {
$endDate = clone $endDateTime;
$endDate->setTimezone(new DateTimeZone("UTC"));
//show "No End" option was toggled
//show's "No End" option was toggled
//or the end date comes earlier
if (is_null($currentShowEndDateTime) || ($endDateTime < $currentShowEndDateTime)) {
//"No End" option was unchecked so we need to delete the
@ -557,11 +577,14 @@ SQL;
private function preserveLinkedShowContent()
{
/* Get show content from any linekd instance. It doesn't
/* Get show content from any linked instance. It doesn't
* matter which instance since content is the same in all.
*/
$ccShowInstance = $this->ccShow->getCcShowInstancess()->getFirst();
if (!$ccShowInstance) {
return;
}
$ccSchedules = CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->find();
@ -1509,8 +1532,12 @@ SQL;
if ($this->isUpdate) {
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($showId)
->filterByDbRepeatType($showData['add_show_repeat_type'])
->filterByDbRepeatType($this->origCcShowDay->getDbRepeatType())
->findOne();
if (!$showDay) {
//repeat type changed so we have to create a new show_day rule
$showDay = new CcShowDays();
}
} else {
$showDay = new CcShowDays();
}
@ -1542,16 +1569,30 @@ SQL;
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
if ($this->isUpdate) {
if ($this->origCcShowDay->getDbRepeatType() == 2 ||
$this->origCcShowDay->getDbRepeatType() == 3) {
$day = null;
} else if (!$this->origShowRepeatStatus) {
//keep current show day to use for updating cc_show_day rule
$keepDay = $day;
$day = $this->origCcShowDay->getDbDay();
}
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($showId)
->filterByDbRepeatType($this->repeatType)
->filterByDbRepeatType($this->origCcShowDay->getDbRepeatType())
->filterByDbDay($day)
->findOne();
if (!$showDay) {
//if no show day object was found it is because a new
//repeating day of the week was added
//repeating day of the week was added OR the repeat
//type has changed
$showDay = new CcShowDays();
}
if (isset($keepDay)) {
$day = $keepDay;
}
} else {
$showDay = new CcShowDays();
}