From 6832c6c3d2b1457cb710d3c24091fb2cf575fb5b Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Wed, 20 Jul 2011 19:34:23 +0200 Subject: [PATCH] Show free-busy times in 6 hours blocks for all-day events --- plugins/calendar/calendar.php | 11 ++++------- plugins/calendar/calendar_ui.js | 23 ++++++++++------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index f472743d..0623d08d 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -1235,15 +1235,12 @@ class calendar extends rcube_plugin { $email = get_input_value('email', RCUBE_INPUT_GPC); $start = get_input_value('start', RCUBE_INPUT_GET); -# $end = get_input_value('end', RCUBE_INPUT_GET); - $interval = 3600; // in seconds + $end = get_input_value('end', RCUBE_INPUT_GET); + $interval = intval(get_input_value('interval', RCUBE_INPUT_GET)); if (!$start) $start = time(); if (!$end) $end = $start + 86400 * 30; - - // reset $start/$end to midnight - #$start = gmmktime(0, 0, 0, gmdate('n', $start), gmdate('j'), gmdate('Y')); - #$end = gmmktime(23, 59, 59, gmdate('n', $end), gmdate('j'), gmdate('Y')); + if (!$interval) $interval = 60; // 1 hour $fblist = $this->driver->get_freebusy_list($email, $start, $end); $slots = array(); @@ -1251,7 +1248,7 @@ class calendar extends rcube_plugin // build a list from $start till $end with blocks representing the fb-status for ($s = 0, $t = $start; $t <= $end; $s++) { $status = self::FREEBUSY_UNKNOWN; - $t_end = $t + $interval; + $t_end = $t + $interval * 60; // determine attendee's status if (is_array($fblist)) { diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js index 02564d3c..97279c4a 100644 --- a/plugins/calendar/calendar_ui.js +++ b/plugins/calendar/calendar_ui.js @@ -623,19 +623,15 @@ function rcube_calendar_ui(settings) } // render time slots - var interval = 60; var now = new Date(), fb_start = new Date(), fb_end = new Date(); fb_start.setTime(Math.max(now, event.start)); - fb_start.setHours(0); - fb_start.setMinutes(0); - fb_start.setSeconds(0); - fb_start.setMilliseconds(0); + fb_start.setHours(0); fb_start.setMinutes(0); fb_start.setSeconds(0); fb_start.setMilliseconds(0); fb_end.setTime(fb_start.getTime() + 86400000); freebusy_data = {}; - freebusy_ui.loading = 1; - freebusy_ui.numdays = 1; - freebusy_ui.interval = interval; + freebusy_ui.loading = 1; // prevent render_freebusy_grid() to load data + freebusy_ui.numdays = allday.checked ? 7 : 1; + freebusy_ui.interval = allday.checked ? 360 : 60; freebusy_ui.start = fb_start; freebusy_ui.end = new Date(freebusy_ui.start.getTime() + 86400000 * freebusy_ui.numdays); render_freebusy_grid(0); @@ -673,7 +669,7 @@ function rcube_calendar_ui(settings) // fetch data from server freebusy_ui.loading = 0; - load_freebusy_data(fb_start, interval); + load_freebusy_data(freebusy_ui.start, freebusy_ui.interval); }; // render an HTML table showing free-busy status for all the event attendees @@ -695,7 +691,7 @@ function rcube_calendar_ui(settings) } // TODO: define working hours by config - css = !(curdate.getHours() >= 6 && curdate.getHours() <= 18) ? 'offhours' : 'workinghours'; + css = (freebusy_ui.numdays == 1 && (curdate.getHours() < 6 || curdate.getHours() > 18)) ? 'offhours' : 'workinghours'; times_row += '' + Q($.fullCalendar.formatDate(curdate, settings['time_format'])) + ''; slots_row += ' '; @@ -717,7 +713,7 @@ function rcube_calendar_ui(settings) // if we have loaded free-busy data, show it if (!freebusy_ui.loading) { - if (date2unixtime(freebusy_ui.start) < freebusy_data.start || date2unixtime(freebusy_ui.end) > freebusy_data.end) { + if (date2unixtime(freebusy_ui.start) < freebusy_data.start || date2unixtime(freebusy_ui.end) > freebusy_data.end || freebusy_ui.interval != freebusy_data.interval) { load_freebusy_data(freebusy_ui.start, freebusy_ui.interval) return; } @@ -747,7 +743,7 @@ function rcube_calendar_ui(settings) type: 'GET', dataType: 'json', url: rcmail.url('freebusy-times'), - data: { email:email, start:date2unixtime(start), end:date2unixtime(end), _remote: 1 }, + data: { email:email, start:date2unixtime(start), end:date2unixtime(end), interval:interval, _remote: 1 }, success: function(data){ freebusy_ui.loading--; @@ -757,9 +753,10 @@ function rcube_calendar_ui(settings) freebusy_data[data.email] = {}; for (var i=0; i < data.slots.length; i++) { freebusy_data[data.email][ts] = data.slots[i]; - ts += data.interval; + ts += data.interval * 60; } freebusy_data.end = ts; + freebusy_data.interval = data.interval; // hide loading indicator var domid = String(data.email).replace(rcmail.identifier_expr, '');