Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
James 2011-08-18 15:59:39 -04:00
commit 8c2e622552
6 changed files with 57 additions and 20 deletions

View File

@ -9,6 +9,7 @@ class ApiController extends Zend_Controller_Action
$context = $this->_helper->getHelper('contextSwitch');
$context->addActionContext('version', 'json')
->addActionContext('recorded-shows', 'json')
->addActionContext('server-timestamp', 'json')
->addActionContext('upload-file', 'json')
->addActionContext('upload-recorded', 'json')
->addActionContext('media-monitor-setup', 'json')
@ -57,6 +58,12 @@ class ApiController extends Zend_Controller_Action
echo $jsonStr;
}
public function serverTimestampAction(){
$this->view->serverTimestamp = array("timestamp"=>time(), "timezoneOffset"=> date("Z"));
}
/**
* Allows remote client to download requested media file.
*

View File

@ -61,10 +61,23 @@ function makeTimeStamp(date){
return timestamp;
}
function adjustDateToServerDate(date, serverTimezoneOffset){
//date object stores time in the browser's localtime. We need to artificially shift
//it to
var timezoneOffset = date.getTimezoneOffset()*60*1000;
date.setTime(date.getTime() + timezoneOffset + serverTimezoneOffset*1000);
/* date object has been shifted to artificial UTC time. Now let's
* shift it to the server's timezone */
return date;
}
function dayClick(date, allDay, jsEvent, view) {
var now, today, selected, chosenDate, chosenTime;
now = new Date();
now = adjustDateToServerDate(new Date(), serverTimezoneOffset);
if(view.name === "month") {
today = new Date(now.getFullYear(), now.getMonth(), now.getDate());

View File

@ -4,6 +4,8 @@
*
*/
var serverTimezoneOffset = 0;
function closeDialog(event, ui) {
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
$(this).remove();
@ -292,7 +294,10 @@ function buildEditDialog(json){
}
$(window).load(function() {
function createFullCalendar(data){
serverTimezoneOffset = data.serverTimestamp.timezoneOffset;
var mainHeight = document.documentElement.clientHeight - 200 - 50;
$('#schedule_calendar').fullCalendar({
@ -312,6 +317,8 @@ $(window).load(function() {
contentHeight: mainHeight,
theme: true,
lazyFetching: false,
serverTimestamp: parseInt(data.serverTimestamp.timestamp, 10),
serverTimezoneOffset: parseInt(data.serverTimestamp.timezoneOffset, 10),
events: getFullCalendarEvents,
@ -324,5 +331,11 @@ $(window).load(function() {
eventResize: eventResize
});
}
$(window).load(function() {
$.ajax({ url: "/Api/server-timestamp/format/json", dataType:"json", success:createFullCalendar
, error:function(jqXHR, textStatus, errorThrown){}});
});

View File

@ -2275,7 +2275,7 @@ function BasicView(element, calendar, viewName) {
function updateCells(firstTime) {
var dowDirty = firstTime || rowCnt == 1; // could the cells' day-of-weeks need updating?
var month = t.start.getMonth();
var today = clearTime(new Date());
var today = clearTime(adjustDateToServerDate(new Date(), opt("serverTimezoneOffset")));
var cell;
var date;
var row;

View File

@ -298,7 +298,9 @@ class AirtimeInstall
{
global $CC_DBC;
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', 'America/Toronto')";
$defaultTimezone = date_default_timezone_get();
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
return false;

View File

@ -21,7 +21,9 @@ class AirtimeInstall{
{
global $CC_DBC;
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', 'America/Toronto')";
$defaultTimezone = date_default_timezone_get();
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
return false;