New all-day event implementation

This commit is contained in:
Jörg Lehrke 2010-04-23 06:15:18 +00:00
parent 7611cd1374
commit ee18b0acac
2 changed files with 74 additions and 8 deletions

View File

@ -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

View File

@ -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