From 917aad5ccb7b5e081ef7704c00e2698ac578f143 Mon Sep 17 00:00:00 2001
From: Gunnar Wrobel
Date: Tue, 14 Dec 2010 18:25:42 +0100
Subject: [PATCH] Make all backends work with the listMailboxes() method. Add
todos.
---
framework/Kolab_Storage/TODO | 12 +
.../Kolab_Storage/lib/Horde/Kolab/Storage/Cli.php | 9 +-
.../lib/Horde/Kolab/Storage/Driver/Cclient.php | 115 +++++-
.../lib/Horde/Kolab/Storage/Driver/Mock.php | 4 +-
.../lib/Horde/Kolab/Storage/Driver/Pear.php | 11 +-
.../lib/Horde/Kolab/Storage/Driver/Rcube.php | 434 +++++++++++++++++++++
.../lib/Horde/Kolab/Storage/Exception/Pear.php | 47 +++
.../lib/Horde/Kolab/Storage/Factory.php | 45 ++-
framework/Kolab_Storage/package.xml | 14 +-
.../Horde/Kolab/Storage/Unit/Cli/OptionsTest.php | 4 +-
10 files changed, 676 insertions(+), 19 deletions(-)
create mode 100644 framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Rcube.php
create mode 100644 framework/Kolab_Storage/lib/Horde/Kolab/Storage/Exception/Pear.php
diff --git a/framework/Kolab_Storage/TODO b/framework/Kolab_Storage/TODO
index 32da9b457..3a5a11e3f 100644
--- a/framework/Kolab_Storage/TODO
+++ b/framework/Kolab_Storage/TODO
@@ -13,3 +13,15 @@
- getNamespace() [DONE]
- replace imap_rfc822 use by Horde_Mail_Rfc822
+
+ - allow cli config file overriden by cli params
+
+ - performance tuning for the whole caching
+
+ - support cache searches in a better way
+
+ - Allow just any cache backend
+
+ - Evaluate redis as caching backend
+
+ - Allow storage of client information in the cache
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Cli.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Cli.php
index b3aae1c42..8cc58f288 100644
--- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Cli.php
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Cli.php
@@ -84,12 +84,13 @@ class Horde_Kolab_Storage_Cli
'--driver',
array(
'action' => 'store',
- 'choices' => array('horde', 'php', 'pear', 'roundcube', 'mock'),
+ 'choices' => array('horde', 'horde-php', 'php', 'pear', 'roundcube', 'mock'),
'help' => Horde_Kolab_Storage_Translation::t(
"The Kolab backend driver that should be used.
Choices are:
- - horde [IMAP]: The Horde_Imap_Client driver
+ - horde [IMAP]: The Horde_Imap_Client driver as pure PHP implementation.
+ - horde-php [IMAP]: The Horde_Imap_Client driver based on c-client in PHP
- php [IMAP]: The PHP imap_* functions which are based on c-client
- pear [IMAP]: The PEAR-Net_IMAP driver
- roundcube [IMAP]: The roundcube IMAP driver
@@ -99,7 +100,7 @@ Choices are:
),
new Horde_Argv_Option(
'-u',
- '--user',
+ '--username',
array(
'action' => 'store',
'help' => Horde_Kolab_Storage_Translation::t('The user accessing the backend.')
@@ -107,7 +108,7 @@ Choices are:
),
new Horde_Argv_Option(
'-p',
- '--pass',
+ '--password',
array(
'action' => 'store',
'help' => Horde_Kolab_Storage_Translation::t('The password of the user accessing the backend.')
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Cclient.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Cclient.php
index 97b6ab0d2..4df47b2a3 100644
--- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Cclient.php
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Cclient.php
@@ -29,23 +29,134 @@ class Horde_Kolab_Storage_Driver_Cclient
extends Horde_Kolab_Storage_Driver_Base
{
/**
+ * IMAP resource.
+ *
+ * @var resource
+ */
+ private $_imap;
+
+ /**
+ * Server name.
+ *
+ * @var string
+ */
+ private $_host;
+
+ /**
+ * Basic IMAP connection string.
+ *
+ * @var string
+ */
+ private $_base_mbox;
+
+ /**
+ * Lazy connect to the IMAP server.
+ *
+ * @return resource The IMAP connection.
+ *
+ * @throws Horde_Kolab_Storage_Exception In case the connection failed.
+ */
+ private function _getImap()
+ {
+ if (!isset($this->_imap)) {
+ $result = @imap_open(
+ $this->_getBaseMbox(),
+ $this->getParam('username'),
+ $this->getParam('password'),
+ OP_HALFOPEN
+ );
+ if (!$result) {
+ throw new Horde_Kolab_Storage_Exception(
+ sprintf(
+ Horde_Kolab_Storage_Translation::t(
+ "Connecting to server %s failed. Error: %s"
+ ),
+ $this->_getHost(),
+ @imap_last_error()
+ )
+ );
+ }
+ $this->_imap = $result;
+ }
+ return $this->_imap;
+ }
+
+ /**
+ * Return the root mailbox of the current user.
+ *
+ * @return string The id of the user that opened the IMAP connection.
+ */
+ private function _getBaseMbox()
+ {
+ if (!isset($this->_base_mbox)) {
+ $this->_base_mbox = '{' . $this->_getHost() . ':143/notls}';
+ }
+ return $this->_base_mbox;
+ }
+
+ /**
* Return the id of the user currently authenticated.
*
* @return string The id of the user that opened the IMAP connection.
*/
public function getAuth()
{
- return $this->_imap->getParam('username');
+ return $this->getParam('username');
+ }
+
+ /**
+ * Return the root mailbox of the current user.
+ *
+ * @return string The id of the user that opened the IMAP connection.
+ */
+ private function _getHost()
+ {
+ if (!isset($this->_host)) {
+ $this->_host = $this->getParam('host');
+ if (empty($this->_host)) {
+ throw new Horde_Kolab_Storage_Exception(
+ Horde_Kolab_Storage_Translation::t(
+ "Missing \"host\" parameter!"
+ )
+ );
+ }
+ }
+ return $this->_host;
}
/**
* Retrieves a list of mailboxes on the server.
*
* @return array The list of mailboxes.
+ *
+ * @throws Horde_Kolab_Storage_Exception In case listing the folders failed.
*/
public function getMailboxes()
{
- return $this->_imap->listMailboxes('*', Horde_Imap_Client::MBOX_ALL, array('flat' => true));
+ $folders = array();
+
+ $result = @imap_list($this->_getImap(), $this->_getBaseMbox(), '*');
+ if (!$result) {
+ throw new Horde_Kolab_Storage_Exception(
+ sprintf(
+ Horde_Kolab_Storage_Translation::t(
+ "Listing folders for %s failed. Error: %s"
+ ),
+ $this->_getBaseMbox(),
+ @imap_last_error()
+ )
+ );
+ }
+
+ $root = $this->_getBaseMbox();
+ $server_len = strlen($root);
+ foreach ($result as $folder) {
+ if (substr($folder, 0, $server_len) == $root) {
+ $folders[] = substr($folder, $server_len);
+ }
+ }
+
+ return $folders;
}
/**
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Mock.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Mock.php
index b58e604ff..be7332623 100644
--- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Mock.php
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Mock.php
@@ -52,7 +52,7 @@ extends Horde_Kolab_Storage_Driver_Base
/**
* Constructor.
*
- * @param array $params Connection parameters.
+ * @param array $params Connection parameters.
*/
public function __construct($params = array())
{
@@ -86,7 +86,7 @@ extends Horde_Kolab_Storage_Driver_Base
*/
public function getAuth()
{
- return $this->getParam('user');
+ return $this->getParam('username');
}
/**
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Pear.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Pear.php
index 2c46d1bc0..312f96026 100644
--- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Pear.php
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Pear.php
@@ -29,17 +29,16 @@ class Horde_Kolab_Storage_Driver_Pear
extends Horde_Kolab_Storage_Driver_Base
{
/**
- * The group handler for this connection.
+ * The IMAP client.
*
- * @var Horde_Group
+ * @var Net_IMAP
*/
- private $_groups;
+ private $_imap;
/**
* Constructor.
*
* @param Net_IMAP $imap The IMAP connection handler.
- * @param Horde_Group $groups The groups handler.
* @param array $params Connection parameters.
*/
public function __construct(
@@ -57,7 +56,7 @@ extends Horde_Kolab_Storage_Driver_Base
*/
public function getAuth()
{
- return $this->_imap->getParam('username');
+ return $this->getParam('username');
}
/**
@@ -67,7 +66,7 @@ extends Horde_Kolab_Storage_Driver_Base
*/
public function getMailboxes()
{
- return $this->_imap->listMailboxes('*', Horde_Imap_Client::MBOX_ALL, array('flat' => true));
+ return $this->_imap->getMailboxes();
}
/**
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Rcube.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Rcube.php
new file mode 100644
index 000000000..5f15ced0a
--- /dev/null
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Rcube.php
@@ -0,0 +1,434 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * A Roundcube Imap based Kolab storage driver.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package Kolab_Storage
+ * @author Gunnar Wrobel
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_Driver_Rcube
+extends Horde_Kolab_Storage_Driver_Base
+{
+ /**
+ * The IMAP client.
+ *
+ * @var rcube_imap_generic
+ */
+ private $_imap;
+
+ /**
+ * Constructor.
+ *
+ * @param rcube_imap_generic $imap The IMAP connection handler.
+ * @param array $params Connection parameters.
+ */
+ public function __construct(
+ rcube_imap_generic $imap,
+ $params = array()
+ ) {
+ $this->_imap = $imap;
+ parent::__construct($params);
+ }
+
+ /**
+ * Return the id of the user currently authenticated.
+ *
+ * @return string The id of the user that opened the IMAP connection.
+ */
+ public function getAuth()
+ {
+ return $this->getParam('username');
+ }
+
+ /**
+ * Retrieves a list of mailboxes on the server.
+ *
+ * @return array The list of mailboxes.
+ */
+ public function getMailboxes()
+ {
+ return $this->_imap->listMailboxes('', '*');
+ }
+
+ /**
+ * Opens the given folder.
+ *
+ * @param string $folder The folder to open
+ *
+ * @return mixed True in case the folder was opened successfully, a PEAR
+ * error otherwise.
+ */
+ public function select($folder)
+ {
+ $this->_imap->openMailbox($folder, Horde_Imap_Client::OPEN_AUTO);
+ return true;
+ }
+
+ /**
+ * Does the given folder exist?
+ *
+ * @param string $folder The folder to check.
+ *
+ * @return boolean True in case the folder exists, false otherwise.
+ */
+ public function exists($folder)
+ {
+ $folders = $this->getMailboxes();
+ if (in_array($folder, $folders)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the status of the current folder.
+ *
+ * @param string $folder Check the status of this folder.
+ *
+ * @return array An array that contains 'uidvalidity' and 'uidnext'.
+ */
+ public function status($folder)
+ {
+ return $this->_imap->status($folder,
+ Horde_Imap_Client::STATUS_UIDNEXT
+ | Horde_Imap_Client::STATUS_UIDVALIDITY);
+ }
+
+ /**
+ * Returns the message ids of the messages in this folder.
+ *
+ * @param string $folder Check the status of this folder.
+ *
+ * @return array The message ids.
+ */
+ public function getUids($folder)
+ {
+ $search_query = new Horde_Imap_Client_Search_Query();
+ $search_query->flag('DELETED', false);
+ $uidsearch = $this->_imap->search($folder, $search_query);
+ $uids = $uidsearch['match'];
+ return $uids;
+ }
+
+ /**
+ * Create the specified folder.
+ *
+ * @param string $folder The folder to create.
+ *
+ * @return mixed True in case the operation was successfull, a
+ * PEAR error otherwise.
+ */
+ public function create($folder)
+ {
+ return $this->_imap->createMailbox($folder);
+ }
+
+ /**
+ * Delete the specified folder.
+ *
+ * @param string $folder The folder to delete.
+ *
+ * @return mixed True in case the operation was successfull, a
+ * PEAR error otherwise.
+ */
+ public function delete($folder)
+ {
+ return $this->_imap->deleteMailbox($folder);
+ }
+
+ /**
+ * Rename the specified folder.
+ *
+ * @param string $old The folder to rename.
+ * @param string $new The new name of the folder.
+ *
+ * @return mixed True in case the operation was successfull, a
+ * PEAR error otherwise.
+ */
+ public function rename($old, $new)
+ {
+ return $this->_imap->renameMailbox($old, $new);
+ }
+
+ /**
+ * Appends a message to the current folder.
+ *
+ * @param string $mailbox The mailbox to append the message(s) to. Either
+ * in UTF7-IMAP or UTF-8.
+ * @param string $msg The message to append.
+ *
+ * @return mixed True or a PEAR error in case of an error.
+ */
+ public function appendMessage($mailbox, $msg)
+ {
+ return $this->_imap->append($mailbox, array(array('data' => $msg)));
+ }
+
+ /**
+ * Deletes messages from the current folder.
+ *
+ * @param integer $uids IMAP message ids.
+ *
+ * @return mixed True or a PEAR error in case of an error.
+ */
+ public function deleteMessages($mailbox, $uids)
+ {
+ if (!is_array($uids)) {
+ $uids = array($uids);
+ }
+ return $this->_imap->store($mailbox, array('add' => array('\\deleted'), 'ids' => $uids));
+ }
+
+ /**
+ * Moves a message to a new folder.
+ *
+ * @param integer $uid IMAP message id.
+ * @param string $new_folder Target folder.
+ *
+ * @return mixed True or a PEAR error in case of an error.
+ */
+ public function moveMessage($old_folder, $uid, $new_folder)
+ {
+ $options = array('ids' => array($uid), 'move' => true);
+ return $this->_imap->copy($old_folder, $new_folder, $options);
+ }
+
+ /**
+ * Expunges messages in the current folder.
+ *
+ * @param string $mailbox The mailbox to append the message(s) to. Either
+ * in UTF7-IMAP or UTF-8.
+ *
+ * @return mixed True or a PEAR error in case of an error.
+ */
+ public function expunge($mailbox)
+ {
+ return $this->_imap->expunge($mailbox);
+ }
+
+ /**
+ * Retrieves the message headers for a given message id.
+ *
+ * @param string $mailbox The mailbox to append the message(s) to. Either
+ * in UTF7-IMAP or UTF-8.
+ * @param int $uid The message id.
+ * @param boolean $peek_for_body Prefetch the body.
+ *
+ * @return mixed The message header or a PEAR error in case of an error.
+ */
+ function getMessageHeader($mailbox, $uid, $peek_for_body = true)
+ {
+ $options = array('ids' => array($uid));
+ $criteria = array(
+ Horde_Imap_Client::FETCH_HEADERTEXT => array(
+ array(
+ )
+ )
+ );
+ $result = $this->_imap->fetch($mailbox, $criteria, $options);
+ return $result[$uid]['headertext'][0];
+ }
+
+ /**
+ * Retrieves the message body for a given message id.
+ *
+ * @param string $mailbox The mailbox to append the message(s) to. Either
+ * in UTF7-IMAP or UTF-8.
+ * @param integet $uid The message id.
+ *
+ * @return mixed The message body or a PEAR error in case of an error.
+ */
+ function getMessageBody($mailbox, $uid)
+ {
+ $options = array('ids' => array($uid));
+ $criteria = array(
+ Horde_Imap_Client::FETCH_BODYTEXT => array(
+ array(
+ )
+ )
+ );
+ $result = $this->_imap->fetch($mailbox, $criteria, $options);
+ return $result[$uid]['bodytext'][0];
+ }
+
+ /**
+ * Retrieve the access rights for a folder.
+ *
+ * @param Horde_Kolab_Storage_Folder $folder The folder to retrieve the ACL for.
+ *
+ * @return An array of rights.
+ */
+ public function getAcl(Horde_Kolab_Storage_Folder $folder)
+ {
+ //@todo: Separate driver class
+ if ($this->_imap->queryCapability('ACL') === true) {
+ if ($folder->getOwner() == $this->getAuth()) {
+ try {
+ return $this->_getAcl($folder->getName());
+ } catch (Exception $e) {
+ return array($this->getAuth() => $this->_getMyAcl($folder->getName()));
+ }
+ } else {
+ $acl = $this->_getMyAcl($folder->getName());
+ if (strpos($acl, 'a')) {
+ try {
+ return $this->_getAcl($folder->getName());
+ } catch (Exception $e) {
+ }
+ }
+ return array($this->getAuth() => $acl);
+ }
+ } else {
+ return array($this->getAuth() => 'lrid');
+ }
+ }
+
+ /**
+ * Retrieve the access rights for a folder.
+ *
+ * @param string $folder The folder to retrieve the ACL for.
+ *
+ * @return An array of rights.
+ */
+ private function _getAcl($folder)
+ {
+ $acl = $this->_imap->getACL($folder);
+ $result = array();
+ foreach ($acl as $user => $rights) {
+ $result[$user] = join('', $rights);
+ }
+ return $result;
+ }
+
+ /**
+ * Retrieve the access rights on a folder for the current user.
+ *
+ * @param string $folder The folder to retrieve the ACL for.
+ *
+ * @return An array of rights.
+ */
+ private function _getMyAcl($folder)
+ {
+ return $this->_imap->getMyACLRights($folder);
+ }
+
+ /**
+ * Set the access rights for a folder.
+ *
+ * @param string $folder The folder to act upon.
+ * @param string $user The user to set the ACL for.
+ * @param string $acl The ACL.
+ *
+ * @return NULL
+ */
+ public function setAcl($folder, $user, $acl)
+ {
+ //@todo: Separate driver class
+ if ($this->_imap->queryCapability('ACL') === true) {
+ $this->_imap->setACL($folder, $user, array('rights' => $acl));
+ }
+ }
+
+ /**
+ * Delete the access rights for user on a folder.
+ *
+ * @param string $folder The folder to act upon.
+ * @param string $user The user to delete the ACL for
+ *
+ * @return NULL
+ */
+ public function deleteAcl($folder, $user)
+ {
+ //@todo: Separate driver class
+ if ($this->_imap->queryCapability('ACL') === true) {
+ $this->_imap->setACL($folder, $user, array('remove' => true));
+ }
+ }
+
+ /**
+ * Fetches the annotation on a folder.
+ *
+ * @param string $entry The entry to fetch.
+ * @param string $mailbox_name The name of the folder.
+ *
+ * @return mixed The annotation value or a PEAR error in case of an error.
+ */
+ public function getAnnotation($entry, $mailbox_name)
+ {
+ try {
+ $result = $this->_imap->getMetadata($mailbox_name, $entry);
+ } catch (Exception $e) {
+ return '';
+ }
+ return isset($result[$mailbox_name][$entry]) ? $result[$mailbox_name][$entry] : '';
+ }
+
+ /**
+ * Sets the annotation on a folder.
+ *
+ * @param string $entry The entry to set.
+ * @param array $value The values to set
+ * @param string $mailbox_name The name of the folder.
+ *
+ * @return mixed True if successfull, a PEAR error otherwise.
+ */
+ public function setAnnotation($entry, $value, $mailbox_name)
+ {
+ return $this->_imap->setMetadata($mailbox_name,
+ array($entry => $value));
+ }
+
+
+ /**
+ * Retrieve the namespace information for this connection.
+ *
+ * @return Horde_Kolab_Storage_Driver_Namespace The initialized namespace handler.
+ */
+ public function getNamespace()
+ {
+ if ($this->_imap->hasCapability('NAMESPACE') === true) {
+ $namespaces = array();
+ foreach ($this->_imap->getNamespace() as $type => $elements) {
+ foreach ($elements as $namespace) {
+ switch ($type) {
+ case 'personal':
+ $namespace['type'] = 'personal';
+ break;
+ case 'others':
+ $namespace['type'] = 'other';
+ break;
+ case 'shared':
+ $namespace['type'] = 'shared';
+ break;
+ }
+ $namespace['delimiter'] = $namespace['delimter'];
+ $namespaces[] = $namespace;
+ }
+ }
+ return new Horde_Kolab_Storage_Driver_Namespace_Imap(
+ $namespaces,
+ $this->getParam('namespaces', array())
+ );
+ }
+ return parent::getNamespace();
+ }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Exception/Pear.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Exception/Pear.php
new file mode 100644
index 000000000..54e6171b0
--- /dev/null
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Exception/Pear.php
@@ -0,0 +1,47 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * This class converts PEAR errors into exceptions for the Kolab_Storage
+ * package.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package Kolab_Storage
+ * @author Gunnar Wrobel
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_Exception_Pear
+extends Horde_Exception_Pear
+{
+ /**
+ * Exception handling.
+ *
+ * @param mixed $result The result to be checked for a PEAR_Error.
+ *
+ * @return mixed Returns the original result if it was no PEAR_Error.
+ *
+ * @throws Horde_Exception_Pear In case the result was a PEAR_Error.
+ */
+ static public function catchError($result)
+ {
+ self::$_class = __CLASS__;
+ return parent::catchError($result);
+ }
+}
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Factory.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Factory.php
index 3b18cf30a..a0319a0fd 100644
--- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Factory.php
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Factory.php
@@ -85,7 +85,7 @@ class Horde_Kolab_Storage_Factory
);
}
if (isset($params['params'])) {
- $config = $params['params'];
+ $config = (array) $params['params'];
} else {
$config = array();
}
@@ -93,11 +93,52 @@ class Horde_Kolab_Storage_Factory
case 'mock':
$config['data'] = array('user/test' => array());
return new Horde_Kolab_Storage_Driver_Mock($config);
+ case 'horde':
+ $config['hostspec'] = $config['host'];
+ unset($config['host']);
+ return new Horde_Kolab_Storage_Driver_Imap(
+ new Horde_Imap_Client_Socket(
+ $config
+ )
+ );
+ case 'horde-php':
+ $config['hostspec'] = $config['host'];
+ unset($config['host']);
+ return new Horde_Kolab_Storage_Driver_Imap(
+ new Horde_Imap_Client_Cclient(
+ $config
+ )
+ );
+ case 'php':
+ return new Horde_Kolab_Storage_Driver_Cclient($config);
+ case 'pear':
+ $client = new Net_IMAP($config['host']);
+ Horde_Kolab_Storage_Exception_Pear::catchError(
+ $client->login($config['username'], $config['password'])
+ );
+ return new Horde_Kolab_Storage_Driver_Pear(
+ $client, $config
+ );
+ case 'roundcube':
+ $client = new rcube_imap_generic();
+ $client->connect(
+ $config['host'], $config['username'], $config['password'],
+ array(
+ 'debug_mode' => false,
+ 'ssl_mode' => false,
+ 'port' => 143,
+ 'timeout' => 0,
+ 'force_caps' => false,
+ )
+ );
+ return new Horde_Kolab_Storage_Driver_Rcube(
+ $client, $config
+ );
default:
throw new Horde_Kolab_Storage_Exception(
sprintf(
Horde_Kolab_Storage_Translation::t(
- 'Invalid "driver" parameter "%s". Please use one of "mock", "php", "pear", "horde", "horde-socket", and "roundcube"!'
+ 'Invalid "driver" parameter "%s". Please use one of "mock", "php", "pear", "horde", "horde-php", and "roundcube"!'
),
$params['driver']
)
diff --git a/framework/Kolab_Storage/package.xml b/framework/Kolab_Storage/package.xml
index aa6a3e4b0..deee53c1f 100644
--- a/framework/Kolab_Storage/package.xml
+++ b/framework/Kolab_Storage/package.xml
@@ -32,7 +32,7 @@
yes
2010-12-14
-
+
0.4.0
0.1.0
@@ -99,7 +99,11 @@
+
+
+
+
@@ -136,6 +140,7 @@
+
@@ -462,6 +467,10 @@
pear.php.net
+ Exception
+ pear.horde.org
+
+
HTTP_Request
pear.php.net
@@ -528,6 +537,7 @@
+
@@ -535,6 +545,7 @@
+
@@ -545,6 +556,7 @@
+
diff --git a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Cli/OptionsTest.php b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Cli/OptionsTest.php
index 2dcc45e55..ef047f797 100644
--- a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Cli/OptionsTest.php
+++ b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Cli/OptionsTest.php
@@ -63,7 +63,7 @@ extends Horde_Kolab_Storage_TestCase
'kolab-storage'
);
$this->assertRegExp(
- '/-u[ ]*USER,[ ]*--user=USER/',
+ '/-u[ ]*USERNAME,[ ]*--username=USERNAME/',
$this->runCli()
);
}
@@ -74,7 +74,7 @@ extends Horde_Kolab_Storage_TestCase
'kolab-storage'
);
$this->assertRegExp(
- '/-p[ ]*PASS,[ ]*--pass=PASS/',
+ '/-p[ ]*PASSWORD,[ ]*--password=PASSWORD/',
$this->runCli()
);
}
--
2.11.0