Branch 'roundcubemail-plugins-kolab-format2-horde5' - plugins/calendar

Thomas Brüderli bruederli at kolabsys.com
Fri May 3 10:54:27 CEST 2013


 plugins/calendar/calendar.php   |   20 ++++++++++----------
 plugins/calendar/calendar_ui.js |   10 +++++-----
 2 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit 59aff827c42e2247f350e71ff7c4d51141f0aec9
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Fri May 3 10:41:26 2013 +0200

    Do case-insensitive checks whether the current user is an event attendee or organizer (#1838)

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index d1f2617..fcfe909 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -671,7 +671,7 @@ class calendar extends rcube_plugin
           foreach ($old['attendees'] as $i => $attendee) {
             if ($attendee['role'] == 'ORGANIZER')
               $organizer = $attendee;
-            else if ($attendee['email'] && in_array($attendee['email'], $emails)) {
+            else if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
               $old['attendees'][$i]['status'] = 'DECLINED';
             }
           }
@@ -708,7 +708,7 @@ class calendar extends rcube_plugin
         if ($existing = $this->driver->get_event($event, true, false, true)) {
           $emails = $this->get_user_emails();
           foreach ($existing['attendees'] as $i => $attendee) {
-            if ($attendee['email'] && in_array($attendee['email'], $emails)) {
+            if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
               $status = $attendee['status'];
               break;
             }
@@ -1059,7 +1059,7 @@ class calendar extends rcube_plugin
         $identity['emails'][] = $rec['email'];
       }
       $identity['emails'][] = $this->rc->user->get_username();
-      $settings['identity'] = array('name' => $identity['name'], 'email' => $identity['email'], 'emails' => ';' . join(';', $identity['emails']));
+      $settings['identity'] = array('name' => $identity['name'], 'email' => strtolower($identity['email']), 'emails' => ';' . strtolower(join(';', $identity['emails'])));
     }
 
     return $settings;
@@ -1283,7 +1283,7 @@ class calendar extends rcube_plugin
       foreach ($event['attendees'] as $i => $attendee) {
         if ($attendee['role'] == 'ORGANIZER')
           $organizer = true;
-        if ($attendee['email'] == in_array($attendee['email'], $emails))
+        if ($attendee['email'] == in_array(strtolower($attendee['email']), $emails))
           $owner = $i;
         else if (!isset($attendee['rsvp']))
           $event['attendees'][$i]['rsvp'] = true;
@@ -1339,7 +1339,7 @@ class calendar extends rcube_plugin
     $sent = 0;
     foreach ((array)$event['attendees'] as $attendee) {
       // skip myself for obvious reasons
-      if (!$attendee['email'] || in_array($attendee['email'], $emails))
+      if (!$attendee['email'] || in_array(strtolower($attendee['email']), $emails))
         continue;
       
       // which template to use for mail text
@@ -1728,7 +1728,7 @@ class calendar extends rcube_plugin
           // check my status
           $status = 'unknown';
           foreach ($event['attendees'] as $i => $attendee) {
-            if ($attendee['email'] && in_array($attendee['email'], $emails)) {
+            if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
               $status = strtoupper($attendee['status']);
               break;
             }
@@ -1837,7 +1837,7 @@ class calendar extends rcube_plugin
           if ($attendee['role'] == 'ORGANIZER') {
             $organizer = $attendee;
           }
-          else if ($attendee['email'] && in_array($attendee['email'], $emails)) {
+          else if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
             $event['attendees'][$i]['status'] = strtoupper($status);
           }
         }
@@ -1923,7 +1923,7 @@ class calendar extends rcube_plugin
 
 
     // send iTip reply
-    if ($this->ical->method == 'REQUEST' && $organizer && !in_array($organizer['email'], $emails) && !$error_msg) {
+    if ($this->ical->method == 'REQUEST' && $organizer && !in_array(strtolower($organizer['email']), $emails) && !$error_msg) {
       $itip = $this->load_itip();
       if ($itip->send_itip_message($event, 'REPLY', $organizer, 'itipsubject' . $status, 'itipmailbody' . $status))
         $this->rc->output->command('display_message', $this->gettext(array('name' => 'sentresponseto', 'vars' => array('mailto' => $organizer['name'] ? $organizer['name'] : $organizer['email']))), 'confirmation');
@@ -2018,9 +2018,9 @@ class calendar extends rcube_plugin
    */
   private function get_user_emails()
   {
-    $emails = array($this->rc->user->get_username());
+    $emails = array(strtolower($this->rc->user->get_username()));
     foreach ($this->rc->user->list_identities() as $identity)
-      $emails[] = $identity['email'];
+      $emails[] = strtolower($identity['email']);
     
     return array_unique($emails);
   }
diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js
index caf6142..ec1bd4f 100644
--- a/plugins/calendar/calendar_ui.js
+++ b/plugins/calendar/calendar_ui.js
@@ -166,15 +166,15 @@ function rcube_calendar_ui(settings)
     // check if the event has 'real' attendees, excluding the current user
     var has_attendees = function(event)
     {
-      return (event.attendees && event.attendees.length && (event.attendees.length > 1 || event.attendees[0].email != settings.identity.email));
+      return (event.attendees && event.attendees.length && (event.attendees.length > 1 || String(event.attendees[0].email).toLowerCase() != settings.identity.email));
     };
     
     // check if the current user is an attendee of this event
     var is_attendee = function(event, role, email)
     {
-      var emails = email ? ';'+email : settings.identity.emails;
+      var emails = email ? ';'+email.toLowerCase() : settings.identity.emails;
       for (var i=0; event.attendees && i < event.attendees.length; i++) {
-        if ((!role || event.attendees[i].role == role) && event.attendees[i].email && emails.indexOf(';'+event.attendees[i].email) >= 0)
+        if ((!role || event.attendees[i].role == role) && event.attendees[i].email && emails.indexOf(';'+event.attendees[i].email.toLowerCase()) >= 0)
           return true;
       }
       return false;
@@ -617,7 +617,7 @@ function rcube_calendar_ui(settings)
         });
         
         // don't submit attendees if only myself is added as organizer
-        if (data.attendees.length == 1 && data.attendees[0].role == 'ORGANIZER' && data.attendees[0].email == settings.identity.email)
+        if (data.attendees.length == 1 && data.attendees[0].role == 'ORGANIZER' && String(data.attendees[0].email).toLowerCase() == settings.identity.email)
           data.attendees = [];
         
         // tell server to send notifications
@@ -1497,7 +1497,7 @@ function rcube_calendar_ui(settings)
         // update attendee status
         for (var data, i=0; i < me.selected_event.attendees.length; i++) {
           data = me.selected_event.attendees[i];
-          if (settings.identity.emails.indexOf(';'+data.email) >= 0)
+          if (settings.identity.emails.indexOf(';'+String(data.email).toLowerCase()) >= 0)
             data.status = response.toUpperCase();
         }
         event_show_dialog(me.selected_event);





More information about the commits mailing list