From a2758c4319b6c6f95235529d52b4e71b51caab3e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 6 Aug 2018 19:04:41 +0200 Subject: [PATCH] * CalDAV/Calendar/Resources: do not allow to change resource quantity via CalDAV Resource quantity is restored from existing event, as neither iOS nor Thunderbird returns our X-EGROUPWARE-QUANTITY attribute on the attendee. Also display quantity > 1 in brackets after resource name. --- calendar/inc/class.calendar_ical.inc.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index c5ecef8a84..76d1dd222e 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -541,7 +541,11 @@ class calendar_ical extends calendar_boupdate $options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it } if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid; - if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity; + if ($quantity > 1) + { + $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity; + $options['CN'] .= ' ('.$quantity.')'; + } $attributes['ATTENDEE'][] = $participantURL; $parameters['ATTENDEE'][] = $options; } @@ -1267,6 +1271,17 @@ class calendar_ical extends calendar_boupdate $event['participants'][$uid] = calendar_so::combine_status('U'); } } + // restore resource-quantity from existing event as neither iOS nor Thunderbird returns our X-EGROUPWARE-QUANTITY + elseif ($uid[0] === 'r' && isset($event_info['stored_event']['participants'][$uid])) + { + $quantity = $role = $old_quantity = null; + calendar_so::split_status($status, $quantity, $role); + calendar_so::split_status($event_info['stored_event']['participants'][$uid], $old_quantity); + if ($old_quantity > 1) + { + $event['participants'][$uid] = calendar_so::combine_status('U', $old_quantity, $role); + } + } } } // unset old X-* attributes stored in custom-fields