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

Broker properly handles iTip containing only an updated occurrence. F… #366

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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: 32 additions & 5 deletions lib/ITip/Broker.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,43 @@ protected function processMessageRequest(Message $itipMessage, VCalendar $existi
$existingObject->add(clone $component);
}
} else {
// We need to update an existing object with all the new
// information. We can just remove all existing components
// and create new ones.
// We need to update an existing object with all the new information.
// We start by removing all non-VEVENT components (VTIMEZONE, etc.)
foreach ($existingObject->getComponents() as $component) {
$existingObject->remove($component);
if ($component->name !== 'VEVENT') {
$existingObject->remove($component);
Copy link
Member

Choose a reason for hiding this comment

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

Wondering out loud: is this needed? Should we get rid of VTIMEZONE ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I wondered too while reading the code.
Previously VTIMEZONE components were also removed, and added back from the iTip.

I'm fine reworking this to only remove and add VEVENT components. Let me know

}
}

// Then we search for a master event in the iTip, if we find it we remove all VEVENT from the original
// calendar object, as we will later add new components from the iTip
foreach ($itipMessage->message->select('VEVENT') as $vEvent) {
if (!isset($vEvent->{'RECURRENCE-ID'})) {
$existingObject->remove('VEVENT');
}
}

// Then we iterate over the iTip to add new or updated components to the original calendar object
foreach ($itipMessage->message->getComponents() as $component) {
$existingObject->add(clone $component);
if ($component->name !== 'VEVENT') {
$existingObject->add(clone $component);
} else {
// It's an exception to a recurring event, we try to find it in the original event to remove it
if (isset($component->{'RECURRENCE-ID'})) {
foreach ($existingObject->select('VEVENT') as $vEvent) {
if (isset($vEvent->{'RECURRENCE-ID'}) && ($vEvent->{'RECURRENCE-ID'}->getDateTime() == $component->{'RECURRENCE-ID'}->getDateTime())) {
$existingObject->remove($vEvent);

break;
}
}
}

$existingObject->add(clone $component);
}
}
}

return $existingObject;

}
Expand Down