Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for COMMENT property #593

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion lib/ITip/Broker.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class Broker
'RDATE',
'EXDATE',
'STATUS',
'COMMENT'
];

/**
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -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'};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get the value? or use clone?

}
}

// Now we need to loop through the original organizer event, to find
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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']];
Expand Down Expand Up @@ -790,6 +817,7 @@ protected function parseEventForAttendee(VCalendar $calendar, array $eventInfo,
* based on.
* 11. significantChangeHash
* 12. status
* 13. comments
*
* @throws ITipException
* @throws SameOrganizerForAllComponentsException
Expand All @@ -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.
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -962,7 +996,8 @@ protected function parseEventInfo(VCalendar $calendar): array
'exdate',
'timezone',
'significantChangeHash',
'status'
'status',
'comments'
);
}
}