From 2a2a9f5f11e290d719f3420f49b4e5f9d9012790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lehrke?= Date: Fri, 23 Apr 2010 15:15:22 +0000 Subject: [PATCH] Cleanup all-day handling --- calendar/inc/class.calendar_boupdate.inc.php | 28 ++++++------- calendar/inc/class.calendar_sif.inc.php | 42 ++++++++++---------- 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index 04bebd3898..07198a06bf 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -1657,7 +1657,7 @@ class calendar_boupdate extends calendar_bo if ($filter != 'master' && ($filter != 'exact' || empty($event['uid']))) { - if (isset($event['whole_day']) && $event['whole_day']) + if (!empty($event['whole_day'])) { if ($filter == 'relax') { @@ -1781,19 +1781,7 @@ class calendar_boupdate extends calendar_bo // check times if ($filter != 'relax') { - if (isset($event['whole_day'])&& $event['whole_day']) - { - if (!$this->so->isWholeDay($egwEvent)) - { - if ($this->log) - { - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - "() egwEvent is not a whole-day event!\n",3,$this->logfile); - } - continue; - } - } - else + if (empty($event['whole_day'])) { if (abs($event['end'] - $egwEvent['end']) >= 120) { @@ -1805,6 +1793,18 @@ class calendar_boupdate extends calendar_bo continue; } } + else + { + if (!$this->so->isWholeDay($egwEvent)) + { + if ($this->log) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. + "() egwEvent is not a whole-day event!\n",3,$this->logfile); + } + continue; + } + } } // check for real match diff --git a/calendar/inc/class.calendar_sif.inc.php b/calendar/inc/class.calendar_sif.inc.php index 333ef5bd66..4c623735a3 100644 --- a/calendar/inc/class.calendar_sif.inc.php +++ b/calendar/inc/class.calendar_sif.inc.php @@ -490,7 +490,7 @@ class calendar_sif extends calendar_boupdate // not merge // SIF clients do not support participants => add them back unset($event['participants']); - if ($event['whole_day'] && $event['tzid'] != $event_info['stored_event']['tzid']) + if (!empty($event['whole_day']) && $event['tzid'] != $event_info['stored_event']['tzid']) { if (!isset(self::$tz_cache[$event_info['stored_event']['tzid']])) { @@ -524,9 +524,7 @@ class calendar_sif extends calendar_boupdate else // common adjustments for new events { // set non blocking all day depending on the user setting - if (isset($event['whole_day']) - && $event['whole_day'] - && $this->nonBlockingAllday) + if (!empty($event['whole_day']) && $this->nonBlockingAllday) { $event['non_blocking'] = 1; } @@ -906,7 +904,7 @@ class calendar_sif extends calendar_boupdate } elseif (!$recur_date && $event['recur_type'] != MCAL_RECUR_NONE && - !isset($event['whole_day'])) // whole-day events are not shifted + empty($event['whole_day'])) // whole-day events are not shifted { // Add the timezone transition related pseudo exceptions $exceptions = $this->so->get_recurrence_exceptions($event, $tzid, 0, 0, 'tz_rrule'); @@ -1059,16 +1057,7 @@ class calendar_sif extends calendar_boupdate $sifEvent .= ''; foreach ($event['recur_exception'] as $day) { - if (isset($event['whole_day'])) - { - if (!is_a($day,'DateTime')) - { - $day = new egw_time($day,egw_time::$server_timezone); - $day->setTimezone(self::$tz_cache[$event['tzid']]); - } - $sifEvent .= '' . $day->format('Y-m-d') . ''; - } - else + if (empty($event['whole_day'])) { if ($this->log && is_a($day,'DateTime')) { @@ -1078,6 +1067,15 @@ class calendar_sif extends calendar_boupdate } $sifEvent .= '' . self::getDateTime($day,$tzid) . ''; } + else + { + if (!is_a($day,'DateTime')) + { + $day = new egw_time($day,egw_time::$server_timezone); + $day->setTimezone(self::$tz_cache[$event['tzid']]); + } + $sifEvent .= '' . $day->format('Y-m-d') . ''; + } } $sifEvent .= ''; } @@ -1099,7 +1097,13 @@ class calendar_sif extends calendar_boupdate break; case 'Start': - if (isset($event['whole_day'])) + if (empty($event['whole_day'])) + { + $sifEvent .= '' . self::getDateTime($event['start'],$tzid) . ''; + $sifEvent .= '' . self::getDateTime($event['end'],$tzid) . ''; + $sifEvent .= "0"; + } + else { // for whole-day events we use the date in event timezone $time = new egw_time($event['start'],egw_time::$server_timezone); @@ -1110,12 +1114,6 @@ class calendar_sif extends calendar_boupdate $sifEvent .= '' . $time->format('Y-m-d') . ''; $sifEvent .= "1"; } - else - { - $sifEvent .= '' . self::getDateTime($event['start'],$tzid) . ''; - $sifEvent .= '' . self::getDateTime($event['end'],$tzid) . ''; - $sifEvent .= "0"; - } break; case 'ReminderMinutesBeforeStart':