Add methods to read and set a folder's UID (migrated from iRony)
This commit is contained in:
parent
3c56dcc275
commit
38f5215467
2 changed files with 40 additions and 0 deletions
|
@ -31,6 +31,9 @@ class kolab_storage
|
||||||
const COLOR_KEY_PRIVATE = '/private/vendor/kolab/color';
|
const COLOR_KEY_PRIVATE = '/private/vendor/kolab/color';
|
||||||
const NAME_KEY_SHARED = '/shared/vendor/kolab/displayname';
|
const NAME_KEY_SHARED = '/shared/vendor/kolab/displayname';
|
||||||
const NAME_KEY_PRIVATE = '/private/vendor/kolab/displayname';
|
const NAME_KEY_PRIVATE = '/private/vendor/kolab/displayname';
|
||||||
|
const UID_KEY_SHARED = '/shared/vendor/kolab/uniqueid';
|
||||||
|
const UID_KEY_PRIVATE = '/private/vendor/kolab/uniqueid';
|
||||||
|
const UID_KEY_CYRUS = '/shared/vendor/cmu/cyrus-imapd/uniqueid';
|
||||||
|
|
||||||
public static $version = '3.0';
|
public static $version = '3.0';
|
||||||
public static $last_error;
|
public static $last_error;
|
||||||
|
|
|
@ -259,6 +259,43 @@ class kolab_storage_folder
|
||||||
return $this->resource_uri;
|
return $this->resource_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to extract folder UID metadata
|
||||||
|
*
|
||||||
|
* @return string Folder's UID
|
||||||
|
*/
|
||||||
|
public function get_uid()
|
||||||
|
{
|
||||||
|
// UID is defined in folder METADATA
|
||||||
|
$metakeys = array(kolab_storage::UID_KEY_SHARED, kolab_storage::UID_KEY_PRIVATE, kolab_storage::UID_KEY_CYRUS);
|
||||||
|
$metadata = $this->get_metadata($metakeys);
|
||||||
|
foreach ($metakeys as $key) {
|
||||||
|
if (($uid = $metadata[$key])) {
|
||||||
|
return $uid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate a folder UID and set it to IMAP
|
||||||
|
$uid = rtrim(chunk_split(md5($this->name . $this->get_owner()), 12, '-'), '-');
|
||||||
|
$this->set_uid($uid);
|
||||||
|
|
||||||
|
return $uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set an UID value to the given IMAP folder instance
|
||||||
|
*
|
||||||
|
* @param string Folder's UID
|
||||||
|
* @return boolean True on succes, False on failure
|
||||||
|
*/
|
||||||
|
public function set_uid($uid)
|
||||||
|
{
|
||||||
|
if (!($success = $this->set_metadata(array(kolab_storage::UID_KEY_SHARED => $uid)))) {
|
||||||
|
$success = $this->set_metadata(array(kolab_storage::UID_KEY_PRIVATE => $uid));
|
||||||
|
}
|
||||||
|
return $success;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check activation status of this folder
|
* Check activation status of this folder
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue