Merge branch '2.5.x' of github.com:sourcefabric/Airtime into 2.5.x
This commit is contained in:
commit
3a50f7a6dc
5 changed files with 52 additions and 40 deletions
|
@ -45,6 +45,22 @@ class Application_Common_DateHelper
|
||||||
return gmdate("H:i:s", $this->_dateTime);
|
return gmdate("H:i:s", $this->_dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getUserTimezoneOffset()
|
||||||
|
{
|
||||||
|
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
|
||||||
|
$now = new DateTime("now", $userTimezone);
|
||||||
|
|
||||||
|
return $now->format("Z");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getStationTimezoneOffset()
|
||||||
|
{
|
||||||
|
$stationTimezone = new DateTimeZone(Application_Model_Preference::GetDefaultTimezone());
|
||||||
|
$now = new DateTime("now", $stationTimezone);
|
||||||
|
|
||||||
|
return $now->format("Z");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return DateTime - YYYY-MM-DD 00:00 in station timezone of today
|
* @return DateTime - YYYY-MM-DD 00:00 in station timezone of today
|
||||||
|
@ -374,6 +390,21 @@ class Application_Common_DateHelper
|
||||||
return $d->format($format);
|
return $d->format($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @param $datetime string Y-m-d H:i:s in user timezone
|
||||||
|
*
|
||||||
|
* @return string Y-m-d H:i:s in UTC timezone
|
||||||
|
*/
|
||||||
|
public static function UserTimezoneStringToUTCString($datetime, $format="Y-m-d H:i:s") {
|
||||||
|
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
|
||||||
|
$utcTimezone = new DateTimeZone("UTC");
|
||||||
|
|
||||||
|
$d = new DateTime($datetime, $userTimezone);
|
||||||
|
$d->setTimezone($utcTimezone);
|
||||||
|
|
||||||
|
return $d->format($format);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the columns given in the array $columnsToConvert in the
|
* Convert the columns given in the array $columnsToConvert in the
|
||||||
* database result $rows to local timezone.
|
* database result $rows to local timezone.
|
||||||
|
|
|
@ -68,33 +68,6 @@ class ApiController extends Zend_Controller_Action
|
||||||
"version" => Application_Model_Preference::GetAirtimeVersion()));
|
"version" => Application_Model_Preference::GetAirtimeVersion()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up and send init values used in the Calendar.
|
|
||||||
* This is only being used by schedule.js at the moment.
|
|
||||||
*/
|
|
||||||
public function calendarInitAction()
|
|
||||||
{
|
|
||||||
if (is_null(Zend_Auth::getInstance()->getStorage()->read())) {
|
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
|
||||||
print _('You are not allowed to access this resource.');
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tz = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
|
|
||||||
$now = new DateTime("now", $tz);
|
|
||||||
|
|
||||||
$this->view->calendarInit = array(
|
|
||||||
"timestamp" => time(),
|
|
||||||
"timezoneOffset" => $now->format("Z"),
|
|
||||||
"timeScale" => Application_Model_Preference::GetCalendarTimeScale(),
|
|
||||||
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
|
|
||||||
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->_helper->json->sendJson(array());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows remote client to download requested media file.
|
* Allows remote client to download requested media file.
|
||||||
*
|
*
|
||||||
|
|
|
@ -51,7 +51,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
"var calendarPref = {};\n".
|
"var calendarPref = {};\n".
|
||||||
"calendarPref.weekStart = ".Application_Model_Preference::GetWeekStartDay().";\n".
|
"calendarPref.weekStart = ".Application_Model_Preference::GetWeekStartDay().";\n".
|
||||||
"calendarPref.timestamp = ".time().";\n".
|
"calendarPref.timestamp = ".time().";\n".
|
||||||
"calendarPref.timezoneOffset = ".date("Z").";\n".
|
"calendarPref.timezoneOffset = ".Application_Common_DateHelper::getUserTimezoneOffset().";\n".
|
||||||
"calendarPref.timeScale = '".Application_Model_Preference::GetCalendarTimeScale()."';\n".
|
"calendarPref.timeScale = '".Application_Model_Preference::GetCalendarTimeScale()."';\n".
|
||||||
"calendarPref.timeInterval = ".Application_Model_Preference::GetCalendarTimeInterval().";\n".
|
"calendarPref.timeInterval = ".Application_Model_Preference::GetCalendarTimeInterval().";\n".
|
||||||
"calendarPref.weekStartDay = ".Application_Model_Preference::GetWeekStartDay().";\n".
|
"calendarPref.weekStartDay = ".Application_Model_Preference::GetWeekStartDay().";\n".
|
||||||
|
@ -61,7 +61,8 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
|
||||||
//full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time
|
//full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time
|
||||||
$this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds");
|
//this should be as a default, however with our new drop down timezone changing for shows, we should reset this offset then??
|
||||||
|
$this->view->headScript()->appendScript("var timezoneOffset = ".Application_Common_DateHelper::getStationTimezoneOffset()."; //in seconds");
|
||||||
//set offset to ensure it loads last
|
//set offset to ensure it loads last
|
||||||
$this->view->headScript()->offsetSetFile(90, $baseUrl.'js/airtime/schedule/full-calendar-functions.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$this->view->headScript()->offsetSetFile(90, $baseUrl.'js/airtime/schedule/full-calendar-functions.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
||||||
|
|
||||||
public function isValid($formData) {
|
public function isValid($formData) {
|
||||||
if (parent::isValid($formData)) {
|
if (parent::isValid($formData)) {
|
||||||
return $this->checkReliantFields($formData);
|
return $this->checkReliantFields($formData);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -95,15 +95,18 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
||||||
if (!$formData['add_show_no_end']) {
|
if (!$formData['add_show_no_end']) {
|
||||||
$start_timestamp = $formData['add_show_start_date'];
|
$start_timestamp = $formData['add_show_start_date'];
|
||||||
$end_timestamp = $formData['add_show_end_date'];
|
$end_timestamp = $formData['add_show_end_date'];
|
||||||
|
$showTimeZone = new DateTimeZone($formData['add_show_timezone']);
|
||||||
|
|
||||||
$start_epoch = strtotime($start_timestamp);
|
//We're assuming all data is valid at this point (timezone, etc.).
|
||||||
$end_epoch = strtotime($end_timestamp);
|
|
||||||
|
|
||||||
if ($end_epoch < $start_epoch) {
|
$startDate = new DateTime($start_timestamp, $showTimeZone);
|
||||||
|
$endDate = new DateTime($end_timestamp, $showTimeZone);
|
||||||
|
|
||||||
|
if ($endDate < $startDate) {
|
||||||
$this->getElement('add_show_end_date')->setErrors(array(_('End date must be after start date')));
|
$this->getElement('add_show_end_date')->setErrors(array(_('End date must be after start date')));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($formData['add_show_day_check'])) {
|
if (!isset($formData['add_show_day_check'])) {
|
||||||
|
|
|
@ -11,9 +11,11 @@ class Application_Model_Datatables
|
||||||
$isRange = false;
|
$isRange = false;
|
||||||
if (strstr($term, '~')) {
|
if (strstr($term, '~')) {
|
||||||
$info = explode('~', $term);
|
$info = explode('~', $term);
|
||||||
if ($dbname == 'utime' || $dbname == 'mtime') {
|
if ($dbname == 'utime' || $dbname == 'mtime' || $dbname == 'lptime') {
|
||||||
$input1 = isset($info[0])?Application_Common_DateHelper::ConvertToUtcDateTimeString($info[0]):null;
|
|
||||||
$input2 = isset($info[1])?Application_Common_DateHelper::ConvertToUtcDateTimeString($info[1]):null;
|
$input1 = ($info[0] != "") ? Application_Common_DateHelper::UserTimezoneStringToUTCString($info[0]) : null;
|
||||||
|
$input2 = ($info[1] != "") ? Application_Common_DateHelper::UserTimezoneStringToUTCString($info[1]) : null;
|
||||||
|
|
||||||
} else if($dbname == 'bit_rate' || $dbname == 'sample_rate') {
|
} else if($dbname == 'bit_rate' || $dbname == 'sample_rate') {
|
||||||
$input1 = isset($info[0])?doubleval($info[0]) * 1000:null;
|
$input1 = isset($info[0])?doubleval($info[0]) * 1000:null;
|
||||||
$input2 = isset($info[1])?doubleval($info[1]) * 1000:null;
|
$input2 = isset($info[1])?doubleval($info[1]) * 1000:null;
|
||||||
|
@ -50,6 +52,8 @@ class Application_Model_Datatables
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logging::info($where);
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue