summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-05-08 12:49:12 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2013-05-08 12:49:12 (GMT)
commit0364945d81bf480c6d6e4ef10b1aef61ba1f5e23 (patch)
tree68a18ffb34d2c59afa05cd7f33a82db7631cc7f2
parentd765eab497281d7a1e99ebd3468934e0cce32186 (diff)
downloadiRony-0364945d81bf480c6d6e4ef10b1aef61ba1f5e23.tar.gz
Use /vendor/cmu/cyrus-imapd/uniqueid annotation for UIDs if available
-rw-r--r--lib/Kolab/Utils/DAVBackend.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/Kolab/Utils/DAVBackend.php b/lib/Kolab/Utils/DAVBackend.php
index 205fecd..f1b7c02 100644
--- a/lib/Kolab/Utils/DAVBackend.php
+++ b/lib/Kolab/Utils/DAVBackend.php
@@ -33,6 +33,7 @@ class DAVBackend
{
const IMAP_UID_KEY = '/shared/vendor/kolab/dav-uid';
const IMAP_UID_KEY_PRIVATE = '/private/vendor/kolab/dav-uid';
+ const IMAP_UID_KEY_CYRUS = '/shared/vendor/cmu/cyrus-imapd/uniqueid';
/**
* Getter for a kolab_storage_folder with the given UID
@@ -60,9 +61,12 @@ class DAVBackend
public static function get_uid($folder)
{
// color is defined in folder METADATA
- $metadata = $folder->get_metadata(array(self::IMAP_UID_KEY, self::IMAP_UID_KEY_PRIVATE));
- if (($uid = $metadata[self::IMAP_UID_KEY]) || ($uid = $metadata[self::IMAP_UID_KEY_PRIVATE])) {
- return $uid;
+ $metakeys = array(self::IMAP_UID_KEY_CYRUS, self::IMAP_UID_KEY, self::IMAP_UID_KEY_PRIVATE);
+ $metadata = $folder->get_metadata($metakeys);
+ foreach ($metakeys as $key) {
+ if (($uid = $metadata[$key])) {
+ return $uid;
+ }
}
// generate a folder UID and set it to IMAP
@@ -81,8 +85,11 @@ class DAVBackend
*/
public static function set_uid($folder, $uid)
{
- if (!($success = $folder->set_metadata(array(self::IMAP_UID_KEY => $uid)))) {
- $success = $folder->set_metadata(array(self::IMAP_UID_KEY_PRIVATE => $uid));
+ $metakeys = array(self::IMAP_UID_KEY_CYRUS, self::IMAP_UID_KEY, self::IMAP_UID_KEY_PRIVATE);
+ foreach ($metakeys as $key) {
+ if ($success = $folder->set_metadata(array($key => $uid))) {
+ break;
+ }
}
return $success;