From 5602b5f3cde04fbae98a3db627ec719dac4f1417 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Thu, 27 Feb 2014 23:32:15 +0100 Subject: [PATCH] Read and write delegated-from/to attendee parameters --- plugins/libcalendaring/libvcalendar.php | 5 ++-- plugins/libkolab/lib/kolab_format_xcal.php | 27 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/plugins/libcalendaring/libvcalendar.php b/plugins/libcalendaring/libvcalendar.php index 52aa7122..369f08a5 100644 --- a/plugins/libcalendaring/libvcalendar.php +++ b/plugins/libcalendaring/libvcalendar.php @@ -43,7 +43,8 @@ class libvcalendar implements Iterator private $attach_uri = null; private $prodid = '-//Roundcube//Roundcube libcalendaring//Sabre//Sabre VObject//EN'; private $type_component_map = array('event' => 'VEVENT', 'task' => 'VTODO'); - private $attendee_keymap = array('name' => 'CN', 'status' => 'PARTSTAT', 'role' => 'ROLE', 'cutype' => 'CUTYPE', 'rsvp' => 'RSVP'); + private $attendee_keymap = array('name' => 'CN', 'status' => 'PARTSTAT', 'role' => 'ROLE', + 'cutype' => 'CUTYPE', 'rsvp' => 'RSVP', 'delegated-from' => 'DELEGATED-FROM', 'delegated-to' => 'DELEGATED-TO'); private $iteratorkey = 0; private $charset; private $forward_exceptions; @@ -710,7 +711,7 @@ class libvcalendar implements Iterator $out = array(); foreach ($map as $from => $to) { if (isset($values[$from])) - $out[$to] = $values[$from]; + $out[$to] = is_array($values[$from]) ? join(',', $values[$from]) : $values[$from]; } return $out; } diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php index 500dfa21..979aeef7 100644 --- a/plugins/libkolab/lib/kolab_format_xcal.php +++ b/plugins/libkolab/lib/kolab_format_xcal.php @@ -137,6 +137,16 @@ abstract class kolab_format_xcal extends kolab_format $attendee = $attvec->get($i); $cr = $attendee->contact(); if ($cr->email() != $object['organizer']['email']) { + $delegators = $delegatees = array(); + $vdelegators = $attendee->delegatedFrom(); + for ($j=0; $j < $vdelegators->size(); $j++) { + $delegators[] = $vdelegators->get($j)->email(); + } + $vdelegatees = $attendee->delegatedTo(); + for ($j=0; $j < $vdelegatees->size(); $j++) { + $delegatees[] = $vdelegatees->get($j)->email(); + } + $object['attendees'][] = array( 'role' => $role_map[$attendee->role()], 'cutype' => $cutype_map[$attendee->cutype()], @@ -144,6 +154,8 @@ abstract class kolab_format_xcal extends kolab_format 'rsvp' => $attendee->rsvp(), 'email' => $cr->email(), 'name' => $cr->name(), + 'delegated-from' => $delegators, + 'delegated-to' => $delegatees, ); } } @@ -287,6 +299,21 @@ abstract class kolab_format_xcal extends kolab_format $att->setCutype($this->cutype_map[$attendee['cutype']] ? $this->cutype_map[$attendee['cutype']] : kolabformat::CutypeIndividual); $att->setRSVP((bool)$attendee['rsvp']); + if (!empty($attendee['delegated-from'])) { + $vdelegators = new vectorcontactref; + foreach ((array)$attendee['delegated-from'] as $delegator) { + $vdelegators->push(new ContactReference(ContactReference::EmailReference, $delegator)); + } + $att->setDelegatedFrom($vdelegators); + } + if (!empty($attendee['delegated-to'])) { + $vdelegatees = new vectorcontactref; + foreach ((array)$attendee['delegated-to'] as $delegatee) { + $vdelegatees->push(new ContactReference(ContactReference::EmailReference, $delegatee)); + } + $att->setDelegatedTo($vdelegatees); + } + if ($att->isValid()) { $attendees->push($att); }