plugins/calendar plugins/kolab_folders plugins/tasklist

Thomas Brüderli bruederli at kolabsys.com
Wed Mar 25 15:09:15 CET 2015


 plugins/calendar/calendar.php                   |   22 +++++++---------
 plugins/calendar/drivers/kolab/kolab_driver.php |   10 ++++++-
 plugins/kolab_folders/kolab_folders.php         |    4 +--
 plugins/kolab_folders/localization/en_US.inc    |    3 +-
 plugins/tasklist/tasklist.php                   |   32 ++++++++++--------------
 5 files changed, 36 insertions(+), 35 deletions(-)

New commits:
commit 7fec791449579350ee3ed6b5b0747edee546e147
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Wed Mar 25 15:09:04 2015 +0100

    Select folders annotated 'private' for events/tasks flagged as such (#4789)

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 81ca66e..17a3db5 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -260,23 +260,21 @@ class calendar extends rcube_plugin
   /**
    * Get properties of the calendar this user has specified as default
    */
-  public function get_default_calendar($writeable = false, $confidential = false)
+  public function get_default_calendar($sensitivity = null)
   {
     $default_id = $this->rc->config->get('calendar_default_calendar');
-    $calendars = $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL);
+    $calendars = $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL | calendar_driver::FILTER_WRITEABLE);
     $calendar = $calendars[$default_id] ?: null;
