Fix bug where delegatee would be lost on task/event update (#5058)
Summary: Fixes #5058 Reviewers: #roundcube_kolab_plugins_developers, vanmeeuwen Reviewed By: #roundcube_kolab_plugins_developers, vanmeeuwen Differential Revision: https://git.kolab.org/D110
This commit is contained in:
parent
faeeb8aafb
commit
55816351cb
3 changed files with 50 additions and 22 deletions
|
@ -2988,17 +2988,7 @@ class calendar extends rcube_plugin
|
|||
|
||||
// preserve my participant status for regular updates
|
||||
if (empty($status)) {
|
||||
$emails = $this->get_user_emails();
|
||||
foreach ($event['attendees'] as $i => $attendee) {
|
||||
if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
|
||||
foreach ($existing['attendees'] as $j => $_attendee) {
|
||||
if ($attendee['email'] == $_attendee['email']) {
|
||||
$event['attendees'][$i] = $existing['attendees'][$j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->lib->merge_attendees($event, $existing);
|
||||
}
|
||||
|
||||
// set status=CANCELLED on CANCEL messages
|
||||
|
|
|
@ -1537,6 +1537,54 @@ class libcalendaring extends rcube_plugin
|
|||
$this->rc->output->command('plugin.expand_attendee_callback', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge attendees of the old and new event version
|
||||
* with keeping current user and his delegatees status
|
||||
*
|
||||
* @param array &$new New object data
|
||||
* @param array $old Old object data
|
||||
*/
|
||||
public function merge_attendees(&$new, $old)
|
||||
{
|
||||
$emails = $this->get_user_emails();
|
||||
$delegates = array();
|
||||
$attendees = array();
|
||||
|
||||
// keep attendee status of the current user
|
||||
foreach ((array) $new['attendees'] as $i => $attendee) {
|
||||
if (empty($attendee['email'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$attendees[] = $email = strtolower($attendee['email']);
|
||||
|
||||
if (in_array($email, $emails)) {
|
||||
foreach ($old['attendees'] as $_attendee) {
|
||||
if ($attendee['email'] == $_attendee['email']) {
|
||||
$new['attendees'][$i] = $_attendee;
|
||||
if ($_attendee['status'] == 'DELEGATED' && ($email = $_attendee['delegated-to'])) {
|
||||
$delegates[] = strtolower($email);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure delegated attendee is not lost
|
||||
foreach ($delegates as $delegatee) {
|
||||
if (!in_array($delegatee, $attendees)) {
|
||||
foreach ((array) $old['attendees'] as $attendee) {
|
||||
if ($attendee['email'] && ($email = strtolower($attendee['email'])) && $email == $delegatee) {
|
||||
$new['attendees'][] = $attendee;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/********* Static utility functions *********/
|
||||
|
||||
|
|
|
@ -2066,17 +2066,7 @@ class tasklist extends rcube_plugin
|
|||
|
||||
// preserve my participant status for regular updates
|
||||
if (empty($status)) {
|
||||
$emails = $this->lib->get_user_emails();
|
||||
foreach ($task['attendees'] as $i => $attendee) {
|
||||
if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
|
||||
foreach ($existing['attendees'] as $j => $_attendee) {
|
||||
if ($attendee['email'] == $_attendee['email']) {
|
||||
$task['attendees'][$i] = $existing['attendees'][$j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->lib->merge_attendees($task, $existing);
|
||||
}
|
||||
|
||||
// set status=CANCELLED on CANCEL messages
|
||||
|
|
Loading…
Add table
Reference in a new issue