summaryrefslogtreecommitdiff
path: root/plugins/kolab_folders
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2012-09-20 06:51:38 (GMT)
committerThomas Bruederli <thomas@roundcube.net>2012-09-20 06:51:38 (GMT)
commit395807c424e8bc2693880d3f561e918b5673b7b8 (patch)
treec9d2f738cf3a60223aab1f1c989a83c9998c1608 /plugins/kolab_folders
parent51510f1665087a9017c740643f468c4cc449b9f1 (diff)
downloadroundcubemail-plugins-kolab-395807c424e8bc2693880d3f561e918b5673b7b8.tar.gz
Save folder subtypes in private annotations according to Kolab 3 spec
Diffstat (limited to 'plugins/kolab_folders')
-rw-r--r--plugins/kolab_folders/kolab_folders.php32
1 files changed, 28 insertions, 4 deletions
diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php
index 9e00847..899620f 100644
--- a/plugins/kolab_folders/kolab_folders.php
+++ b/plugins/kolab_folders/kolab_folders.php
@@ -28,7 +28,9 @@ class kolab_folders extends rcube_plugin
public $types = array('mail', 'event', 'journal', 'task', 'note', 'contact', 'configuration');
public $mail_types = array('inbox', 'drafts', 'sentitems', 'outbox', 'wastebasket', 'junkemail');
+
private $rc;
+ private static $instance;
/**
@@ -36,6 +38,7 @@ class kolab_folders extends rcube_plugin
*/
function init()
{
+ self::$instance = $this;
$this->rc = rcmail::get_instance();
// load required plugin
@@ -335,9 +338,13 @@ class kolab_folders extends rcube_plugin
function get_folder_type($folder)
{
$storage = $this->rc->get_storage();
- $folderdata = $storage->get_metadata($folder, kolab_storage::CTYPE_KEY);
+ $folderdata = $storage->get_metadata($folder, array(kolab_storage::CTYPE_KEY_PRIVATE, kolab_storage::CTYPE_KEY));
+
+ if (!($ctype = $folderdata[$folder][kolab_storage::CTYPE_KEY_PRIVATE])) {
+ $ctype = $folderdata[$folder][kolab_storage::CTYPE_KEY];
+ }
- return explode('.', $folderdata[$folder][kolab_storage::CTYPE_KEY]);
+ return explode('.', $ctype);
}
/**
@@ -351,8 +358,14 @@ class kolab_folders extends rcube_plugin
function set_folder_type($folder, $type='mail')
{
$storage = $this->rc->get_storage();
+ list($ctype, $subtype) = explode('.', $type);
- return $storage->set_metadata($folder, array(kolab_storage::CTYPE_KEY => $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;
}
/**
@@ -365,7 +378,7 @@ class kolab_folders extends rcube_plugin
function get_default_folder($type)
{
$storage = $this->rc->get_storage();
- $folderdata = $storage->get_metadata('*', kolab_storage::CTYPE_KEY);
+ $folderdata = $storage->get_metadata('*', array(kolab_storage::CTYPE_KEY_PRIVATE, kolab_storage::CTYPE_KEY));
if (!is_array($folderdata)) {
return null;
@@ -517,4 +530,15 @@ class kolab_folders extends rcube_plugin
}
}
+
+ /**
+ * Static getter for default folder of the given type
+ *
+ * @param string $type Folder type
+ * @return string Folder name
+ */
+ public static function default_folder($type)
+ {
+ return self::$instance->get_default_folder($type);
+ }
}