Fix new all-day event handling

This commit is contained in:
Jörg Lehrke 2010-04-23 13:52:45 +00:00
parent f8a0c3ccec
commit 22bb23b8ff
3 changed files with 38 additions and 35 deletions

View File

@ -715,15 +715,15 @@ class calendar_bo
function db2data(&$events,$date_format='ts')
{
if (!is_array($events)) echo "<p>bocal::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
foreach($events as &$event)
foreach ($events as &$event)
{
// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
if (!$event['tz_id'] || !($event['tzid'] = calendar_timezones::id2tz($event['tz_id'])))
{
$event['tzid'] = egw_time::$server_timezone->getName();
}
if (($event['whole_day'] = $this->so->isWholeDay($event)) &&
$date_format != 'server')
$event['whole_day'] = $this->isWholeDay($event);
if ($event['whole_day'] && $date_format != 'server')
{
// Adjust dates to user TZ
$time = new egw_time($event['start'], egw_time::$server_timezone);

View File

@ -852,7 +852,8 @@ class calendar_boupdate extends calendar_bo
}
$save_event = $event;
if (!isset($event['whole_day']) && ($event['whole_day'] = $this->isWholeDay($event)))
if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event);
if ($event['whole_day'])
{
$time = new egw_time($event['start'], egw_time::$user_timezone);
$time =& $this->so->startOfDay($time);

View File

@ -568,16 +568,20 @@ class calendar_ical extends calendar_boupdate
break;
case 'DTSTART':
if (!isset($event['whole_day']))
if (empty($event['whole_day']))
{
$attributes['DTSTART'] = self::getDateTime($event['start'],$tzid,$parameters['DTSTART']);
}
break;
case 'DTEND':
// write start + end of whole day events as dates
if (isset($event['whole_day']))
if (empty($event['whole_day']))
{
$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
}
else
{
// write start + end of whole day events as dates
$event['end-nextday'] = $event['end'] + 12*3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
foreach (array('start' => 'DTSTART','end-nextday' => 'DTEND') as $f => $t)
{
@ -588,10 +592,6 @@ class calendar_ical extends calendar_boupdate
}
unset($attributes['DTSTART']);
}
else
{
$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
}
break;
case 'RRULE':
@ -613,9 +613,17 @@ class calendar_ical extends calendar_boupdate
if ($event['recur_type'] == MCAL_RECUR_NONE) break;
if (!empty($event['recur_exception']))
{
// use 'DATE' instead of 'DATE-TIME' on whole day events
if (isset($event['whole_day']))
if (empty($event['whole_day']))
{
$value_type = 'DATE-TIME';
foreach ($event['recur_exception'] as $key => $timestamp)
{
$event['recur_exception'][$key] = self::getDateTime($timestamp,$tzid,$parameters['EXDATE']);
}
}
else
{
// use 'DATE' instead of 'DATE-TIME' on whole day events
$value_type = 'DATE';
foreach ($event['recur_exception'] as $id => $timestamp)
{
@ -630,14 +638,7 @@ class calendar_ical extends calendar_boupdate
}
$event['recur_exception'] = $days;
}
else
{
$value_type = 'DATE-TIME';
foreach ($event['recur_exception'] as $key => $timestamp)
{
$event['recur_exception'][$key] = self::getDateTime($timestamp,$tzid,$parameters['EXDATE']);
}
}
$attributes['EXDATE'] = '';
$values['EXDATE'] = $event['recur_exception'];
$parameters['EXDATE']['VALUE'] = $value_type;
@ -694,7 +695,11 @@ class calendar_ical extends calendar_boupdate
if ($recur_date)
{
// We handle a pseudo exception
if (isset($event['whole_day']))
if (empty($event['whole_day']))
{
$attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]);
}
else
{
$time = new egw_time($recur_date,egw_time::$server_timezone);
$time->setTimezone(self::$tz_cache[$event['tzid']]);
@ -706,17 +711,17 @@ class calendar_ical extends calendar_boupdate
array('VALUE' => 'DATE')
);
}
else
{
$attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]);
}
}
elseif ($event['recurrence'] && $event['reference'])
{
// $event['reference'] is a calendar_id, not a timestamp
if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist
if (isset($revent['whole_day']))
if (empty($revent['whole_day']))
{
$attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]);
}
else
{
$time = new egw_time($event['recurrence'],egw_time::$server_timezone);
$time->setTimezone(self::$tz_cache[$event['tzid']]);
@ -728,10 +733,7 @@ class calendar_ical extends calendar_boupdate
array('VALUE' => 'DATE')
);
}
else
{
$attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]);
}
unset($revent);
}
break;
@ -859,7 +861,7 @@ class calendar_ical extends calendar_boupdate
// RFC requires DESCRIPTION for DISPLAY
if (!$event['title'] && !$description) continue;
if (isset($event['whole_day']) && $alarmData['offset'])
if (!empty($event['whole_day']) && $alarmData['offset'])
{
$alarmData['time'] = $event['start'] - $alarmData['offset'];
$alarmData['offset'] = false;
@ -1205,7 +1207,7 @@ class calendar_ical extends calendar_boupdate
}
}
if ($event['whole_day'] && $event['tzid'] != $event_info['stored_event']['tzid'])
if (!empty($event['whole_day']) && $event['tzid'] != $event_info['stored_event']['tzid'])
{
// Adjust dates to original TZ
$time = new egw_time($event['start'],egw_time::$server_timezone);
@ -1224,7 +1226,7 @@ class calendar_ical extends calendar_boupdate
$event['recur_exception'][$key] = egw_time::to($time,'server');
}
}
elseif($event['recurrence'])
elseif ($event['recurrence'])
{
$time = new egw_time($event['recurrence'],egw_time::$server_timezone);
$time =& $this->so->startOfDay($time, $event_info['stored_event']['tzid']);
@ -1244,7 +1246,7 @@ class calendar_ical extends calendar_boupdate
{
unset($event['id']);
// set non blocking all day depending on the user setting
if (isset($event['whole_day']) && $this->nonBlockingAllday)
if (!empty($event['whole_day']) && $this->nonBlockingAllday)
{
$event['non_blocking'] = 1;
}