From ee18b0acac69d75f4afafe9c4e5ff97bca45ac7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lehrke?= Date: Fri, 23 Apr 2010 06:15:18 +0000 Subject: [PATCH] New all-day event implementation --- calendar/inc/class.calendar_bo.inc.php | 47 +++++++++++++++++--- calendar/inc/class.calendar_boupdate.inc.php | 35 ++++++++++++++- 2 files changed, 74 insertions(+), 8 deletions(-) diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index 7875e23592..e81296f260 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -722,19 +722,54 @@ class calendar_bo { $event['tzid'] = egw_time::$server_timezone->getName(); } - // we convert here from the server-time timestamps to user-time and (optional) to a different date-format! - foreach(array('start','end','modified','created','recur_enddate','recurrence') as $ts) + if (($event['whole_day'] = $this->so->isWholeDay($event)) && + $date_format != 'server') { - if (empty($event[$ts])) continue; - - $event[$ts] = $this->date2usertime($event[$ts],$date_format); + // Adjust dates to user TZ + $time = new egw_time($event['start'], egw_time::$server_timezone); + $time =& $this->so->startOfDay($time, $event['tzid']); + $event['start'] = egw_time::to($time, $date_format); + $time = new egw_time($event['end'], egw_time::$server_timezone); + $time =& $this->so->startOfDay($time, $event['tzid']); + $time->setTime(23, 59, 59); + $event['end'] = egw_time::to($time, $date_format); + $time = new egw_time($event['recurrence'], egw_time::$server_timezone); + $time =& $this->so->startOfDay($time, $event['tzid']); + $event['recurrence'] = egw_time::to($time, $date_format); + $time = new egw_time($event['recur_enddate'], egw_time::$server_timezone); + $time =& $this->so->startOfDay($time, $event['tzid']); + $time->setTime(23, 59, 59); + $event['recur_enddate'] = egw_time::to($time, $date_format); + $timestamps = array('modified','created'); + } + else + { + $timestamps = array('start','end','modified','created','recur_enddate','recurrence'); + } + // we convert here from the server-time timestamps to user-time and (optional) to a different date-format! + foreach ($timestamps as $ts) + { + if (!empty($event[$ts])) + { + $event[$ts] = $this->date2usertime($event[$ts],$date_format); + } } // same with the recur exceptions if (isset($event['recur_exception']) && is_array($event['recur_exception'])) { foreach($event['recur_exception'] as &$date) { - $date = $this->date2usertime($date,$date_format); + if ($event['whole_day'] && $date_format != 'server') + { + // Adjust dates to user TZ + $time = new egw_time($date, egw_time::$server_timezone); + $time =& $this->so->startOfDay($time, $event['tzid']); + $date = egw_time::to($time, $date_format); + } + else + { + $date = $this->date2usertime($date,$date_format); + } } } // same with the alarms diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index b286ad58ae..dea1532ded 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -852,8 +852,30 @@ class calendar_boupdate extends calendar_bo } $save_event = $event; + if (!isset($event['whole_day']) && ($event['whole_day'] = $this->isWholeDay($event))) + { + $time = new egw_time($event['start'], egw_time::$user_timezone); + $time =& $this->so->startOfDay($time); + $event['start'] = egw_time::to($time, 'ts'); + $time = new egw_time($event['end'], egw_time::$user_timezone); + $time =& $this->so->startOfDay($time); + $time->setTime(23, 59, 59); + $event['end'] = egw_time::to($time, 'ts'); + $time = new egw_time($event['recurrence'], egw_time::$user_timezone); + $time =& $this->so->startOfDay($time); + $event['recurrence'] = egw_time::to($time, 'ts'); + $time = new egw_time($event['recur_enddate'], egw_time::$user_timezone); + $time =& $this->so->startOfDay($time); + $time->setTime(23, 59, 59); + $event['recur_enddate'] = egw_time::to($time, 'ts'); + $timestamps = array('modified','created'); + } + else + { + $timestamps = array('start','end','modified','created','recur_enddate','recurrence'); + } // we run all dates through date2ts, to adjust to server-time and the possible date-formats - foreach(array('start','end','modified','created','recur_enddate','recurrence') as $ts) + foreach($timestamps as $ts) { // we convert here from user-time to timestamps in server-time! if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; @@ -868,7 +890,16 @@ class calendar_boupdate extends calendar_bo { foreach($event['recur_exception'] as $n => $date) { - $event['recur_exception'][$n] = $this->date2ts($date,true); + if ($event['whole_day']) + { + $time = new egw_time($date, egw_time::$user_timezone); + $time =& $this->so->startOfDay($time); + $date = egw_time::to($time, 'ts'); + } + else + { + $event['recur_exception'][$n] = $this->date2ts($date,true); + } } } // same with the alarms