Detect all-day events in free/busy data and shift into user's timezone to cover the full day

This commit is contained in:
Thomas Bruederli 2014-08-12 16:52:44 +02:00
parent 79af219093
commit 57090af3f8

View file

@ -1890,12 +1890,12 @@ class calendar extends rcube_plugin
// convert dates into unix timestamps // convert dates into unix timestamps
if (!empty($start) && !is_numeric($start)) { if (!empty($start) && !is_numeric($start)) {
$dts = new DateTime($start, $this->timezone); $dts = rcube_utils::anytodatetime($start, $this->timezone);
$start = $dts->format('U'); $start = $dts ? $dts->format('U') : null;
} }
if (!empty($end) && !is_numeric($end)) { if (!empty($end) && !is_numeric($end)) {
$dte = new DateTime($end, $this->timezone); $dte = rcube_utils::anytodatetime($end, $this->timezone);
$end = $dte->format('U'); $end = $dte ? $dte->format('U') : null;
} }
if (!$start) $start = time(); if (!$start) $start = time();
@ -1922,6 +1922,14 @@ class calendar extends rcube_plugin
$status = self::FREEBUSY_FREE; $status = self::FREEBUSY_FREE;
foreach ($fblist as $slot) { foreach ($fblist as $slot) {
list($from, $to, $type) = $slot; list($from, $to, $type) = $slot;
// check for possible all-day times
if (gmdate('His', $from) == '000000' && gmdate('His', $to) == '235959') {
// shift into the user's timezone for sane matching
$from -= $this->gmt_offset;
$to -= $this->gmt_offset;
}
if ($from < $t_end && $to > $t) { if ($from < $t_end && $to > $t) {
$status = isset($type) ? $type : self::FREEBUSY_BUSY; $status = isset($type) ? $type : self::FREEBUSY_BUSY;
if ($status == self::FREEBUSY_BUSY) // can't get any worse :-) if ($status == self::FREEBUSY_BUSY) // can't get any worse :-)