Branch 'kolab-syncroton-2.2' - lib/plugins

Aleksander Machniak machniak at kolabsys.com
Mon Nov 11 09:19:01 CET 2013


 lib/plugins/kolab_auth/kolab_auth.php                  |  100 +++++++++--------
 lib/plugins/kolab_auth/localization/de_CH.inc          |    2 
 lib/plugins/kolab_auth/localization/de_DE.inc          |    2 
 lib/plugins/kolab_auth/localization/es_ES.inc          |    3 
 lib/plugins/kolab_auth/localization/et_EE.inc          |    3 
 lib/plugins/kolab_auth/localization/fr_FR.inc          |    2 
 lib/plugins/kolab_auth/localization/ja_JP.inc          |    4 
 lib/plugins/kolab_auth/localization/nl_NL.inc          |    2 
 lib/plugins/kolab_auth/localization/pl_PL.inc          |    2 
 lib/plugins/kolab_auth/localization/ru_RU.inc          |    2 
 lib/plugins/kolab_folders/kolab_folders.php            |   52 +-------
 lib/plugins/kolab_folders/localization/de_CH.inc       |   10 +
 lib/plugins/kolab_folders/localization/de_DE.inc       |   14 +-
 lib/plugins/kolab_folders/localization/es_ES.inc       |   21 +++
 lib/plugins/kolab_folders/localization/et_EE.inc       |   25 ++++
 lib/plugins/kolab_folders/localization/fr_FR.inc       |    6 +
 lib/plugins/kolab_folders/localization/ja_JP.inc       |   40 +++---
 lib/plugins/kolab_folders/localization/nl_NL.inc       |    6 +
 lib/plugins/kolab_folders/localization/pl_PL.inc       |   15 +-
 lib/plugins/kolab_folders/localization/ru_RU.inc       |    6 +
 lib/plugins/libkolab/SQL/mysql.initial.sql             |    4 
 lib/plugins/libkolab/SQL/mysql/2013110400.sql          |    1 
 lib/plugins/libkolab/lib/kolab_date_recurrence.php     |   27 +++-
 lib/plugins/libkolab/lib/kolab_format.php              |    8 -
 lib/plugins/libkolab/lib/kolab_format_event.php        |   14 +-
 lib/plugins/libkolab/lib/kolab_storage_cache.php       |    5 
 lib/plugins/libkolab/lib/kolab_storage_cache_event.php |    2 
 lib/plugins/libkolab/lib/kolab_storage_folder.php      |    1 
 28 files changed, 239 insertions(+), 140 deletions(-)

New commits:
commit 24f6cf4793236c7d57c03c873724466ecba3438c
Author: Aleksander Machniak <alec at alec.pl>
Date:   Mon Nov 11 09:18:21 2013 +0100

    Rebase Roundcube plugins (from 3.1 branch)

diff --git a/lib/plugins/kolab_auth/kolab_auth.php b/lib/plugins/kolab_auth/kolab_auth.php
index 7ff5761..cf5818f 100644
--- a/lib/plugins/kolab_auth/kolab_auth.php
+++ b/lib/plugins/kolab_auth/kolab_auth.php
@@ -37,8 +37,6 @@ class kolab_auth extends rcube_plugin
     {
         $rcmail = rcube::get_instance();
 
-        $this->load_config();
-
         $this->add_hook('authenticate', array($this, 'authenticate'));
         $this->add_hook('startup', array($this, 'startup'));
         $this->add_hook('user_create', array($this, 'user_create'));
@@ -56,28 +54,20 @@ class kolab_auth extends rcube_plugin
         // Hook to modify some configuration, e.g. ldap
         $this->add_hook('config_get', array($this, 'config_get'));
 
-        // Enable debug logs per-user, this enables logging only after
-        // user has logged in
-        if (!empty($_SESSION['username']) && $rcmail->config->get('kolab_auth_auditlog')) {
-            $this->add_hook('write_log', array($this, 'write_log'));
+        $this->add_hook('write_log', array($this, 'write_log'));
 
+        // TODO: This section does not actually seem to work
+        if ($rcmail->config->get('kolab_auth_auditlog', false)) {
             $rcmail->config->set('debug_level', 1);
             $rcmail->config->set('devel_mode', true);
             $rcmail->config->set('smtp_log', true);
             $rcmail->config->set('log_logins', true);
             $rcmail->config->set('log_session', true);
+            $rcmail->config->set('sql_debug', true);
             $rcmail->config->set('memcache_debug', true);
             $rcmail->config->set('imap_debug', true);
             $rcmail->config->set('ldap_debug', true);
             $rcmail->config->set('smtp_debug', true);
-            $rcmail->config->set('sql_debug', true);
-
-            // SQL debug need to be set directly on DB object
-            // setting config variable will not work here because
-            // the object is already initialized/configured
-            if ($db = $rcmail->get_dbh()) {
-                $db->set_debug(true);
-            }
         }
     }
 
@@ -96,6 +86,8 @@ class kolab_auth extends rcube_plugin
         // Replaces ldap_vars (%dc, etc) in public kolab ldap addressbooks
         // config based on the users base_dn. (for multi domain support)
         if ($args['name'] == 'ldap_public' && !empty($args['result'])) {
+            $this->load_config();
+
             $rcmail      = rcube::get_instance();
             $kolab_books = (array) $rcmail->config->get('kolab_auth_ldap_addressbooks');
 
@@ -126,6 +118,8 @@ class kolab_auth extends rcube_plugin
         }
 
         $rcmail = rcube::get_instance();
+        $this->load_config();
+
 
         // Example 'kolab_auth_role_plugins' =
         //
@@ -213,49 +207,53 @@ class kolab_auth extends rcube_plugin
         }
     }
 
