mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-14 18:08:21 +01:00
Fix new all-day event handling
This commit is contained in:
parent
f8a0c3ccec
commit
22bb23b8ff
@ -715,15 +715,15 @@ class calendar_bo
|
|||||||
function db2data(&$events,$date_format='ts')
|
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";
|
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')
|
// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
|
||||||
if (!$event['tz_id'] || !($event['tzid'] = calendar_timezones::id2tz($event['tz_id'])))
|
if (!$event['tz_id'] || !($event['tzid'] = calendar_timezones::id2tz($event['tz_id'])))
|
||||||
{
|
{
|
||||||
$event['tzid'] = egw_time::$server_timezone->getName();
|
$event['tzid'] = egw_time::$server_timezone->getName();
|
||||||
}
|
}
|
||||||
if (($event['whole_day'] = $this->so->isWholeDay($event)) &&
|
$event['whole_day'] = $this->isWholeDay($event);
|
||||||
$date_format != 'server')
|
if ($event['whole_day'] && $date_format != 'server')
|
||||||
{
|
{
|
||||||
// Adjust dates to user TZ
|
// Adjust dates to user TZ
|
||||||
$time = new egw_time($event['start'], egw_time::$server_timezone);
|
$time = new egw_time($event['start'], egw_time::$server_timezone);
|
||||||
|
@ -852,7 +852,8 @@ class calendar_boupdate extends calendar_bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
$save_event = $event;
|
$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 = new egw_time($event['start'], egw_time::$user_timezone);
|
||||||
$time =& $this->so->startOfDay($time);
|
$time =& $this->so->startOfDay($time);
|
||||||
|
@ -568,16 +568,20 @@ class calendar_ical extends calendar_boupdate
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'DTSTART':
|
case 'DTSTART':
|
||||||
if (!isset($event['whole_day']))
|
if (empty($event['whole_day']))
|
||||||
{
|
{
|
||||||
$attributes['DTSTART'] = self::getDateTime($event['start'],$tzid,$parameters['DTSTART']);
|
$attributes['DTSTART'] = self::getDateTime($event['start'],$tzid,$parameters['DTSTART']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'DTEND':
|
case 'DTEND':
|
||||||
// write start + end of whole day events as dates
|
if (empty($event['whole_day']))
|
||||||
if (isset($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
|
$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)
|
foreach (array('start' => 'DTSTART','end-nextday' => 'DTEND') as $f => $t)
|
||||||
{
|
{
|
||||||
@ -588,10 +592,6 @@ class calendar_ical extends calendar_boupdate
|
|||||||
}
|
}
|
||||||
unset($attributes['DTSTART']);
|
unset($attributes['DTSTART']);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'RRULE':
|
case 'RRULE':
|
||||||
@ -613,9 +613,17 @@ class calendar_ical extends calendar_boupdate
|
|||||||
if ($event['recur_type'] == MCAL_RECUR_NONE) break;
|
if ($event['recur_type'] == MCAL_RECUR_NONE) break;
|
||||||
if (!empty($event['recur_exception']))
|
if (!empty($event['recur_exception']))
|
||||||
{
|
{
|
||||||
// use 'DATE' instead of 'DATE-TIME' on whole day events
|
if (empty($event['whole_day']))
|
||||||
if (isset($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';
|
$value_type = 'DATE';
|
||||||
foreach ($event['recur_exception'] as $id => $timestamp)
|
foreach ($event['recur_exception'] as $id => $timestamp)
|
||||||
{
|
{
|
||||||
@ -630,14 +638,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
}
|
}
|
||||||
$event['recur_exception'] = $days;
|
$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'] = '';
|
$attributes['EXDATE'] = '';
|
||||||
$values['EXDATE'] = $event['recur_exception'];
|
$values['EXDATE'] = $event['recur_exception'];
|
||||||
$parameters['EXDATE']['VALUE'] = $value_type;
|
$parameters['EXDATE']['VALUE'] = $value_type;
|
||||||
@ -694,7 +695,11 @@ class calendar_ical extends calendar_boupdate
|
|||||||
if ($recur_date)
|
if ($recur_date)
|
||||||
{
|
{
|
||||||
// We handle a pseudo exception
|
// 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 = new egw_time($recur_date,egw_time::$server_timezone);
|
||||||
$time->setTimezone(self::$tz_cache[$event['tzid']]);
|
$time->setTimezone(self::$tz_cache[$event['tzid']]);
|
||||||
@ -706,17 +711,17 @@ class calendar_ical extends calendar_boupdate
|
|||||||
array('VALUE' => 'DATE')
|
array('VALUE' => 'DATE')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elseif ($event['recurrence'] && $event['reference'])
|
elseif ($event['recurrence'] && $event['reference'])
|
||||||
{
|
{
|
||||||
// $event['reference'] is a calendar_id, not a timestamp
|
// $event['reference'] is a calendar_id, not a timestamp
|
||||||
if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist
|
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 = new egw_time($event['recurrence'],egw_time::$server_timezone);
|
||||||
$time->setTimezone(self::$tz_cache[$event['tzid']]);
|
$time->setTimezone(self::$tz_cache[$event['tzid']]);
|
||||||
@ -728,10 +733,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
array('VALUE' => 'DATE')
|
array('VALUE' => 'DATE')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]);
|
|
||||||
}
|
|
||||||
unset($revent);
|
unset($revent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -859,7 +861,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
// RFC requires DESCRIPTION for DISPLAY
|
// RFC requires DESCRIPTION for DISPLAY
|
||||||
if (!$event['title'] && !$description) continue;
|
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['time'] = $event['start'] - $alarmData['offset'];
|
||||||
$alarmData['offset'] = false;
|
$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
|
// Adjust dates to original TZ
|
||||||
$time = new egw_time($event['start'],egw_time::$server_timezone);
|
$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');
|
$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 = new egw_time($event['recurrence'],egw_time::$server_timezone);
|
||||||
$time =& $this->so->startOfDay($time, $event_info['stored_event']['tzid']);
|
$time =& $this->so->startOfDay($time, $event_info['stored_event']['tzid']);
|
||||||
@ -1244,7 +1246,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
{
|
{
|
||||||
unset($event['id']);
|
unset($event['id']);
|
||||||
// set non blocking all day depending on the user setting
|
// 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;
|
$event['non_blocking'] = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user