Should fix bug in agenda when dealing with datetimes with timezones see #4863

skala
Julio Montoya 13 years ago
parent b414d334ff
commit 24230de452
  1. 32
      main/calendar/agenda.lib.php
  2. 20
      main/template/default/agenda/month.tpl

@ -9,7 +9,6 @@ class Agenda {
var $events = array();
var $type = 'personal'; // personal, admin or course
function __construct() {
//Table definitions
$this->tbl_global_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
@ -41,9 +40,9 @@ class Agenda {
*
* Adds an event to the calendar
*
* @param int start tms
* @param int end tms
* @param string all day (true, false)
* @param string start datetime format: 2012-06-14 09:00:00
* @param string end datetime format: 2012-06-14 09:00:00
* @param string all day (true, false)
* @param string view agendaDay, agendaWeek, month @todo seems not to be used
* @param string title
* @param string content
@ -52,11 +51,8 @@ class Agenda {
*
*/
function add_event($start, $end, $all_day, $view, $title, $content, $users_to_send = array(), $add_as_announcement = false) {
$start = date('Y-m-d H:i:s', $start);
$end = date('Y-m-d H:i:s', $end);
$start = api_get_utc_datetime($start);
$end = api_get_utc_datetime($end);
$end = api_get_utc_datetime($end);
$all_day = isset($all_day) && $all_day == 'true' ? 1:0;
$attributes = array();
@ -197,12 +193,21 @@ class Agenda {
return -1;
}
/**
* Edits an event
*
* @param int event id
* @param string start datetime format: 2012-06-14 09:00:00
* @param string end datetime format: 2012-06-14 09:00:00
* @param int event is all day? 1|0
* @param string view
* @param string event title
* @param string event content
*/
function edit_event($id, $start, $end, $all_day, $view, $title, $content) {
$start = date('Y-m-d H:i:s', $start);
$start = api_get_utc_datetime($start);
if ($all_day == '0') {
$end = date('Y-m-d H:i:s', $end);
$end = api_get_utc_datetime($end);
}
$all_day = isset($all_day) && $all_day == '1' ? 1:0;
@ -692,9 +697,12 @@ class Agenda {
return $my_events;
}
//Format needed for the Fullcalendar js lib
/**
* Format needed for the Fullcalendar js lib
* @param string UTC time
*/
function format_event_date($utc_time) {
return date('c', api_strtotime(api_get_local_time($utc_time)));
return date('c', api_strtotime(api_get_local_time($utc_time)));
}

@ -125,9 +125,9 @@ $(document).ready(function() {
},
//add event
select: function(start, end, allDay, jsEvent, view) {
/* When selecting one day or several days */
var start_date = Math.round(start.getTime() / 1000);
var end_date = Math.round(end.getTime() / 1000);
//Removing UTC stuff
var start_date = $.datepicker.formatDate("yy-mm-dd", start) + " " + start.toTimeString().substr(0, 8);
var end_date = $.datepicker.formatDate("yy-mm-dd", end) + " " + end.toTimeString().substr(0, 8);
$('#visible_to_input').show();
$('#add_as_announcement_div').show();
@ -167,6 +167,7 @@ $(document).ready(function() {
$('#color_calendar').addClass('{{ type_event_class }}');
allFields.removeClass( "ui-state-error" );
$("#dialog-form").dialog("open");
$("#dialog-form").dialog({
@ -192,9 +193,12 @@ $(document).ready(function() {
$("#content").attr('value', '');
}
});
//prevent the browser to follow the link
//Don't follow the link
return false;
calendar.fullCalendar('unselect');
//Reload events
calendar.fullCalendar("refetchEvents");
calendar.fullCalendar("rerenderEvents");
}
},
eventRender: function(event, element) {
@ -205,7 +209,7 @@ $(document).ready(function() {
},
content: event.attachment,
position: { at:'top right' , my:'bottom right'},
}).removeData('qtip'); // this is an special hack to add multipl qtip in the same target!
}).removeData('qtip'); // this is an special hack to add multiple qtip in the same target
}
@ -221,14 +225,16 @@ $(document).ready(function() {
},
eventClick: function(calEvent, jsEvent, view) {
//var start_date = Math.round(calEvent.start.getTime() / 1000);
var start_date = $.datepicker.formatDate("yy-mm-dd", calEvent.start) + " " + calEvent.start.toTimeString().substr(0, 8);
var start_date = Math.round(calEvent.start.getTime() / 1000);
if (calEvent.allDay == 1) {
var end_date = '';
} else {
var end_date = '';
if (calEvent.end && calEvent.end != '') {
var end_date = Math.round(calEvent.end.getTime() / 1000);
//var end_date = Math.round(calEvent.end.getTime() / 1000);
var end_date = $.datepicker.formatDate("yy-mm-dd", calEvent.end) + " " + calEvent.end.toTimeString().substr(0, 8);
}
}

Loading…
Cancel
Save