From 23d36a92407106928fdc43ed39071a0368e67c44 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Sat, 24 Sep 2022 01:48:00 +0200 Subject: [PATCH] Add support for COMMENTs Signed-off-by: Anna Larch --- lib/ITip/Broker.php | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php index 6d627537..1aedf5f7 100644 --- a/lib/ITip/Broker.php +++ b/lib/ITip/Broker.php @@ -78,6 +78,7 @@ class Broker 'RDATE', 'EXDATE', 'STATUS', + 'COMMENT' ]; /** @@ -305,6 +306,7 @@ protected function processMessageCancel(Message $itipMessage, ?VCalendar $existi foreach ($existingObject->VEVENT as $vevent) { $vevent->STATUS = 'CANCELLED'; $vevent->SEQUENCE = $itipMessage->sequence; + // this should also allow for COMMENTs } } @@ -332,6 +334,7 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin $requestStatus = '2.0'; // Finding all the instances the attendee replied to. + $comments = null; foreach ($itipMessage->message->VEVENT as $vevent) { $recurId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getValue() : 'master'; $attendee = $vevent->ATTENDEE; @@ -340,6 +343,9 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin $requestStatus = $vevent->{'REQUEST-STATUS'}->getValue(); list($requestStatus) = explode(';', $requestStatus); } + if(!empty($vevent->{'COMMENT'})) { + $comments = $vevent->{'COMMENT'}; + } } // Now we need to loop through the original organizer event, to find @@ -377,6 +383,12 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin } unset($instances[$recurId]); } + if($comments !== null) { + // as this is 0+, we need a loopdiloop + foreach ($comments as $comment) { + $vevent->add('COMMENT', $comment); + } + } } if (!$masterObject) { @@ -513,6 +525,11 @@ protected function parseEventForOrganizer(VCalendar $calendar, array $eventInfo, if (isset($calendar->VEVENT->SUMMARY)) { $event->add('SUMMARY', $calendar->VEVENT->SUMMARY->getValue()); } + if($eventInfo['comments'] !== null) { + foreach ($eventInfo['comments'] as $comment) { + $event->add('COMMENT', $comment); + } + } $event->add(clone $calendar->VEVENT->DTSTART); if (isset($calendar->VEVENT->DTEND)) { $event->add(clone $calendar->VEVENT->DTEND); @@ -593,6 +610,11 @@ protected function parseEventForOrganizer(VCalendar $calendar, array $eventInfo, } $currentEvent->DTSTAMP = gmdate('Ymd\\THis\\Z'); + if($eventInfo['comments'] !== null) { + foreach ($eventInfo['comments'] as $comment) { + $currentEvent->add('COMMENT', $comment); + } + } $icalMsg->add($currentEvent); } } @@ -710,6 +732,11 @@ protected function parseEventForAttendee(VCalendar $calendar, array $eventInfo, 'SEQUENCE' => $message->sequence, ]); $summary = isset($calendar->VEVENT->SUMMARY) ? $calendar->VEVENT->SUMMARY->getValue() : ''; + if($eventInfo['comments'] !== null) { + foreach ($eventInfo['comments'] as $comment) { + $event->add('COMMENT', $comment); + } + } // Adding properties from the correct source instance if (isset($eventInfo['instances'][$instance['id']])) { $instanceObj = $eventInfo['instances'][$instance['id']]; @@ -790,6 +817,7 @@ protected function parseEventForAttendee(VCalendar $calendar, array $eventInfo, * based on. * 11. significantChangeHash * 12. status + * 13. comments * * @throws ITipException * @throws SameOrganizerForAllComponentsException @@ -804,6 +832,7 @@ protected function parseEventInfo(VCalendar $calendar): array $timezone = null; $status = null; $organizerScheduleAgent = 'SERVER'; + $comments = null; // Now we need to collect a list of attendees, and which instances they // are a part of. @@ -924,6 +953,11 @@ protected function parseEventInfo(VCalendar $calendar): array } $instances[$recurId] = $vevent; } + if(isset($vevent->{'COMMENT'})) { + foreach($vevent->{'COMMENT'} as $comment) { + $comments[] = $comment; + } + } foreach ($this->significantChangeProperties as $prop) { if (isset($vevent->$prop)) { @@ -962,7 +996,8 @@ protected function parseEventInfo(VCalendar $calendar): array 'exdate', 'timezone', 'significantChangeHash', - 'status' + 'status', + 'comments' ); } }