-    /**
-     * Logging method replacement to print debug/errors into
-     * a separate (sub)folder for each user
-     */
     public function write_log($args)
     {
         $rcmail = rcube::get_instance();
 
-        if ($rcmail->config->get('log_driver') == 'syslog') {
+        if (!$rcmail->config->get('kolab_auth_auditlog', false)) {
             return $args;
         }
 
-        $line = sprintf("[%s]: %s\n", $args['date'], $args['line']);
+        $args['abort'] = true;
 
-        // log_driver == 'file' is assumed here
-        $log_dir  = $rcmail->config->get('log_dir', RCUBE_INSTALL_PATH . 'logs');
-        $log_path = $log_dir.'/'.strtolower($_SESSION['kolab_auth_admin']).'/'.strtolower($_SESSION['username']);
+        if ($rcmail->config->get('log_driver') == 'syslog') {
+            $prio = $args['name'] == 'errors' ? LOG_ERR : LOG_INFO;
+            syslog($prio, $args['line']);
+            return $args;
+        }
+        else {
+            $line = sprintf("[%s]: %s\n", $args['date'], $args['line']);
 
-        // Append original username + target username
-        if (!is_dir($log_path)) {
-            // Attempt to create the directory
-            if (@mkdir($log_path, 0750, true)) {
+            // log_driver == 'file' is assumed here
+            $log_dir  = $rcmail->config->get('log_dir', INSTALL_PATH . 'logs');
+            $log_path = $log_dir.'/'.strtolower($_SESSION['kolab_auth_admin']).'/'.strtolower($_SESSION['username']);
+
+            // Append original username + target username
+            if (!is_dir($log_path)) {
+                // Attempt to create the directory
+                if (@mkdir($log_path, 0750, true)) {
+                    $log_dir = $log_path;
+                }
+            }
+            else {
                 $log_dir = $log_path;
             }
-        }
-        else {
-            $log_dir = $log_path;
-        }
 
-        // try to open specific log file for writing
-        $logfile = $log_dir.'/'.$args['name'];
+            // try to open specific log file for writing
+            $logfile = $log_dir.'/'.$args['name'];
 
-        if ($fp = fopen($logfile, 'a')) {
-            fwrite($fp, $line);
-            fflush($fp);
-            fclose($fp);
-        }
-        else {
-            trigger_error("Error writing to log file $logfile; Please check permissions", E_USER_WARNING);
+            if ($fp = fopen($logfile, 'a')) {
+                fwrite($fp, $line);
+                fflush($fp);
+                fclose($fp);
+                return $args;
+            }
+            else {
+                trigger_error("Error writing to log file $logfile; Please check permissions", E_USER_WARNING);
+            }
         }
 
-        $args['abort'] = true;
-
         return $args;
     }
 
@@ -298,6 +296,7 @@ class kolab_auth extends rcube_plugin
      */
     public function login_form($args)
     {
+        $this->load_config();
         $this->add_texts('localization/');
 
         $rcmail      = rcube::get_instance();
@@ -385,12 +384,12 @@ class kolab_auth extends rcube_plugin
             $_SESSION['user_roledns'] = (array)($record[$role_attr]);
         }
 
-        if (!empty($imap_attr) && !empty($record[$imap_attr])) {
+        if (!empty($imap_attr) && !empty($record[$role_attr])) {
             $default_host = $rcmail->config->get('default_host');
             if (!empty($default_host)) {
                 rcube::write_log("errors", "Both default host and kolab_auth_mailhost set. Incompatible.");
             } else {
-                $args['host'] = "tls://" . $record[$imap_attr];
+                $args['host'] = "tls://" . $record[$role_attr];
             }
         }
 
@@ -624,7 +623,18 @@ class kolab_auth extends rcube_plugin
             return self::$ldap;
         }
 
-        $rcmail      = rcube::get_instance();
+        $rcmail = rcube::get_instance();
+
+        // $this->load_config();
+        // we're in static method, load config manually
+        $fpath = $rcmail->plugins->dir . '/kolab_auth/config.inc.php';
+        if (is_file($fpath) && !$rcmail->config->load_from_file($fpath)) {
+            rcube::raise_error(array(
+                'code' => 527, 'type' => 'php',
+                'file' => __FILE__, 'line' => __LINE__,
+                'message' => "Failed to load config from $fpath"), true, false);
+        }
+
         $addressbook = $rcmail->config->get('kolab_auth_addressbook');
 
         if (!is_array($addressbook)) {
diff --git a/lib/plugins/kolab_auth/localization/de_CH.inc b/lib/plugins/kolab_auth/localization/de_CH.inc
index 5e85a01..9cdad33 100644
--- a/lib/plugins/kolab_auth/localization/de_CH.inc
+++ b/lib/plugins/kolab_auth/localization/de_CH.inc
@@ -1,3 +1,5 @@
 <?php
+
 $labels['loginas'] = 'Anmelden als';
+
 ?>
diff --git a/lib/plugins/kolab_auth/localization/de_DE.inc b/lib/plugins/kolab_auth/localization/de_DE.inc
index 5e85a01..9cdad33 100644
--- a/lib/plugins/kolab_auth/localization/de_DE.inc
+++ b/lib/plugins/kolab_auth/localization/de_DE.inc
@@ -1,3 +1,5 @@
 <?php
+
 $labels['loginas'] = 'Anmelden als';
+
 ?>
diff --git a/lib/plugins/kolab_auth/localization/es_ES.inc b/lib/plugins/kolab_auth/localization/es_ES.inc
index acb6c35..e1adb3f 100644
--- a/lib/plugins/kolab_auth/localization/es_ES.inc
+++ b/lib/plugins/kolab_auth/localization/es_ES.inc
@@ -1,2 +1,5 @@
 <?php
+
+$labels['loginas'] = 'Login As';
+
 ?>
diff --git a/lib/plugins/kolab_auth/localization/et_EE.inc b/lib/plugins/kolab_auth/localization/et_EE.inc
index acb6c35..e1adb3f 100644
--- a/lib/plugins/kolab_auth/localization/et_EE.inc
+++ b/lib/plugins/kolab_auth/localization/et_EE.inc
@@ -1,2 +1,5 @@
 <?php
+
+$labels['loginas'] = 'Login As';
+
 ?>
diff --git a/lib/plugins/kolab_auth/localization/fr_FR.inc b/lib/plugins/kolab_auth/localization/fr_FR.inc
index 6f72695..a25707f 100644
--- a/lib/plugins/kolab_auth/localization/fr_FR.inc
+++ b/lib/plugins/kolab_auth/localization/fr_FR.inc
@@ -1,3 +1,5 @@
 <?php
+
 $labels['loginas'] = 'Se connecter en tant que';
+
 ?>
diff --git a/lib/plugins/kolab_auth/localization/ja_JP.inc b/lib/plugins/kolab_auth/localization/ja_JP.inc
index ed0358a..e1adb3f 100644
--- a/lib/plugins/kolab_auth/localization/ja_JP.inc
+++ b/lib/plugins/kolab_auth/localization/ja_JP.inc
@@ -1,3 +1,5 @@
 <?php
-$labels['loginas'] = 'ログイン';
+
+$labels['loginas'] = 'Login As';
+
 ?>
diff --git a/lib/plugins/kolab_auth/localization/nl_NL.inc b/lib/plugins/kolab_auth/localization/nl_NL.inc
index a98283f..935b1cf 100644
--- a/lib/plugins/kolab_auth/localization/nl_NL.inc
+++ b/lib/plugins/kolab_auth/localization/nl_NL.inc
@@ -1,3 +1,5 @@
 <?php
+
 $labels['loginas'] = 'Log in als';
+
 ?>
diff --git a/lib/plugins/kolab_auth/localization/pl_PL.inc b/lib/plugins/kolab_auth/localization/pl_PL.inc
index 124c373..785f200 100644
--- a/lib/plugins/kolab_auth/localization/pl_PL.inc
+++ b/lib/plugins/kolab_auth/localization/pl_PL.inc
@@ -1,3 +1,5 @@
 <?php
+
 $labels['loginas'] = 'Zaloguj jako';
+
 ?>
diff --git a/lib/plugins/kolab_auth/localization/ru_RU.inc b/lib/plugins/kolab_auth/localization/ru_RU.inc
index 9e28c12..61ebc59 100644
--- a/lib/plugins/kolab_auth/localization/ru_RU.inc
+++ b/lib/plugins/kolab_auth/localization/ru_RU.inc
@@ -1,3 +1,5 @@
 <?php
+
 $labels['loginas'] = 'Войти как';
+
 ?>
diff --git a/lib/plugins/kolab_folders/kolab_folders.php b/lib/plugins/kolab_folders/kolab_folders.php
index 6de4ed3..0677b41 100644
--- a/lib/plugins/kolab_folders/kolab_folders.php
+++ b/lib/plugins/kolab_folders/kolab_folders.php
@@ -26,9 +26,8 @@ class kolab_folders extends rcube_plugin
 {
     public $task = '?(?!login).*';
 
-    public $types      = array('mail', 'event', 'journal', 'task', 'note', 'contact', 'configuration', 'file', 'freebusy');
+    public $types = array('mail', 'event', 'journal', 'task', 'note', 'contact', 'configuration', 'file', 'freebusy');
     public $mail_types = array('inbox', 'drafts', 'sentitems', 'outbox', 'wastebasket', 'junkemail');
-    public $act_types  = array('event', 'task');
 
     private $rc;
     private static $instance;
@@ -87,7 +86,7 @@ class kolab_folders extends rcube_plugin
 
         // Create default folders
         if ($args['root'] == '' && $args['name'] = '*') {
-            $this->create_default_folders($folders, $args['filter'], $folderdata, $args['mode'] == 'LSUB');
+            $this->create_default_folders($folders, $args['filter'], $folderdata);
         }
 
         $args['folders'] = $folders;
@@ -477,7 +476,7 @@ class kolab_folders extends rcube_plugin
     /**
      * Creates default folders if they doesn't exist
      */
-    private function create_default_folders(&$folders, $filter, $folderdata = null, $lsub = false)
+    private function create_default_folders(&$folders, $filter, $folderdata = null)
     {
         $storage     = $this->rc->get_storage();
         $namespace   = $storage->get_namespace();
@@ -531,54 +530,25 @@ class kolab_folders extends rcube_plugin
             }
 
             list($type1, $type2) = explode('.', $type);
-
-            $activate = in_array($type1, $this->act_types);
-            $exists   = false;
-            $result   = false;
-
-            // check if folder exists
-            if (!empty($folderdata[$foldername]) || $foldername == 'INBOX') {
-                $exists = true;
-            }
-            else if ((!$filter || $filter == $type1) && in_array($foldername, $folders)) {
-                // this assumes also that subscribed folder exists
-                $exists = true;
-            }
-            else {
-                $exists = $storage->folder_exists($foldername);
-            }
+            $exists = !empty($folderdata[$foldername]) || $foldername == 'INBOX';
 
             // create folder
-            if (!$exists) {
-                $exists = $storage->create_folder($foldername);
+            if (!$exists && !$storage->folder_exists($foldername)) {
+                $storage->create_folder($foldername);
+                $storage->subscribe($foldername);
             }
 
-            // set type + subscribe + activate
-            if ($exists) {
-                if ($result = kolab_storage::set_folder_type($foldername, $type)) {
-                    // check if folder is subscribed
-                    if ((!$filter || $filter == $type1) && $lsub && in_array($foldername, $folders)) {
-                        // already subscribed
-                        $subscribed = true;
-                    }
-                    else {
-                        $subscribed = $storage->subscribe($foldername);
-                    }
-
-                    // activate folder
-                    if ($activate) {
-                        kolab_storage::set_state($foldername, true);
-                    }
-                }
-            }
+            // set type
+            $result = $this->set_folder_type($foldername, $type);
 
             // add new folder to the result
-            if ($result && (!$filter || $filter == $type1) && (!$lsub || $subscribed)) {
+            if ($result && (!$filter || $filter == $type1)) {
                 $folders[] = $foldername;
             }
         }
     }
 
+
     /**
      * Static getter for default folder of the given type
      *
diff --git a/lib/plugins/kolab_folders/localization/de_CH.inc b/lib/plugins/kolab_folders/localization/de_CH.inc
index b53eea0..f9f6e16 100644
--- a/lib/plugins/kolab_folders/localization/de_CH.inc
+++ b/lib/plugins/kolab_folders/localization/de_CH.inc
@@ -1,14 +1,16 @@
 <?php
+
+$labels = array();
+
 $labels['folderctype'] = 'Ordnerinhalt';
 $labels['foldertypemail'] = 'E-Mail';
-$labels['foldertypeevent'] = 'Kalender'; // Events?
+$labels['foldertypeevent'] = 'Kalender'; // Termine?
 $labels['foldertypejournal'] = 'Journal';
 $labels['foldertypetask'] = 'Aufgaben';
 $labels['foldertypenote'] = 'Notizen';
 $labels['foldertypecontact'] = 'Kontakte';
 $labels['foldertypeconfiguration'] = 'Konfiguration';
-$labels['foldertypefile'] = 'Dateien';
-$labels['foldertypefreebusy'] = 'Frei-Besetzt';
+
 $labels['default'] = 'Standard';
 $labels['inbox'] = 'Posteingang';
 $labels['drafts'] = 'Entwürfe';
@@ -16,5 +18,7 @@ $labels['sentitems'] = 'Gesendet';
 $labels['outbox'] = 'Postausgang';
 $labels['wastebasket'] = 'Gelöscht';
 $labels['junkemail'] = 'Spam';
+
 $messages['defaultfolderexists'] = 'Es existiert bereits ein Standardordner für den angegebenen Typ';
+
 ?>
diff --git a/lib/plugins/kolab_folders/localization/de_DE.inc b/lib/plugins/kolab_folders/localization/de_DE.inc
index 60c6741..f9f6e16 100644
--- a/lib/plugins/kolab_folders/localization/de_DE.inc
+++ b/lib/plugins/kolab_folders/localization/de_DE.inc
@@ -1,20 +1,24 @@
 <?php
+
+$labels = array();
+
 $labels['folderctype'] = 'Ordnerinhalt';
 $labels['foldertypemail'] = 'E-Mail';
-$labels['foldertypeevent'] = 'Kalender'; // Events?
+$labels['foldertypeevent'] = 'Kalender'; // Termine?
 $labels['foldertypejournal'] = 'Journal';
 $labels['foldertypetask'] = 'Aufgaben';
 $labels['foldertypenote'] = 'Notizen';
 $labels['foldertypecontact'] = 'Kontakte';
 $labels['foldertypeconfiguration'] = 'Konfiguration';
-$labels['foldertypefile'] = 'Dateien';
-$labels['foldertypefreebusy'] = 'Frei/Belegt';
+
 $labels['default'] = 'Standard';
 $labels['inbox'] = 'Posteingang';
 $labels['drafts'] = 'Entwürfe';
 $labels['sentitems'] = 'Gesendet';
 $labels['outbox'] = 'Postausgang';
-$labels['wastebasket'] = 'Mülleimer';
+$labels['wastebasket'] = 'Gelöscht';
 $labels['junkemail'] = 'Spam';
-$messages['defaultfolderexists'] = 'Es gibt bereits einen Standardordner dieses Typs';
+
+$messages['defaultfolderexists'] = 'Es existiert bereits ein Standardordner für den angegebenen Typ';
+
 ?>
diff --git a/lib/plugins/kolab_folders/localization/es_ES.inc b/lib/plugins/kolab_folders/localization/es_ES.inc
index 91fe5b4..0481d09 100644
--- a/lib/plugins/kolab_folders/localization/es_ES.inc
+++ b/lib/plugins/kolab_folders/localization/es_ES.inc
@@ -1,7 +1,26 @@
 <?php
-$labels['foldertypeevent'] = ''; // Events?
+
+$labels = array();
+
+$labels['folderctype'] = 'Content type';
+$labels['foldertypemail'] = 'Mail';
+$labels['foldertypeevent'] = 'Calendar'; // Events?
+$labels['foldertypejournal'] = 'Journal';
 $labels['foldertypetask'] = 'Tareas';
 $labels['foldertypenote'] = 'Notas';
 $labels['foldertypecontact'] = 'Contactos';
 $labels['foldertypeconfiguration'] = 'Configuración';
+$labels['foldertypefile'] = 'Files';
+$labels['foldertypefreebusy'] = 'Free-Busy';
+
+$labels['default'] = 'Default';
+$labels['inbox'] = 'Inbox';
+$labels['drafts'] = 'Drafts';
+$labels['sentitems'] = 'Sent';
+$labels['outbox'] = 'Outbox';
+$labels['wastebasket'] = 'Trash';
+$labels['junkemail'] = 'Junk';
+
+$messages['defaultfolderexists'] = 'There is already default folder of specified type';
+
 ?>
diff --git a/lib/plugins/kolab_folders/localization/et_EE.inc b/lib/plugins/kolab_folders/localization/et_EE.inc
index e39fe4a..856f59d 100644
--- a/lib/plugins/kolab_folders/localization/et_EE.inc
+++ b/lib/plugins/kolab_folders/localization/et_EE.inc
@@ -1,3 +1,26 @@
 <?php
-$labels['foldertypeevent'] = ''; // Events?
+
+$labels = array();
+
+$labels['folderctype'] = 'Content type';
+$labels['foldertypemail'] = 'Mail';
+$labels['foldertypeevent'] = 'Calendar'; // Events?
+$labels['foldertypejournal'] = 'Journal';
+$labels['foldertypetask'] = 'Tasks';
+$labels['foldertypenote'] = 'Notes';
+$labels['foldertypecontact'] = 'Contacts';
+$labels['foldertypeconfiguration'] = 'Configuration';
+$labels['foldertypefile'] = 'Files';
+$labels['foldertypefreebusy'] = 'Free-Busy';
+
+$labels['default'] = 'Default';
+$labels['inbox'] = 'Inbox';
+$labels['drafts'] = 'Drafts';
+$labels['sentitems'] = 'Sent';
+$labels['outbox'] = 'Outbox';
+$labels['wastebasket'] = 'Trash';
+$labels['junkemail'] = 'Junk';
+
+$messages['defaultfolderexists'] = 'There is already default folder of specified type';
+
 ?>
diff --git a/lib/plugins/kolab_folders/localization/fr_FR.inc b/lib/plugins/kolab_folders/localization/fr_FR.inc
index 9ddece1..19e03e7 100644
--- a/lib/plugins/kolab_folders/localization/fr_FR.inc
+++ b/lib/plugins/kolab_folders/localization/fr_FR.inc
@@ -1,4 +1,7 @@
 <?php
+
+$labels = array();
+
 $labels['folderctype'] = 'Type de contenu';
 $labels['foldertypemail'] = 'Courriel';
 $labels['foldertypeevent'] = 'Calendrier'; // Events?
@@ -9,6 +12,7 @@ $labels['foldertypecontact'] = 'Contacts';
 $labels['foldertypeconfiguration'] = 'Configuration';
 $labels['foldertypefile'] = 'Fichiers';
 $labels['foldertypefreebusy'] = 'Disponible/Occupé';
+
 $labels['default'] = 'Par Défaut';
 $labels['inbox'] = 'Courrier entrant';
 $labels['drafts'] = 'Brouillons';
@@ -16,5 +20,7 @@ $labels['sentitems'] = 'Envoyés';
 $labels['outbox'] = 'Courrier sortant';
 $labels['wastebasket'] = 'Corbeille';
 $labels['junkemail'] = 'Indésirables';
+
 $messages['defaultfolderexists'] = 'Il existe déjà un répertoire par défaut pour le type spécifié';
+
 ?>
diff --git a/lib/plugins/kolab_folders/localization/ja_JP.inc b/lib/plugins/kolab_folders/localization/ja_JP.inc
index 14f3692..3bba3ed 100644
--- a/lib/plugins/kolab_folders/localization/ja_JP.inc
+++ b/lib/plugins/kolab_folders/localization/ja_JP.inc
@@ -1,20 +1,26 @@
 <?php
-$labels['folderctype'] = 'コンテンツタイプ';
-$labels['foldertypemail'] = 'メール';
-$labels['foldertypeevent'] = 'カレンダー'; // Events?
-$labels['foldertypejournal'] = 'ジャーナル';
-$labels['foldertypetask'] = 'タスク';
-$labels['foldertypenote'] = 'ノート';
-$labels['foldertypecontact'] = 'コンタクト';
+
+$labels = array();
+
+$labels['folderctype'] = 'Content type';
+$labels['foldertypemail'] = 'Mail';
+$labels['foldertypeevent'] = 'Calendar'; // Events?
+$labels['foldertypejournal'] = 'Journal';
+$labels['foldertypetask'] = 'Tasks';
+$labels['foldertypenote'] = 'Notes';
+$labels['foldertypecontact'] = 'Contacts';
 $labels['foldertypeconfiguration'] = '設定';
-$labels['foldertypefile'] = 'ファイル';
-$labels['foldertypefreebusy'] = '空状況';
-$labels['default'] = 'デフォルト';
-$labels['inbox'] = '受信箱';
-$labels['drafts'] = '下書き';
-$labels['sentitems'] = '送信済';
-$labels['outbox'] = '送信箱';
-$labels['wastebasket'] = 'ごみ箱';
-$labels['junkemail'] = '迷惑メール';
-$messages['defaultfolderexists'] = '指定したタイプの初期フォルダは既にあります。';
+$labels['foldertypefile'] = 'Files';
+$labels['foldertypefreebusy'] = 'Free-Busy';
+
+$labels['default'] = 'Default';
+$labels['inbox'] = 'Inbox';
+$labels['drafts'] = 'Drafts';
+$labels['sentitems'] = 'Sent';
+$labels['outbox'] = 'Outbox';
+$labels['wastebasket'] = 'Trash';
+$labels['junkemail'] = 'Junk';
+
+$messages['defaultfolderexists'] = 'There is already default folder of specified type';
+
 ?>
diff --git a/lib/plugins/kolab_folders/localization/nl_NL.inc b/lib/plugins/kolab_folders/localization/nl_NL.inc
index e0dffcd..3011279 100644
--- a/lib/plugins/kolab_folders/localization/nl_NL.inc
+++ b/lib/plugins/kolab_folders/localization/nl_NL.inc
@@ -1,4 +1,7 @@
 <?php
+
+$labels = array();
+
 $labels['folderctype'] = 'Inhoudstype';
 $labels['foldertypemail'] = 'Mail';
 $labels['foldertypeevent'] = 'Agenda'; // Events?
@@ -9,6 +12,7 @@ $labels['foldertypecontact'] = 'Adresboek';
 $labels['foldertypeconfiguration'] = 'Configuratie';
 $labels['foldertypefile'] = 'Bestanden';
 $labels['foldertypefreebusy'] = 'Free/Busy';
+
 $labels['default'] = 'Standaard';
 $labels['inbox'] = 'Inbox';
 $labels['drafts'] = 'Concepten';
@@ -16,5 +20,7 @@ $labels['sentitems'] = 'Verzonden';
 $labels['outbox'] = 'Te versturen';
 $labels['wastebasket'] = 'Prullenbak';
 $labels['junkemail'] = 'Ongewenst';
+
 $messages['defaultfolderexists'] = 'Er is reeds een standaard map voor dit type inhoud';
+
 ?>
diff --git a/lib/plugins/kolab_folders/localization/pl_PL.inc b/lib/plugins/kolab_folders/localization/pl_PL.inc
index f6d98a5..4520dac 100644
--- a/lib/plugins/kolab_folders/localization/pl_PL.inc
+++ b/lib/plugins/kolab_folders/localization/pl_PL.inc
@@ -1,20 +1,23 @@
 <?php
-$labels['folderctype'] = 'Typ treści';
+
+$labels = array();
+$labels['folderctype'] = 'Zawartość';
 $labels['foldertypemail'] = 'Poczta';
-$labels['foldertypeevent'] = 'Kalendarz'; // Events?
+$labels['foldertypeevent'] = 'Kalendarz';
 $labels['foldertypejournal'] = 'Dziennik';
 $labels['foldertypetask'] = 'Zadania';
 $labels['foldertypenote'] = 'Notatki';
 $labels['foldertypecontact'] = 'Kontakty';
 $labels['foldertypeconfiguration'] = 'Konfiguracja';
 $labels['foldertypefile'] = 'Pliki';
-$labels['foldertypefreebusy'] = 'Wolny-Zajęty';
+$labels['foldertypefreebusy'] = 'Free-Busy';
 $labels['default'] = 'Domyślny';
 $labels['inbox'] = 'Odebrane';
-$labels['drafts'] = 'Kopie robocze';
+$labels['drafts'] = 'Szkice';
 $labels['sentitems'] = 'Wysłane';
-$labels['outbox'] = 'Poczta wychodzÄ…ca';
+$labels['outbox'] = 'WychodzÄ…ce';
 $labels['wastebasket'] = 'Kosz';
 $labels['junkemail'] = 'Spam';
-$messages['defaultfolderexists'] = 'Folder domyślny wybranego typu już istnieje';
+$messages['defaultfolderexists'] = 'Folder domyślny dla podanego typu już istnieje';
+
 ?>
diff --git a/lib/plugins/kolab_folders/localization/ru_RU.inc b/lib/plugins/kolab_folders/localization/ru_RU.inc
index 3e55480..e9878ba 100644
--- a/lib/plugins/kolab_folders/localization/ru_RU.inc
+++ b/lib/plugins/kolab_folders/localization/ru_RU.inc
@@ -1,4 +1,7 @@
 <?php
+
+$labels = array();
+
 $labels['folderctype'] = 'Тип ящика';
 $labels['foldertypemail'] = 'Почта';
 $labels['foldertypeevent'] = 'Календарь'; // Events?
@@ -9,6 +12,7 @@ $labels['foldertypecontact'] = 'Контакты';
 $labels['foldertypeconfiguration'] = 'Настройки';
 $labels['foldertypefile'] = 'Файлы';
 $labels['foldertypefreebusy'] = 'Занят/Свободен';
+
 $labels['default'] = 'По умолчанию';
 $labels['inbox'] = 'Входящие';
 $labels['drafts'] = 'Черновики';
@@ -16,5 +20,7 @@ $labels['sentitems'] = 'Отправленные';
 $labels['outbox'] = 'Исходящие';
 $labels['wastebasket'] = 'Корзина';
 $labels['junkemail'] = 'Спам';
+
 $messages['defaultfolderexists'] = 'Уже назначен ящик по умолчанию для указанного типа';
+
 ?>
diff --git a/lib/plugins/libkolab/SQL/mysql.initial.sql b/lib/plugins/libkolab/SQL/mysql.initial.sql
index 4f23a52..fcb51b0 100644
--- a/lib/plugins/libkolab/SQL/mysql.initial.sql
+++ b/lib/plugins/libkolab/SQL/mysql.initial.sql
@@ -30,7 +30,7 @@ CREATE TABLE `kolab_cache_contact` (
   `created` DATETIME DEFAULT NULL,
   `changed` DATETIME DEFAULT NULL,
   `data` TEXT NOT NULL,
-  `xml` TEXT NOT NULL,
+  `xml` LONGTEXT NOT NULL,
   `tags` VARCHAR(255) NOT NULL,
   `words` TEXT NOT NULL,
   `type` VARCHAR(32) CHARACTER SET ascii NOT NULL,
@@ -172,4 +172,4 @@ CREATE TABLE `kolab_cache_freebusy` (
 ) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
 
 
-INSERT INTO `system` (`name`, `value`) VALUES ('libkolab-version', '2013100400');
+INSERT INTO `system` (`name`, `value`) VALUES ('libkolab-version', '2013110400');
diff --git a/lib/plugins/libkolab/SQL/mysql/2013110400.sql b/lib/plugins/libkolab/SQL/mysql/2013110400.sql
new file mode 100644
index 0000000..5b7a9ef
--- /dev/null
+++ b/lib/plugins/libkolab/SQL/mysql/2013110400.sql
@@ -0,0 +1 @@
+ALTER TABLE `kolab_cache_contact` CHANGE `xml` `xml` LONGTEXT NOT NULL;
diff --git a/lib/plugins/libkolab/lib/kolab_date_recurrence.php b/lib/plugins/libkolab/lib/kolab_date_recurrence.php
index 3aaa399..85ffd91 100644
--- a/lib/plugins/libkolab/lib/kolab_date_recurrence.php
+++ b/lib/plugins/libkolab/lib/kolab_date_recurrence.php
@@ -101,16 +101,35 @@ class kolab_date_recurrence
     /**
      * Get the end date of the occurence of this recurrence cycle
      *
-     * @param string Date limit (where infinite recurrences should abort)
      * @return mixed Timestamp with end date of the last event or False if recurrence exceeds limit
      */
-    public function end($limit = 'now +1 year')
+    public function end()
     {
-        $limit_dt = new DateTime($limit);
-        if ($this->engine && ($cend = $this->engine->getLastOccurrence()) && ($end_dt = kolab_format::php_datetime(new cDateTime($cend))) && $end_dt < $limit_dt) {
+        $event = $this->object->to_array();
+
+        // recurrence end date is given
+        if ($event['recurrence']['UNTIL'] instanceof DateTime) {
+            return $event['recurrence']['UNTIL']->format('U');
+        }
+
+        // let libkolab do the work
+        if ($this->engine && ($cend = $this->engine->getLastOccurrence()) && ($end_dt = kolab_format::php_datetime(new cDateTime($cend)))) {
             return $end_dt->format('U');
         }
 
+        // determine a reasonable end date if none given
+        if (!$event['recurrence']['COUNT']) {
+          switch ($event['recurrence']['FREQ']) {
+            case 'YEARLY':  $intvl = 'P100Y'; break;
+            case 'MONTHLY': $intvl = 'P20Y';  break;
+            default:        $intvl = 'P10Y';  break;
+          }
+
+          $end_dt = clone $event['start'];
+          $end_dt->add(new DateInterval($intvl));
+          return $end_dt->format('U');
+        }
+
         return false;
     }
 }
diff --git a/lib/plugins/libkolab/lib/kolab_format.php b/lib/plugins/libkolab/lib/kolab_format.php
index 5bcc57a..9dc8a31 100644
--- a/lib/plugins/libkolab/lib/kolab_format.php
+++ b/lib/plugins/libkolab/lib/kolab_format.php
@@ -123,7 +123,7 @@ abstract class kolab_format
             if (!$dateonly)
                 $result->setTime($datetime->format('G'), $datetime->format('i'), $datetime->format('s'));
 
-            if ($tz && $tz->getName() == 'UTC')
+            if ($tz && in_array($tz->getName(), array('UTC','GMT','+00:00')))
                 $result->setUTC(true);
             else if ($tz !== false)
                 $result->setTimezone($tz->getName());
@@ -401,13 +401,13 @@ abstract class kolab_format
         // set some automatic values if missing
         if (empty($object['created']) && method_exists($this->obj, 'setCreated')) {
             $cdt = $this->obj->created();
-            $object['created'] = $cdt && $cdt->isValid() ? self::php_datetime($cdt) : new DateTime('now', self::$timezone);
+            $object['created'] = $cdt && $cdt->isValid() ? self::php_datetime($cdt) : new DateTime('now', new DateTimeZone('UTC'));
             if (!$cdt || !$cdt->isValid())
                 $this->obj->setCreated(self::get_datetime($object['created']));
         }
 
-        $object['changed'] = new DateTime('now', self::$timezone);
-        $this->obj->setLastModified(self::get_datetime($object['changed'], new DateTimeZone('UTC')));
+        $object['changed'] = new DateTime('now', new DateTimeZone('UTC'));
+        $this->obj->setLastModified(self::get_datetime($object['changed']));
 
         // Save custom properties of the given object
         if (isset($object['x-custom'])) {
diff --git a/lib/plugins/libkolab/lib/kolab_format_event.php b/lib/plugins/libkolab/lib/kolab_format_event.php
index 9be9bdf..6a8c3ae 100644
--- a/lib/plugins/libkolab/lib/kolab_format_event.php
+++ b/lib/plugins/libkolab/lib/kolab_format_event.php
@@ -163,20 +163,22 @@ class kolab_format_event extends kolab_format_xcal
         else if ($status == kolabformat::StatusCancelled)
           $object['cancelled'] = true;
 
+        // this is an exception object
+        if ($this->obj->recurrenceID()->isValid()) {
+            $object['thisandfuture'] = $this->obj->thisAndFuture();
+        }
         // read exception event objects
-        if (($exceptions = $this->obj->exceptions()) && is_object($exceptions) && $exceptions->size()) {
+        else if (($exceptions = $this->obj->exceptions()) && is_object($exceptions) && $exceptions->size()) {
+            $recurrence_exceptions = array();
             for ($i=0; $i < $exceptions->size(); $i++) {
                 if (($exobj = $exceptions->get($i))) {
                     $exception = new kolab_format_event($exobj);
                     if ($exception->is_valid()) {
-                        $object['recurrence']['EXCEPTIONS'][] = $this->expand_exception($exception->to_array(), $object);
+                        $recurrence_exceptions[] = $this->expand_exception($exception->to_array(), $object);
                     }
                 }
             }
-        }
-        // this is an exception object
-        else if ($this->obj->recurrenceID()->isValid()) {
-          $object['thisandfuture'] = $this->obj->thisAndFuture();
+            $object['recurrence']['EXCEPTIONS'] = $recurrence_exceptions;
         }
 
         return $this->data = $object;
diff --git a/lib/plugins/libkolab/lib/kolab_storage_cache.php b/lib/plugins/libkolab/lib/kolab_storage_cache.php
index 651dc18..6ae2226 100644
--- a/lib/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/lib/plugins/libkolab/lib/kolab_storage_cache.php
@@ -133,7 +133,6 @@ class kolab_storage_cache
 
         // check cache status hash first ($this->metadata is set in _read_folder_data())
         if ($this->metadata['ctag'] != $this->folder->get_ctag()) {
-
             // lock synchronization for this folder or wait if locked
             $this->_sync_lock();
 
@@ -144,7 +143,7 @@ class kolab_storage_cache
             $this->imap->folder_sync($this->folder->name);
 
             // compare IMAP index with object cache index
-            $imap_index = $this->imap->index($this->folder->name);
+            $imap_index = $this->imap->index($this->folder->name, null, null, true, true);
             $this->index = $imap_index->get();
 
             // determine objects to fetch or to invalidate
@@ -365,7 +364,7 @@ class kolab_storage_cache
         $this->_read_folder_data();
 
         $result = $this->db->query(
-            "DELETE FROM $this->cache_table WHERE folder_id=?".
+            "DELETE FROM $this->cache_table WHERE folder_id=?",
             $this->folder_id
         );
         return $this->db->affected_rows($result);
diff --git a/lib/plugins/libkolab/lib/kolab_storage_cache_event.php b/lib/plugins/libkolab/lib/kolab_storage_cache_event.php
index 69134e7..876c3b4 100644
--- a/lib/plugins/libkolab/lib/kolab_storage_cache_event.php
+++ b/lib/plugins/libkolab/lib/kolab_storage_cache_event.php
@@ -41,7 +41,7 @@ class kolab_storage_cache_event extends kolab_storage_cache
         // extend date range for recurring events
         if ($object['recurrence'] && $object['_formatobj']) {
             $recurrence = new kolab_date_recurrence($object['_formatobj']);
-            $sql_data['dtend'] = date('Y-m-d 23:59:59', $recurrence->end() ?: strtotime('now +1 year'));
+            $sql_data['dtend'] = date('Y-m-d 23:59:59', $recurrence->end() ?: strtotime('now +10 years'));
         }
 
         return $sql_data;
diff --git a/lib/plugins/libkolab/lib/kolab_storage_folder.php b/lib/plugins/libkolab/lib/kolab_storage_folder.php
index 80f13fc..74d95b7 100644
--- a/lib/plugins/libkolab/lib/kolab_storage_folder.php
+++ b/lib/plugins/libkolab/lib/kolab_storage_folder.php
@@ -764,6 +764,7 @@ class kolab_storage_folder
             // update cache with new UID
             if ($result) {
                 $object['_msguid'] = $result;
+                $object['_mailbox'] = $this->name;
                 $this->cache->insert($result, $object);
 
                 // remove temp file




More information about the commits mailing list