From 62a83b3bd5813885d964d9fd1509d52bb9c4f12c Mon Sep 17 00:00:00 2001 From: thomascube Date: Wed, 12 Jan 2011 15:47:44 +0000 Subject: Copying plugins to release branch --- plugins/kolab_core/README.txt | 32 ++++++++++ plugins/kolab_core/config.inc.php.dist | 8 +++ plugins/kolab_core/kolab_core.php | 30 ++++++++++ plugins/kolab_core/rcube_kolab.php | 104 +++++++++++++++++++++++++++++++++ 4 files changed, 174 insertions(+) create mode 100644 plugins/kolab_core/README.txt create mode 100644 plugins/kolab_core/config.inc.php.dist create mode 100644 plugins/kolab_core/kolab_core.php create mode 100644 plugins/kolab_core/rcube_kolab.php (limited to 'plugins/kolab_core') diff --git a/plugins/kolab_core/README.txt b/plugins/kolab_core/README.txt new file mode 100644 index 000000000..87537c0b8 --- /dev/null +++ b/plugins/kolab_core/README.txt @@ -0,0 +1,32 @@ +Kolab Integration Plugin README +------------------------------- + +This plugin relies on classes from the Horde project. In order to have all +the required files available you need to install the following packages from +Horde: + Horde_Framework + Kolab_Format + Kolab_Storage + Horde_NLS + Horde_DOM + +This is best done using PEAR. Make sure that the local PEAR directory is in +the PHP isntall path and execute the following commands to install the +required packages: + +pear channel-discover pear.horde.org + +pear install horde/Horde_Framework +pear install horde/Horde_DOM +pear install horde/Horde_NLS +pear install horde/Horde_Share +pear install horde/Log +pear install horde/Kolab_Format +pear install horde/Kolab_Storage + + +Configuration +------------- + +Rename the config.inc.php.dist to config.inc.php within this plugin directory +and add the corresponding values for your local Kolab server. diff --git a/plugins/kolab_core/config.inc.php.dist b/plugins/kolab_core/config.inc.php.dist new file mode 100644 index 000000000..b6ac25a4d --- /dev/null +++ b/plugins/kolab_core/config.inc.php.dist @@ -0,0 +1,8 @@ +'; + +?> diff --git a/plugins/kolab_core/kolab_core.php b/plugins/kolab_core/kolab_core.php new file mode 100644 index 000000000..e98b02dcd --- /dev/null +++ b/plugins/kolab_core/kolab_core.php @@ -0,0 +1,30 @@ + + * + */ +class kolab_core extends rcube_plugin +{ + /** + * Required startup method of a Roundcube plugin + */ + public function init() + { + // load local config + $this->load_config(); + + // extend include path to load bundled Horde classes + $include_path = $this->home . PATH_SEPARATOR . ini_get('include_path'); + set_include_path($include_path); + } + +} + diff --git a/plugins/kolab_core/rcube_kolab.php b/plugins/kolab_core/rcube_kolab.php new file mode 100644 index 000000000..b3e9f9fe5 --- /dev/null +++ b/plugins/kolab_core/rcube_kolab.php @@ -0,0 +1,104 @@ +config->get('kolab'); + + $conf['kolab']['ldap']['server'] = 'ldap://' . $_SESSION['imap_host'] . ':389'; + $conf['kolab']['imap']['server'] = $_SESSION['imap_host']; + $conf['kolab']['imap']['port'] = $_SESSION['imap_port']; + + // pass the current IMAP authentication credentials to the Horde auth system + self::$horde_auth = Auth::singleton('kolab'); + if (self::$horde_auth->authenticate($_SESSION['username'], array('password' => ($pwd = $rcmail->decrypt($_SESSION['password']))), false)) { + $_SESSION['__auth'] = array( + 'authenticated' => true, + 'userId' => $_SESSION['username'], + 'timestamp' => time(), + 'remote_addr' => $_SERVER['REMOTE_ADDR'], + ); + Auth::setCredential('password', $pwd); + } + + NLS::setCharset('UTF-8'); + } + + + /** + * Get instance of a Kolab (XML) format object + * + * @param string Data type (contact,event,task,note) + * @return object Horde_Kolab_Format_XML The format object + */ + public static function get_format($type) + { + self::setup(); + return Horde_Kolab_Format::factory('XML', $type); + } + + /** + * 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() + { + // unset auth data from session. no need to store it persistantly + if (isset($_SESSION['__auth'])) + unset($_SESSION['__auth']); + } +} -- cgit v1.2.3