summaryrefslogtreecommitdiff
path: root/plugins/libcalendaring
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-11-06 14:14:44 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-11-06 16:09:59 (GMT)
commit7294ef8be0594ec32476ba49a34282675919f38b (patch)
tree0df79e580221fbff482c1dd2c370b440ffabceae /plugins/libcalendaring
parentf01a600af44057dc2310c8df3982da35ec1d8252 (diff)
downloadroundcubemail-plugins-kolab-7294ef8be0594ec32476ba49a34282675919f38b.tar.gz
Send delegate attendee in iTip reply (as suggested in RFC 5546) + add it to organizers calendar/tasklist
Diffstat (limited to 'plugins/libcalendaring')
-rw-r--r--plugins/libcalendaring/lib/libcalendaring_itip.php23
-rw-r--r--plugins/libcalendaring/libcalendaring.php14
2 files changed, 29 insertions, 8 deletions
diff --git a/plugins/libcalendaring/lib/libcalendaring_itip.php b/plugins/libcalendaring/lib/libcalendaring_itip.php
index 9403f46..9524249 100644
--- a/plugins/libcalendaring/lib/libcalendaring_itip.php
+++ b/plugins/libcalendaring/lib/libcalendaring_itip.php
@@ -197,24 +197,34 @@ class libcalendaring_itip
public function compose_itip_message($event, $method)
{
$from = rcube_idn_to_ascii($this->sender['email']);
- $from_utf = rcube_idn_to_utf8($from);
+ $from_utf = rcube_utils::idn_to_utf8($from);
$sender = format_email_recipient($from, $this->sender['name']);
// truncate list attendees down to the recipient of the iTip Reply.
// constraints for a METHOD:REPLY according to RFC 5546
if ($method == 'REPLY') {
- $replying_attendee = null; $reply_attendees = array();
+ $replying_attendee = null;
+ $reply_attendees = array();
foreach ($event['attendees'] as $attendee) {
if ($attendee['role'] == 'ORGANIZER') {
$reply_attendees[] = $attendee;
}
- else if (strcasecmp($attedee['email'], $from) == 0 || strcasecmp($attendee['email'], $from_utf) == 0) {
+ else if (strcasecmp($attendee['email'], $from) == 0 || strcasecmp($attendee['email'], $from_utf) == 0) {
$replying_attendee = $attendee;
- unset($replying_attendee['rsvp']); // unset the RSVP attribute
+ if ($attendee['status'] != 'DELEGATED') {
+ unset($replying_attendee['rsvp']); // unset the RSVP attribute
+ }
+ }
+ // include attendees relevant for delegation (RFC 5546, Section 4.2.5)
+ else if ((!empty($attendee['delegated-to']) &&
+ (strcasecmp($attendee['delegated-to'], $from) == 0 || strcasecmp($attendee['delegated-to'], $from_utf) == 0)) ||
+ (!empty($attendee['delegated-from']) &&
+ (strcasecmp($attendee['delegated-from'], $from) == 0 || strcasecmp($attendee['delegated-from'], $from_utf) == 0))) {
+ $reply_attendees[] = $attendee;
}
}
if ($replying_attendee) {
- $reply_attendees[] = $replying_attendee;
+ array_unshift($reply_attendees, $replying_attendee);
$event['attendees'] = $reply_attendees;
}
}
@@ -454,7 +464,8 @@ class libcalendaring_itip
$title = $this->gettext('itipreply');
foreach ($event['attendees'] as $attendee) {
- if (!empty($attendee['email']) && $attendee['role'] != 'ORGANIZER') {
+ if (!empty($attendee['email']) && $attendee['role'] != 'ORGANIZER' &&
+ (empty($event['_sender']) || ($attendee['email'] == $event['_sender'] || $attendee['email'] == $event['_sender_utf']))) {
$metadata['attendee'] = $attendee['email'];
$rsvp_status = strtoupper($attendee['status']);
if ($attendee['delegated-to'])
diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php
index 6e61add..78eaa24 100644
--- a/plugins/libcalendaring/libcalendaring.php
+++ b/plugins/libcalendaring/libcalendaring.php
@@ -59,6 +59,7 @@ class libcalendaring extends rcube_plugin
);
private static $instance;
+ private static $email_regex = '/([a-z0-9][a-z0-9\-\.\+\_]*@[^&@"\'.][^@&"\']*\\.([^\\x00-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-z0-9]{2,}))/';
private $mail_ical_parser;
@@ -1287,6 +1288,15 @@ class libcalendaring extends rcube_plugin
if (count($this->mail_ical_parser->objects) && $this->mail_ical_parser->method) {
$this->mail_ical_parser->message_date = $this->ical_message->headers->date;
$this->mail_ical_parser->mime_id = $mime_id;
+
+ // store the message's sender address for comparisons
+ $this->mail_ical_parser->sender = preg_match(self::$email_regex, $this->ical_message->headers->from, $m) ? $m[1] : '';
+ if (!empty($this->mail_ical_parser->sender)) {
+ foreach ($this->mail_ical_parser->objects as $i => $object) {
+ $this->mail_ical_parser->objects[$i]['_sender'] = $this->mail_ical_parser->sender;
+ $this->mail_ical_parser->objects[$i]['_sender_utf'] = rcube_utils::idn_to_utf8($this->mail_ical_parser->sender);
+ }
+ }
break;
}
}
@@ -1335,8 +1345,8 @@ class libcalendaring extends rcube_plugin
$object['_method'] = $parser->method;
// store the message's sender address for comparisons
- $object['_sender'] = preg_match('/([a-z0-9][a-z0-9\-\.\+\_]*@[^&@"\'.][^@&"\']*\\.([^\\x00-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-z0-9]{2,}))/', $headers->from, $m) ? $m[1] : '';
- $object['_sender_utf'] = rcube_idn_to_utf8($object['_sender']);
+ $object['_sender'] = preg_match(self::$email_regex, $headers->from, $m) ? $m[1] : '';
+ $object['_sender_utf'] = rcube_utils::idn_to_utf8($object['_sender']);
return $object;
}