3 commits - plugins/calendar plugins/kolab_delegation plugins/libcalendaring

Thomas Brüderli bruederli at kolabsys.com
Wed Jan 21 17:07:36 CET 2015


 plugins/calendar/drivers/kolab/kolab_calendar.php            |    9 ++
 plugins/calendar/drivers/kolab/kolab_driver.php              |   24 +++++++
 plugins/calendar/drivers/kolab/kolab_invitation_calendar.php |   16 -----
 plugins/calendar/skins/larry/calendar.css                    |    9 ++
 plugins/kolab_delegation/kolab_delegation_engine.php         |    7 ++
 plugins/libcalendaring/libcalendaring.php                    |   35 ++++++-----
 6 files changed, 70 insertions(+), 30 deletions(-)

New commits:
commit 59b64ae7cd5cb8d4c80bfd126926753ee49fa740
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Wed Jan 21 17:05:16 2015 +0100

    Visually emphasize pending/declined events from other user's calendars

diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php
index 404d35c..850a12f 100644
--- a/plugins/calendar/drivers/kolab/kolab_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_calendar.php
@@ -674,6 +674,11 @@ class kolab_calendar extends kolab_storage_folder_api
     $record['calendar'] = $this->id;
     $record['links'] = $this->get_links($record['uid']);
 
+    if ($this->get_namespace() == 'other') {
+      $record['className'] = 'fc-event-ns-other';
+      $record = kolab_driver::add_partstat_class($record, array('NEEDS-ACTION','DECLINED'), $this->get_owner());
+    }
+
     return kolab_driver::to_rcube_event($record);
   }
 
diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index 8720dd8..559931c 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -1422,6 +1422,30 @@ class kolab_driver extends calendar_driver
   }
 
   /**
+   * Set CSS class according to the event's attendde partstat
+   */
+  public static function add_partstat_class($event, $partstats, $user = null)
+  {
+    // set classes according to PARTSTAT
+    if (is_array($event['attendees'])) {
+      $user_emails = libcalendaring::get_instance()->get_user_emails($user);
+      $partstat = 'UNKNOWN';
+      foreach ($event['attendees'] as $attendee) {
+        if (in_array($attendee['email'], $user_emails)) {
+          $partstat = $attendee['status'];
+          break;
+        }
+      }
+
+      if (in_array($partstat, $partstats)) {
+        $event['className'] = trim($event['className'] . ' fc-invitation-' . strtolower($partstat));
+      }
+    }
+
+    return $event;
+  }
+
+  /**
    * Provide a list of revisions for the given event
    *
    * @param array  $event Hash array with event properties
diff --git a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
index a2e9cf2..a78c5a8 100644
--- a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
@@ -276,20 +276,10 @@ class kolab_invitation_calendar
   private function _mod_event($event)
   {
     // set classes according to PARTSTAT
-    if (is_array($event['attendees'])) {
-      $user_emails = $this->cal->get_user_emails();
-      $partstat = 'UNKNOWN';
-      foreach ($event['attendees'] as $attendee) {
-        if (in_array($attendee['email'], $user_emails)) {
-          $partstat = $attendee['status'];
-          break;
-        }
-      }
+    $event = kolab_driver::add_partstat_class($event, $this->partstats);
 
-      if (in_array($partstat, $this->partstats)) {
-        $event['className'] = 'fc-invitation-' . strtolower($partstat);
-        $event['calendar'] = $this->id;
-      }
+    if (strpos($event['className'], 'fc-invitation-') !== false) {
+      $event['calendar'] = $this->id;
     }
 
     return $event;
diff --git a/plugins/calendar/skins/larry/calendar.css b/plugins/calendar/skins/larry/calendar.css
index 052860c..9555031 100644
--- a/plugins/calendar/skins/larry/calendar.css
+++ b/plugins/calendar/skins/larry/calendar.css
@@ -1883,6 +1883,15 @@ a.dropdown-link:after {
 	border: 1px dashed #c00 !important;
 }
 
+.fc-event-vert.fc-event-ns-other.fc-invitation-declined,
+.fc-event-hori.fc-event-ns-other.fc-invitation-declined {
+	opacity: 0.7;
+}
+
+.fc-event-ns-other.fc-invitation-declined .fc-event-title {
+	text-decoration: line-through;
+}
+
 .fc-event-vert.fc-invitation-tentative .fc-event-head,
 .fc-event-vert.fc-invitation-declined .fc-event-head,
 .fc-event-vert.fc-invitation-needs-action .fc-event-head {


commit d9f69d35c7ebbdd0544351db5cbed810ce431072
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Wed Jan 21 16:58:09 2015 +0100

    Allow to provide the context for getting user emails (augmented by kolab_delegation)

diff --git a/plugins/kolab_delegation/kolab_delegation_engine.php b/plugins/kolab_delegation/kolab_delegation_engine.php
index ca4d5b4..be16cf6 100644
--- a/plugins/kolab_delegation/kolab_delegation_engine.php
+++ b/plugins/kolab_delegation/kolab_delegation_engine.php
@@ -743,6 +743,13 @@ class kolab_delegation_engine
     {
         $context = $this->delegator_context();
 
+        // try to derive context from the given user email
+        if (!$context && !empty($args['emails'])) {
+            if (($user = preg_replace('/@.+$/', '', $args['emails'][0])) && isset($_SESSION['delegators'][$user])) {
+                $context = $user;
+            }
+        }
+
         // return delegator's addresses
         if ($context) {
             $args['emails'] = $_SESSION['delegators'][$context];
diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php
index 0384ba0..ec82fdf 100644
--- a/plugins/libcalendaring/libcalendaring.php
+++ b/plugins/libcalendaring/libcalendaring.php
@@ -361,32 +361,37 @@ class libcalendaring extends rcube_plugin
     }
 
     /**
-     * Get a list of email addresses of the current user (from login and identities)
+     * Get a list of email addresses of the given user (from login and identities)
+     *
+     * @param string User Email (default to current user)
+     * @return array Email addresses related to the user
      */