-    if (!$calendar || $confidential || ($writeable && !$calendar['editable'])) {
+    if (!$calendar || $sensitivity) {
       foreach ($calendars as $cal) {
-        if ($confidential && $cal['subtype'] == 'confidential') {
+        if ($sensitivity && $cal['subtype'] == $sensitivity) {
           $calendar = $cal;
           break;
         }
-        if ($cal['default']) {
+        if ($cal['default'] && $cal['editable']) {
           $calendar = $cal;
-          if (!$confidential)
-            break;
         }
-        if (!$writeable || $cal['editable']) {
+        if ($cal['editable']) {
           $first = $cal;
         }
       }
@@ -2473,7 +2471,7 @@ class calendar extends rcube_plugin
     }
 
     if ($calendar_select) {
-      $default_calendar = $this->get_default_calendar(true, $data['sensitivity'] == 'confidential');
+      $default_calendar = $this->get_default_calendar($data['sensitivity']);
       $response['select'] = html::span('folder-select', $this->gettext('saveincalendar') . ' ' .
         $calendar_select->show($default_calendar['id']));
     }
@@ -2587,7 +2585,7 @@ class calendar extends rcube_plugin
             $invitation = $itip->get_invitation($token);
 
             // save the event to his/her default calendar if not yet present
-            if (!$this->driver->get_event($this->event) && ($calendar = $this->get_default_calendar(true, $invitation['event']['sensitivity'] == 'confidential'))) {
+            if (!$this->driver->get_event($this->event) && ($calendar = $this->get_default_calendar($invitation['event']['sensitivity']))) {
               $invitation['event']['calendar'] = $calendar['id'];
               if ($this->driver->new_event($invitation['event']))
                 $this->rc->output->command('display_message', $this->gettext(array('name' => 'importedsuccessfully', 'vars' => array('calendar' => $calendar['name']))), 'confirmation');
@@ -2798,7 +2796,7 @@ class calendar extends rcube_plugin
 
       // select default calendar except user explicitly selected 'none'
       if (!$calendar && !$dontsave)
-         $calendar = $this->get_default_calendar(true, $event['sensitivity'] == 'confidential');
+         $calendar = $this->get_default_calendar($event['sensitivity']);
 
       $metadata = array(
         'uid' => $event['uid'],
@@ -3110,7 +3108,7 @@ class calendar extends rcube_plugin
 
       foreach ($events as $event) {
         // save to calendar
-        $calendar = $calendars[$cal_id] ?: $this->get_default_calendar(true, $event['sensitivity'] == 'confidential');
+        $calendar = $calendars[$cal_id] ?: $this->get_default_calendar($event['sensitivity']);
         if ($calendar && $calendar['editable'] && $event['_type'] == 'event') {
           $event['calendar'] = $calendar['id'];
 
diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index 2c0869e..d4f9a19 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -294,10 +294,10 @@ class kolab_driver extends calendar_driver
       'list'      => $this->calendars,
       'calendars' => $calendars,
       'filter'    => $filter,
-      'editable' => ($filter & self::FILTER_WRITEABLE),
+      'editable'  => ($filter & self::FILTER_WRITEABLE),
       'insert'    => ($filter & self::FILTER_INSERTABLE),
       'active'    => ($filter & self::FILTER_ACTIVE),
-      'personal'  => ($filter & self::FILTER_PERSONAL),
+      'personal'  => ($filter & self::FILTER_PERSONAL)
     ));
 
     if ($plugin['abort']) {
@@ -317,6 +317,12 @@ class kolab_driver extends calendar_driver
       if (($filter & self::FILTER_ACTIVE) && !$cal->is_active()) {
         continue;
       }
+      if (($filter & self::FILTER_PRIVATE) && $cal->subtype != 'private') {
+        continue;
+      }
+      if (($filter & self::FILTER_CONFIDENTIAL) && $cal->subtype != 'confidential') {
+        continue;
+      }
       if (($filter & self::FILTER_PERSONAL) && $cal->get_namespace() != 'personal') {
         continue;
       }
diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php
index 6a01b24..242ef08 100644
--- a/plugins/kolab_folders/kolab_folders.php
+++ b/plugins/kolab_folders/kolab_folders.php
@@ -29,8 +29,8 @@ class kolab_folders extends rcube_plugin
     public $types      = array('mail', 'event', 'journal', 'task', 'note', 'contact', 'configuration', 'file', 'freebusy');
     public $subtypes   = array(
         'mail'          => array('inbox', 'drafts', 'sentitems', 'outbox', 'wastebasket', 'junkemail'),
-        'event'         => array('default', 'confidential'),
-        'task'          => array('default', 'confidential'),
+        'event'         => array('default', 'confidential', 'private'),
+        'task'          => array('default', 'confidential', 'private'),
         'journal'       => array('default'),
         'note'          => array('default'),
         'contact'       => array('default'),
diff --git a/plugins/kolab_folders/localization/en_US.inc b/plugins/kolab_folders/localization/en_US.inc
index 0910d9d..0c234d6 100644
--- a/plugins/kolab_folders/localization/en_US.inc
+++ b/plugins/kolab_folders/localization/en_US.inc
@@ -3,7 +3,7 @@
 /**
  * Localizations for the Kolab Folders plugin
  *
- * Copyright (C) 2014, Kolab Systems AG
+ * Copyright (C) 2015, Kolab Systems AG
  *
  * For translation see https://www.transifex.com/projects/p/kolab/resource/kolab_folders/
  */
@@ -29,6 +29,7 @@ $labels['outbox'] = 'Outbox';
 $labels['wastebasket'] = 'Trash';
 $labels['junkemail'] = 'Junk';
 $labels['confidential'] = 'Confidential';
+$labels['private'] = 'Private';
 
 $messages['defaultfolderexists'] = 'There is already default folder of specified type';
 
diff --git a/plugins/tasklist/tasklist.php b/plugins/tasklist/tasklist.php
index 449f43c..b4cdfa2 100644
--- a/plugins/tasklist/tasklist.php
+++ b/plugins/tasklist/tasklist.php
@@ -1724,26 +1724,22 @@ class tasklist extends rcube_plugin
     /**
      * Get properties of the tasklist this user has specified as default
      */
-    public function get_default_tasklist($writeable = false, $confidential = false)
+    public function get_default_tasklist($sensitivity = null)
     {
         $lists = $this->driver->get_lists();
         $list = null;
 
-        if (!$list || ($writeable && !$list['editable'])) {
-            foreach ($lists as $l) {
-                if ($confidential && $l['subtype'] == 'confidential') {
-                    $list = $l;
-                    break;
-                }
-                if ($l['default']) {
-                    $list = $l;
-                    if (!$confidential)
-                        break;
-                }
+        foreach ($lists as $l) {
+            if ($sensitivity && $l['subtype'] == $sensitivity) {
+                $list = $l;
+                break;
+            }
+            if ($l['default']) {
+                $list = $l;
+            }
 
-                if (!$writeable || $l['editable']) {
-                    $first = $l;
-                }
+            if ($l['editable']) {
+                $first = $l;
             }
         }
 
@@ -1786,7 +1782,7 @@ class tasklist extends rcube_plugin
 
             foreach ($tasks as $task) {
                 // save to tasklist
-                $list   = $lists[$cal_id] ?: $this->get_default_tasklist(true, $task['sensitivity'] == 'confidential');
+                $list   = $lists[$cal_id] ?: $this->get_default_tasklist($task['sensitivity']);
                 if ($list && $list['editable'] && $task['_type'] == 'task') {
                     $task = $this->from_ical($task);
                     $task['list'] = $list['id'];
@@ -1866,7 +1862,7 @@ class tasklist extends rcube_plugin
 
             // select default list except user explicitly selected 'none'
             if (!$list && !$dontsave) {
-                $list = $this->get_default_tasklist(true, $task['sensitivity'] == 'confidential');
+                $list = $this->get_default_tasklist($task['sensitivity']);
             }
 
             $metadata = array(
@@ -2105,7 +2101,7 @@ class tasklist extends rcube_plugin
         }
 
         if ($select) {
-            $default_list = $this->get_default_tasklist(true, $data['sensitivity'] == 'confidential');
+            $default_list = $this->get_default_tasklist($data['sensitivity']);
             $response['select'] = html::span('folder-select', $this->gettext('saveintasklist') . ' ' .
                 $select->show($default_list['id']));
         }




More information about the commits mailing list