Fix handling of RSVP flags
This commit is contained in:
parent
7294ef8be0
commit
c6f5a8233b
5 changed files with 55 additions and 16 deletions
|
@ -1642,7 +1642,9 @@ class calendar extends rcube_plugin
|
|||
foreach ((array)$event['attendees'] as $i => $attendee) {
|
||||
if ($attendee['role'] == 'ORGANIZER') {
|
||||
$organizer = $attendee;
|
||||
break;
|
||||
}
|
||||
if ($attendee['status'] == 'DELEGATED' && $attendee['rsvp'] == false) {
|
||||
$event['attendees'][$i]['noreply'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1895,7 +1897,7 @@ class calendar extends rcube_plugin
|
|||
|
||||
// compose multipart message using PEAR:Mail_Mime
|
||||
$method = $action == 'remove' ? 'CANCEL' : 'REQUEST';
|
||||
$message = $itip->compose_itip_message($event, $method);
|
||||
$message = $itip->compose_itip_message($event, $method, $event['sequence'] > $old['sequence']);
|
||||
|
||||
// list existing attendees from $old event
|
||||
$old_attendees = array();
|
||||
|
@ -1915,7 +1917,11 @@ class calendar extends rcube_plugin
|
|||
// skip if notification is disabled for this attendee
|
||||
if ($attendee['noreply'] && $itip_notify & 2)
|
||||
continue;
|
||||
|
||||
|
||||
// skip if this attendee has delegated and set RSVP=FALSE
|
||||
if ($attendee['status'] == 'DELEGATED' && $attendee['rsvp'] === false)
|
||||
continue;
|
||||
|
||||
// which template to use for mail text
|
||||
$is_new = !in_array($attendee['email'], $old_attendees);
|
||||
$is_rsvp = $is_new || $event['sequence'] > $old['sequence'];
|
||||
|
@ -2639,7 +2645,8 @@ class calendar extends rcube_plugin
|
|||
else if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
|
||||
$event['attendees'][$i]['status'] = strtoupper($status);
|
||||
if (!in_array($event['attendees'][$i]['status'], array('NEEDS-ACTION','DELEGATED')))
|
||||
unset($event['attendees'][$i]['rsvp']); // remove RSVP attribute
|
||||
$event['attendees'][$i]['rsvp'] = false; // unset RSVP attribute
|
||||
|
||||
$metadata['attendee'] = $attendee['email'];
|
||||
$metadata['rsvp'] = $attendee['role'] != 'NON-PARTICIPANT';
|
||||
$reply_sender = $attendee['email'];
|
||||
|
@ -2696,7 +2703,17 @@ class calendar extends rcube_plugin
|
|||
$existing['attendees'][] = $attendee;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if delegatee has declined, set delegator's RSVP=True
|
||||
if ($event_attendee && $event_attendee['status'] == 'DECLINED' && $event_attendee['delegated-from']) {
|
||||
foreach ($existing['attendees'] as $i => $attendee) {
|
||||
if ($attendee['email'] == $event_attendee['delegated-from']) {
|
||||
$existing['attendees'][$i]['rsvp'] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// found matching attendee entry in both existing and new events
|
||||
if ($existing_attendee >= 0 && $event_attendee) {
|
||||
$existing['attendees'][$existing_attendee] = $event_attendee;
|
||||
|
|
|
@ -90,6 +90,7 @@ class libcalendaring_itip
|
|||
* @param string Mail subject
|
||||
* @param string Mail body text label
|
||||
* @param object Mail_mime object with message data
|
||||
* @param boolean Request RSVP
|
||||
* @return boolean True on success, false on failure
|
||||
*/
|
||||
public function send_itip_message($event, $method, $recipient, $subject, $bodytext, $message = null, $rsvp = true)
|
||||
|
@ -98,7 +99,7 @@ class libcalendaring_itip
|
|||
$this->sender['name'] = $this->sender['email'];
|
||||
|
||||
if (!$message)
|
||||
$message = $this->compose_itip_message($event, $method);
|
||||
$message = $this->compose_itip_message($event, $method, $rsvp);
|
||||
|
||||
$mailto = rcube_idn_to_ascii($recipient['email']);
|
||||
|
||||
|
@ -192,9 +193,10 @@ class libcalendaring_itip
|
|||
*
|
||||
* @param array Event object to send
|
||||
* @param string iTip method (REQUEST|REPLY|CANCEL)
|
||||
* @param boolean Request RSVP
|
||||
* @return object Mail_mime object with message data
|
||||
*/
|
||||
public function compose_itip_message($event, $method)
|
||||
public function compose_itip_message($event, $method, $rsvp = true)
|
||||
{
|
||||
$from = rcube_idn_to_ascii($this->sender['email']);
|
||||
$from_utf = rcube_utils::idn_to_utf8($from);
|
||||
|
@ -228,11 +230,11 @@ class libcalendaring_itip
|
|||
$event['attendees'] = $reply_attendees;
|
||||
}
|
||||
}
|
||||
// set RSVP=TRUE for every attendee if not set
|
||||
// set RSVP for every attendee
|
||||
else if ($method == 'REQUEST') {
|
||||
foreach ($event['attendees'] as $i => $attendee) {
|
||||
if (!isset($attendee['rsvp'])) {
|
||||
$event['attendees'][$i]['rsvp']= true;
|
||||
if ($attendee['status'] != 'DELEGATED') {
|
||||
$event['attendees'][$i]['rsvp']= $rsvp ? true : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1072,7 +1072,8 @@ class libvcalendar implements Iterator
|
|||
$event['organizer'] = $attendee;
|
||||
}
|
||||
else if (!empty($attendee['email'])) {
|
||||
$attendee['rsvp'] = $attendee['rsvp'] ? 'TRUE' : null;
|
||||
if (isset($attendee['rsvp']))
|
||||
$attendee['rsvp'] = $attendee['rsvp'] ? 'TRUE' : 'FALSE';
|
||||
$ve->add('ATTENDEE', 'mailto:' . $attendee['email'], array_filter(self::map_keys($attendee, $this->attendee_keymap)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -364,14 +364,17 @@ abstract class kolab_format_xcal extends kolab_format
|
|||
$cr = new ContactReference(ContactReference::EmailReference, $attendee['email']);
|
||||
$cr->setName($attendee['name']);
|
||||
|
||||
// set attendee RSVP if missing
|
||||
if (!isset($attendee['rsvp'])) {
|
||||
$object['attendees'][$i]['rsvp'] = $attendee['rsvp'] = true;
|
||||
}
|
||||
|
||||
$att = new Attendee;
|
||||
$att->setContact($cr);
|
||||
$att->setPartStat($this->part_status_map[$attendee['status']]);
|
||||
$att->setRole($this->role_map[$attendee['role']] ? $this->role_map[$attendee['role']] : kolabformat::Required);
|
||||
$att->setCutype($this->cutype_map[$attendee['cutype']] ? $this->cutype_map[$attendee['cutype']] : kolabformat::CutypeIndividual);
|
||||
$att->setRSVP((bool)$attendee['rsvp'] || $reschedule);
|
||||
|
||||
$object['attendees'][$i]['rsvp'] = $attendee['rsvp'] || $reschedule;
|
||||
$att->setRSVP((bool)$attendee['rsvp']);
|
||||
|
||||
if (!empty($attendee['delegated-from'])) {
|
||||
$vdelegators = new vectorcontactref;
|
||||
|
|
|
@ -757,7 +757,7 @@ class tasklist extends rcube_plugin
|
|||
// compose multipart message using PEAR:Mail_Mime
|
||||
$method = $action == 'delete' ? 'CANCEL' : 'REQUEST';
|
||||
$object = $this->to_libcal($task);
|
||||
$message = $itip->compose_itip_message($object, $method);
|
||||
$message = $itip->compose_itip_message($object, $method, $task['sequence'] > $old['sequence']);
|
||||
|
||||
// list existing attendees from the $old task
|
||||
$old_attendees = array();
|
||||
|
@ -779,6 +779,12 @@ class tasklist extends rcube_plugin
|
|||
if ($attendee['noreply'] && $itip_notify & 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip if this attendee has delegated and set RSVP=FALSE
|
||||
if ($attendee['status'] == 'DELEGATED' && $attendee['rsvp'] === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// which template to use for mail text
|
||||
$is_new = !in_array($attendee['email'], $old_attendees);
|
||||
$is_rsvp = $is_new || $task['sequence'] > $old['sequence'];
|
||||
|
@ -1776,7 +1782,7 @@ class tasklist extends rcube_plugin
|
|||
|
||||
$task['attendees'][$i]['status'] = strtoupper($status);
|
||||
if (!in_array($task['attendees'][$i]['status'], array('NEEDS-ACTION','DELEGATED'))) {
|
||||
unset($task['attendees'][$i]['rsvp']); // remove RSVP attribute
|
||||
$task['attendees'][$i]['rsvp'] = false; // unset RSVP attribute
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1833,6 +1839,16 @@ class tasklist extends rcube_plugin
|
|||
}
|
||||
}
|
||||
|
||||
// if delegatee has declined, set delegator's RSVP=True
|
||||
if ($task_attendee && $task_attendee['status'] == 'DECLINED' && $task_attendee['delegated-from']) {
|
||||
foreach ($existing['attendees'] as $i => $attendee) {
|
||||
if ($attendee['email'] == $task_attendee['delegated-from']) {
|
||||
$existing['attendees'][$i]['rsvp'] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// found matching attendee entry in both existing and new events
|
||||
if ($existing_attendee >= 0 && $task_attendee) {
|
||||
$existing['attendees'][$existing_attendee] = $task_attendee;
|
||||
|
|
Loading…
Add table
Reference in a new issue