From 4d532e9a27e08460e3ffec59e04c2cb0b7aa1630 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Sat, 4 Jun 2011 15:52:12 -0400 Subject: [PATCH] Show events in clients timezone; only refetch events from modified source; maintain rc-specific patch for fullcalendar --- plugins/calendar/calendar.js | 10 ++++-- plugins/calendar/calendar.php | 22 +++++++------ .../drivers/database/database_driver.php | 2 +- plugins/calendar/lib/fullcalendar-rc.patch | 32 +++++++++++++++++++ plugins/calendar/lib/js/fullcalendar.js | 11 ++++--- plugins/calendar/skins/default/calendar.css | 2 +- 6 files changed, 59 insertions(+), 20 deletions(-) create mode 100644 plugins/calendar/lib/fullcalendar-rc.patch diff --git a/plugins/calendar/calendar.js b/plugins/calendar/calendar.js index 005a6d86..199a373b 100644 --- a/plugins/calendar/calendar.js +++ b/plugins/calendar/calendar.js @@ -298,6 +298,7 @@ function rcube_calendar(settings) // post data to server var data = { + calendar: event.calendar, start: start.getTime()/1000, end: end.getTime()/1000, allday: allday.checked?1:0, @@ -309,7 +310,7 @@ function rcube_calendar(settings) priority: priority.val(), sensitivity: sensitivity.val(), recurrence: '', - alarms:'', + alarms: '' }; // serialize alarm settings @@ -658,6 +659,7 @@ function rcube_calendar(settings) right: 'agendaDay,agendaWeek,month' }, aspectRatio: 1, + ignoreTimezone: false, // will translate event dates to the client's timezone height: $(window).height() - 96, eventSources: event_sources, monthNames : settings['months'], @@ -755,6 +757,7 @@ function rcube_calendar(settings) // send move request to server var data = { id: event.id, + calendar: event.calendar, start: event.start.getTime()/1000, end: event.end.getTime()/1000, allday: allDay?1:0 @@ -769,8 +772,9 @@ function rcube_calendar(settings) // send resize request to server var data = { id: event.id, + calendar: event.calendar, start: event.start.getTime()/1000, - end: event.end.getTime()/1000, + end: event.end.getTime()/1000 }; if (event.recurrence) recurring_edit_confirm(data, 'resize'); @@ -945,7 +949,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) { // register callback commands rcmail.addEventListener('plugin.display_alarms', function(alarms){ cal.display_alarms(alarms); }); - rcmail.addEventListener('plugin.reload_calendar', function(){ $('#calendar').fullCalendar('refetchEvents'); }); + rcmail.addEventListener('plugin.reload_calendar', function(p){ $('#calendar').fullCalendar('refetchEvents', cal.calendars[p.source]); }); // let's go diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index 539e44c4..40f00f0c 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -50,7 +50,7 @@ class calendar extends rcube_plugin } // load localizations - $this->add_texts('localization/', true); + $this->add_texts('localization/', $this->rc->action != 'plugin.event'); // load Calendar user interface which includes jquery-ui $this->require_plugin('jqueryui'); @@ -181,7 +181,7 @@ class calendar extends rcube_plugin 'title' => html::label($field_id, Q($this->gettext('default_view'))), 'content' => $select->show($this->rc->config->get('calendar_default_view', "agendaWeek")), ); - +/* $field_id = 'rcmfd_time_format'; $choices = array('HH:mm', 'H:mm', 'h:mmt'); $select = new html_select(array('name' => '_time_format', 'id' => $field_id)); @@ -190,7 +190,7 @@ class calendar extends rcube_plugin 'title' => html::label($field_id, Q($this->gettext('time_format'))), 'content' => $select->show($this->rc->config->get('calendar_time_format', "HH:mm")), ); - +*/ $field_id = 'rcmfd_timeslot'; $choices = array('1', '2', '3', '4', '6'); $select = new html_select(array('name' => '_timeslots', 'id' => $field_id)); @@ -217,8 +217,8 @@ class calendar extends rcube_plugin $field_id = 'rcmfd_alarm'; $select_type = new html_select(array('name' => '_alarm_type', 'id' => $field_id)); $select_type->add($this->gettext('none'), ''); - $select_type->add($this->gettext('alarmdisplayoption'), 'DISPLAY'); - $select_type->add($this->gettext('alarmemailoption'), 'EMAIL'); + foreach ($this->driver->alarm_types as $type) + $select_type->add($this->gettext(strtolower("alarm{$type}option")), $type); $input_value = new html_inputfield(array('name' => '_alarm_value', 'id' => $field_id . 'value', 'size' => 3)); $select_offset = new html_select(array('name' => '_alarm_offset', 'id' => $field_id . 'offset')); @@ -378,7 +378,7 @@ class calendar extends rcube_plugin $this->rc->output->show_message('calendar.errorsaving', 'error'); if ($success && $reload) - $this->rc->output->command('plugin.reload_calendar', array()); + $this->rc->output->command('plugin.reload_calendar', array('source' => $event['calendar'])); } /** @@ -504,7 +504,8 @@ class calendar extends rcube_plugin function fromGMT($datetime, $user_tz = true) { $tz = $user_tz ? $this->gmt_offset : date('Z'); - return strtotime($datetime) + $tz; + $ts = is_numeric($datetime) ? $datetime : strtotime($datetime); + return $ts + $tz; } /** @@ -725,17 +726,18 @@ class calendar extends rcube_plugin } $title = ''; - $len = rand(4, 40); + $len = rand(2, 12); + $words = explode(" ", "The Hough transform is named after Paul Hough who patented the method in 1962. It is a technique which can be used to isolate features of a particular shape within an image. Because it requires that the desired features be specified in some parametric form, the classical Hough transform is most commonly used for the de- tection of regular curves such as lines, circles, ellipses, etc. A generalized Hough transform can be employed in applications where a simple analytic description of a feature(s) is not possible. Due to the computational complexity of the generalized Hough algorithm, we restrict the main focus of this discussion to the classical Hough transform. Despite its domain restrictions, the classical Hough transform (hereafter referred to without the classical prefix ) retains many applications, as most manufac- tured parts (and many anatomical parts investigated in medical imagery) contain feature boundaries which can be described by regular curves. The main advantage of the Hough transform technique is that it is tolerant of gaps in feature boundary descriptions and is relatively unaffected by image noise."); $chars = "!# abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890"; for ($i = 0; $i < $len; $i++) - $title .= $chars[rand(0,strlen($chars)-1)]; + $title .= $words[rand(0,count($words)-1)] . " "; $this->driver->new_event(array( 'uid' => $this->generate_uid(), 'start' => $start, 'end' => $start + $duration, 'allday' => $allday, - 'title' => $title, + 'title' => rtrim($title), 'free_busy' => $fb == 2 ? 'outofoffice' : ($fb ? 'busy' : 'free'), 'categories' => $cats[array_rand($cats)], 'calendar' => array_rand($cals), diff --git a/plugins/calendar/drivers/database/database_driver.php b/plugins/calendar/drivers/database/database_driver.php index 350304e4..ef807747 100644 --- a/plugins/calendar/drivers/database/database_driver.php +++ b/plugins/calendar/drivers/database/database_driver.php @@ -508,7 +508,7 @@ class database_driver extends calendar_driver $success = $this->rc->db->affected_rows($query); if ($success && $update_master) $this->_update_event($master, true); -console($savemode, $master['id'], $success); + return $success; } diff --git a/plugins/calendar/lib/fullcalendar-rc.patch b/plugins/calendar/lib/fullcalendar-rc.patch new file mode 100644 index 00000000..8b5337d1 --- /dev/null +++ b/plugins/calendar/lib/fullcalendar-rc.patch @@ -0,0 +1,32 @@ +--- js/fullcalendar.js.orig 2011-06-04 15:45:44.000000000 -0400 ++++ js/fullcalendar.js 2011-06-04 15:46:38.000000000 -0400 +@@ -500,8 +500,8 @@ + } + + +- function refetchEvents() { +- fetchEvents(currentView.visStart, currentView.visEnd); // will call reportEvents ++ function refetchEvents(source) { ++ fetchEvents(currentView.visStart, currentView.visEnd, source); // will call reportEvents + } + + +@@ -897,7 +897,7 @@ + } + + +- function fetchEvents(start, end) { ++ function fetchEvents(start, end, src) { + rangeStart = start; + rangeEnd = end; + cache = []; +@@ -905,7 +905,8 @@ + var len = sources.length; + pendingSourceCnt = len; + for (var i=0; i