From 88720be9a21b47adb42367b31e2aabc795639dfa Mon Sep 17 00:00:00 2001 From: ralf Date: Thu, 4 Jul 2024 15:46:49 +0200 Subject: [PATCH] fix/workaround for Apple and eMclient not understanding RDATE via CalDAV sending now master, plus expanded recurrences (like we would do with exceptions) also no longer export DTSTART in RDATE as unnecessary --- calendar/inc/class.calendar_groupdav.inc.php | 10 ++++++++++ calendar/inc/class.calendar_ical.inc.php | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/calendar/inc/class.calendar_groupdav.inc.php b/calendar/inc/class.calendar_groupdav.inc.php index c0fac26eb6..73771605d0 100644 --- a/calendar/inc/class.calendar_groupdav.inc.php +++ b/calendar/inc/class.calendar_groupdav.inc.php @@ -822,6 +822,11 @@ class calendar_groupdav extends Api\CalDAV\Handler // for recurring events we have to add the exceptions if ($this->client_shared_uid_exceptions && $event['recur_type'] && !empty($event['uid'])) { + // some clients (Apple, eMclient) do NOT understand RDATE, therefore we expand the recurrences + if ($event['recur_type'] == calendar_rrule::RDATE && in_array(Api\CalDAV\Handler::get_agent(), ['dataaccess', 'iphone', 'calendaragent', 'emclient'])) + { + $expand = $readd_master = true; + } if (is_array($expand)) { if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); @@ -831,6 +836,11 @@ class calendar_groupdav extends Api\CalDAV\Handler if ($expand || !isset($events)) { $events =& self::get_series($event['uid'], $this->bo, $expand, $user, $event, isset($json) ? 'object' : 'server'); + + if (!empty($readd_master)) + { + array_unshift($events, $event); + } } // as alarm is now only on next recurrence, set alarm from original event on master if ($event['alarm']) $events[0]['alarm'] = $event['alarm']; diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index b073c289ff..aca4f61255 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -703,7 +703,8 @@ class calendar_ical extends calendar_boupdate $event[$egwFieldName] = $days; if ($version != '1.0') $parameters[$icalFieldName]['VALUE'] = 'DATE'; } - $vevent->setAttribute($icalFieldName, $event[$egwFieldName], $parameters[$icalFieldName]); + $vevent->setAttribute($icalFieldName, // for RDATE, do not export first RDATE as identical with DTSTART + array_slice($event[$egwFieldName], $icalFieldName === 'RDATE' ? 1 : 0), $parameters[$icalFieldName]); } break;