-    public function get_user_emails()
+    public function get_user_emails($user = null)
     {
-        static $emails;
+        static $_emails = array();
+
+        if (empty($user)) {
+            $user = $this->rc->user->get_username();
+        }
 
         // return cached result
-        if (is_array($emails)) {
-            return $emails;
+        if (is_array($_emails[$user])) {
+            return $_emails[$user];
         }
 
-        $emails = array();
+        $emails = array($user);
         $plugin = $this->rc->plugins->exec_hook('calendar_user_emails', array('emails' => $emails));
         $emails = array_map('strtolower', $plugin['emails']);
 
-        if ($plugin['abort']) {
-            return $emails;
-        }
-
-        $emails[] = $this->rc->user->get_username();
-        foreach ($this->rc->user->list_emails() as $identity) {
-            $emails[] = strtolower($identity['email']);
+        // add all emails from the current user's identities
+        if (!$plugin['abort'] && ($user == $this->rc->user->get_username())) {
+            foreach ($this->rc->user->list_emails() as $identity) {
+                $emails[] = strtolower($identity['email']);
+            }
         }
 
-        $emails = array_unique($emails);
-        return $emails;
+        $_emails[$user] = array_unique($emails);
+        return $_emails[$user];
     }
 
     /**


commit d6789046c6bb5575c13616003ffa4734a75f860b
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Wed Jan 21 16:01:12 2015 +0100

    Don't suppress pending/declined events from other user's calendars (#4272)

diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php
index b5c0844..404d35c 100644
--- a/plugins/calendar/drivers/kolab/kolab_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_calendar.php
@@ -237,7 +237,7 @@ class kolab_calendar extends kolab_storage_folder_api
     $query[] = array('dtend',   '>=', $start);
 
     // add query to exclude pending/declined invitations
-    if (empty($filter_query)) {
+    if (empty($filter_query) && $this->get_namespace() != 'other') {
       foreach ($user_emails as $email) {
         $query[] = array('tags', '!=', 'x-partstat:' . $email . ':needs-action');
         $query[] = array('tags', '!=', 'x-partstat:' . $email . ':declined');
@@ -257,7 +257,7 @@ class kolab_calendar extends kolab_storage_folder_api
     $events = array();
     foreach ($this->storage->select($query) as $record) {
       // post-filter events to skip pending and declined invitations
-      if (empty($filter_query) && is_array($record['attendees'])) {
+      if (empty($filter_query) && is_array($record['attendees']) && $this->get_namespace() != 'other') {
         foreach ($record['attendees'] as $attendee) {
           if (in_array($attendee['email'], $user_emails) && in_array($attendee['status'], array('NEEDS-ACTION','DECLINED'))) {
             continue 2;




More information about the commits mailing list