plugins/kolab_folders plugins/libkolab
Thomas Brüderli
bruederli at kolabsys.com
Wed Oct 17 11:46:39 CEST 2012
plugins/kolab_folders/kolab_folders.php | 10 +---------
plugins/libkolab/lib/kolab_storage.php | 21 ++++++++++++++++++++-
2 files changed, 21 insertions(+), 10 deletions(-)
New commits:
commit fad8e68fe7461d65b8834f77bfcdfc4264b06860
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Oct 17 11:46:26 2012 +0200
Move kolab_folders::set_folder_type() logic to libkolab plugin and use it where appropriate (#1104)
diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php
index 297c858..3f83847 100644
--- a/plugins/kolab_folders/kolab_folders.php
+++ b/plugins/kolab_folders/kolab_folders.php
@@ -357,15 +357,7 @@ class kolab_folders extends rcube_plugin
*/
function set_folder_type($folder, $type='mail')
{
- $storage = $this->rc->get_storage();
- list($ctype, $subtype) = explode('.', $type);
-
- $success = $storage->set_metadata($folder, array(kolab_storage::CTYPE_KEY => $ctype, kolab_storage::CTYPE_KEY_PRIVATE => $subtype ? $type : null));
-
- if (!$success) // fallback: only set private annotation
- $success |= $storage->set_metadata($folder, array(kolab_storage::CTYPE_KEY_PRIVATE => $type));
-
- return $uccess;
+ return kolab_storage::set_folder_type($folder, $type);
}
/**
diff --git a/plugins/libkolab/lib/kolab_storage.php b/plugins/libkolab/lib/kolab_storage.php
index 1292b8b..57e5491 100644
--- a/plugins/libkolab/lib/kolab_storage.php
+++ b/plugins/libkolab/lib/kolab_storage.php
@@ -191,7 +191,7 @@ class kolab_storage
if ($saved = self::$imap->create_folder($name, $subscribed)) {
// set metadata for folder type
if ($type) {
- $saved = self::$imap->set_metadata($name, array(self::CTYPE_KEY => $type));
+ $saved = self::set_folder_type($name, $type);
// revert if metadata could not be set
if (!$saved) {
@@ -623,4 +623,23 @@ class kolab_storage
return 'mail';
}
+ /**
+ * Sets folder content-type.
+ *
+ * @param string $folder Folder name
+ * @param string $type Content type
+ *
+ * @return boolean True on success
+ */
+ static function set_folder_type($folder, $type='mail')
+ {
+ list($ctype, $subtype) = explode('.', $type);
+
+ $success = self::$imap->set_metadata($folder, array(self::CTYPE_KEY => $ctype, self::CTYPE_KEY_PRIVATE => $subtype ? $type : null));
+
+ if (!$success) // fallback: only set private annotation
+ $success |= self::$imap->set_metadata($folder, array(self::CTYPE_KEY_PRIVATE => $type));
+
+ return $success;
+ }
}
More information about the commits
mailing list