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

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

@ -8,8 +8,7 @@
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
@ -51,12 +50,9 @@ class Agenda {
* @param bool add event as a *course* announcement
*
*/
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);
function add_event($start, $end, $all_day, $view, $title, $content, $users_to_send = array(), $add_as_announcement = false) {
$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;
@ -413,7 +418,7 @@ class Agenda {
*/
function get_personal_events($start, $end) {
$start = intval($start);
$end = intval($end);
$end = intval($end);
$start = api_get_utc_datetime($start);
$end = api_get_utc_datetime($end);
$user_id = api_get_user_id();
@ -692,9 +697,12 @@ class Agenda {
return $my_events;
}
//Format needed for the Fullcalendar js lib
function format_event_date($utc_time) {
return date('c', api_strtotime(api_get_local_time($utc_time)));
/**
* 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)));
}

@ -109,7 +109,7 @@ $(document).ready(function() {
monthNames: {{month_names}},
monthNamesShort:{{month_names_short}},
dayNames: {{day_names}},
dayNamesShort: {{day_names_short}},
dayNamesShort: {{day_names_short}},
firstHour: 8,
firstDay: 1,
selectable : true,
@ -125,10 +125,10 @@ $(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();
$('#visible_to_read_only').hide();
@ -166,7 +166,8 @@ $(document).ready(function() {
$('#color_calendar').addClass('label_tag');
$('#color_calendar').addClass('{{ type_event_class }}');
allFields.removeClass( "ui-state-error" );
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
}
@ -220,15 +224,17 @@ $(document).ready(function() {
}
},
eventClick: function(calEvent, jsEvent, view) {
var start_date = Math.round(calEvent.start.getTime() / 1000);
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);
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