Read and write delegated-from/to attendee parameters

This commit is contained in:
Thomas Bruederli 2014-02-27 23:32:15 +01:00
parent 91bd3fae6d
commit 5602b5f3cd
2 changed files with 30 additions and 2 deletions

View file

@ -43,7 +43,8 @@ class libvcalendar implements Iterator
private $attach_uri = null; private $attach_uri = null;
private $prodid = '-//Roundcube//Roundcube libcalendaring//Sabre//Sabre VObject//EN'; private $prodid = '-//Roundcube//Roundcube libcalendaring//Sabre//Sabre VObject//EN';
private $type_component_map = array('event' => 'VEVENT', 'task' => 'VTODO'); 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 $iteratorkey = 0;
private $charset; private $charset;
private $forward_exceptions; private $forward_exceptions;
@ -710,7 +711,7 @@ class libvcalendar implements Iterator
$out = array(); $out = array();
foreach ($map as $from => $to) { foreach ($map as $from => $to) {
if (isset($values[$from])) if (isset($values[$from]))
$out[$to] = $values[$from]; $out[$to] = is_array($values[$from]) ? join(',', $values[$from]) : $values[$from];
} }
return $out; return $out;
} }

View file

@ -137,6 +137,16 @@ abstract class kolab_format_xcal extends kolab_format
$attendee = $attvec->get($i); $attendee = $attvec->get($i);
$cr = $attendee->contact(); $cr = $attendee->contact();
if ($cr->email() != $object['organizer']['email']) { 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( $object['attendees'][] = array(
'role' => $role_map[$attendee->role()], 'role' => $role_map[$attendee->role()],
'cutype' => $cutype_map[$attendee->cutype()], 'cutype' => $cutype_map[$attendee->cutype()],
@ -144,6 +154,8 @@ abstract class kolab_format_xcal extends kolab_format
'rsvp' => $attendee->rsvp(), 'rsvp' => $attendee->rsvp(),
'email' => $cr->email(), 'email' => $cr->email(),
'name' => $cr->name(), '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->setCutype($this->cutype_map[$attendee['cutype']] ? $this->cutype_map[$attendee['cutype']] : kolabformat::CutypeIndividual);
$att->setRSVP((bool)$attendee['rsvp']); $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()) { if ($att->isValid()) {
$attendees->push($att); $attendees->push($att);
} }