diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-11-09 21:04:28 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-11-09 21:04:28 +0000 |
| commit | 5d682f384cef41e36829c557bb1d59a5b7ebf702 (patch) | |
| tree | 1e15599e2289cb030bc5014c660962a4a170e017 /plugins/kolab_addressbook/lib | |
| parent | 04e1a4bef02af7a6ab765482769f248b18993b60 (diff) | |
Little code cleanup: use static getters of rcube_kolab class to get Kolab_Storage objects
git-svn-id: https://svn.roundcube.net/trunk@4205 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/kolab_addressbook/lib')
| -rw-r--r-- | plugins/kolab_addressbook/lib/rcube_kolab.php | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/plugins/kolab_addressbook/lib/rcube_kolab.php b/plugins/kolab_addressbook/lib/rcube_kolab.php index 44c37a68f..985691a51 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab.php @@ -1,6 +1,5 @@ <?php -require_once 'Horde/Kolab/Format/XML.php'; require_once 'Horde/Kolab/Storage/List.php'; require_once 'Horde/Auth.php'; require_once 'Horde/Auth/kolab.php'; @@ -16,6 +15,7 @@ class rcube_kolab { private static $horde_auth; + /** * Setup the environment needed by the Kolab_* classes to access Kolab data */ @@ -49,5 +49,47 @@ class rcube_kolab } } + /** + * Get a list of storage folders for the given data type + * + * @param string Data type to list folders for (contact,event,task,note) + * @return array List of Kolab_Folder objects + */ + public static function get_folders($type) + { + self::setup(); + $kolab = Kolab_List::singleton(); + return $kolab->getByType($type); + } + /** + * Get storage object for read/write access to the Kolab backend + * + * @param string IMAP folder to access + * @param string Object type to deal with (leave empty for auto-detection using annotations) + * @return object Kolab_Data The data storage object + */ + public static function get_storage($folder, $data_type = null) + { + self::setup(); + $kolab = Kolab_List::singleton(); + return $kolab->getFolder($folder)->getData($data_type); + } + + /** + * Cleanup session data when done + */ + public static function shutdown() + { + if (isset($_SESSION['__auth'])) { + // unset auth data from session. no need to store it persistantly + unset($_SESSION['__auth']); + + // FIXME: remove strange numeric entries + foreach ($_SESSION as $key => $val) { + if (!$val && is_numeric($key)) + unset($_SESSION[$key]); + } + } + } } |
