The namespace handler is part of the driver.
authorGunnar Wrobel <p@rdus.de>
Tue, 27 Apr 2010 22:54:04 +0000 (00:54 +0200)
committerGunnar Wrobel <wrobel@temple.(none)>
Wed, 23 Jun 2010 14:21:29 +0000 (16:21 +0200)
34 files changed:
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Base.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Decorator/Base.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Decorator/Log.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Imap.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace.php [new file with mode: 0644]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Config.php [new file with mode: 0644]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element.php [new file with mode: 0644]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/Other.php [new file with mode: 0644]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/Personal.php [new file with mode: 0644]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/Shared.php [new file with mode: 0644]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/SharedWithPrefix.php [new file with mode: 0644]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Fixed.php [new file with mode: 0644]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Imap.php [new file with mode: 0644]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Pear.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Base.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace.php [deleted file]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Config.php [deleted file]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element.php [deleted file]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/Other.php [deleted file]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/Personal.php [deleted file]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/Shared.php [deleted file]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/SharedWithPrefix.php [deleted file]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Fixed.php [deleted file]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Imap.php [deleted file]
framework/Kolab_Storage/package.xml
framework/Kolab_Storage/test/Horde/Kolab/Storage/AclTest.php
framework/Kolab_Storage/test/Horde/Kolab/Storage/Class/Driver/CclientTest.php
framework/Kolab_Storage/test/Horde/Kolab/Storage/Class/Driver/ImapTest.php
framework/Kolab_Storage/test/Horde/Kolab/Storage/Class/Driver/MockTest.php
framework/Kolab_Storage/test/Horde/Kolab/Storage/Class/Driver/PearTest.php
framework/Kolab_Storage/test/Horde/Kolab/Storage/FolderTest.php
framework/Kolab_Storage/test/Horde/Kolab/Storage/NamespaceTest.php
framework/Kolab_Storage/test/Horde/Kolab/Storage/PermissionTest.php

index 1f5ef55..8ae25f5 100644 (file)
@@ -219,7 +219,7 @@ interface Horde_Kolab_Storage_Driver
     /**
      * Retrieve the namespace information for this connection.
      *
-     * @return Horde_Kolab_Storage_Namespace The initialized namespace handler.
+     * @return Horde_Kolab_Storage_Driver_Namespace The initialized namespace handler.
      */
     public function getNamespace();
 
index 33af192..08ee395 100644 (file)
@@ -70,16 +70,16 @@ implements Horde_Kolab_Storage_Driver
     /**
      * Retrieve the namespace information for this connection.
      *
-     * @return Horde_Kolab_Storage_Namespace The initialized namespace handler.
+     * @return Horde_Kolab_Storage_Driver_Namespace The initialized namespace handler.
      */
     public function getNamespace()
     {
         if (isset($this->_params['namespaces'])) {
-            return new Horde_Kolab_Storage_Namespace_Config(
+            return new Horde_Kolab_Storage_Driver_Namespace_Config(
                 $this->_params['namespaces']
             );
         }
-        return new Horde_Kolab_Storage_Namespace_Fixed();
+        return new Horde_Kolab_Storage_Driver_Namespace_Fixed();
     }
 
     /**
index 87b061e..e7aef4e 100644 (file)
@@ -258,7 +258,7 @@ implements Horde_Kolab_Storage_Driver
     /**
      * Retrieve the namespace information for this connection.
      *
-     * @return Horde_Kolab_Storage_Namespace The initialized namespace handler.
+     * @return Horde_Kolab_Storage_Driver_Namespace The initialized namespace handler.
      */
     public function getNamespace()
     {
index 0f118f9..1f9c8b9 100644 (file)
@@ -258,7 +258,7 @@ extends Horde_Kolab_Storage_Driver_Decorator_Base
     /**
      * Retrieve the namespace information for this connection.
      *
-     * @return Horde_Kolab_Storage_Namespace The initialized namespace handler.
+     * @return Horde_Kolab_Storage_Driver_Namespace The initialized namespace handler.
      */
     public function getNamespace()
     {
index 1f1bf10..1dc0e8c 100644 (file)
@@ -403,12 +403,12 @@ extends Horde_Kolab_Storage_Driver_Base
     /**
      * Retrieve the namespace information for this connection.
      *
-     * @return Horde_Kolab_Storage_Namespace The initialized namespace handler.
+     * @return Horde_Kolab_Storage_Driver_Namespace The initialized namespace handler.
      */
     public function getNamespace()
     {
         if ($this->_imap->queryCapability('NAMESPACE') === true) {
-            return new Horde_Kolab_Storage_Namespace_Imap(
+            return new Horde_Kolab_Storage_Driver_Namespace_Imap(
                 $this->_imap->getNamespaces(),
                 $this->getParam('namespaces', array())
             );
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace.php
new file mode 100644 (file)
index 0000000..a3a2639
--- /dev/null
@@ -0,0 +1,226 @@
+<?php
+/**
+ * The Horde_Kolab_Storage_Driver_Namespace:: class handles IMAP namespaces and allows
+ * to derive folder information from folder names.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Storage
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * The Horde_Kolab_Storage_Driver_Namespace:: class handles IMAP namespaces and allows
+ * to derive folder information from folder names.
+ *
+ * Copyright 2004-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 <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+abstract class Horde_Kolab_Storage_Driver_Namespace
+implements Iterator
+{
+    /** The possible namespace types (RFC 2342 [5]) */
+    const PERSONAL = 'personal';
+    const OTHER    = 'other';
+    const SHARED   = 'shared';
+
+    /**
+     * The namespaces.
+     *
+     * @var array
+     */
+    protected $_namespaces = array();
+
+    /**
+     * The characterset this module uses to communicate with the outside world.
+     *
+     * @var string
+     */
+    protected $_charset;
+
+    /**
+     * A prefix in the shared namespaces that will be ignored/removed.
+     *
+     * @var string
+     */
+    protected $_sharedPrefix;
+
+    /**
+     * The namespace that matches any folder name not matching to another
+     * namespace.
+     *
+     * @var Horde_Kolab_Storage_Driver_Namespace_Element
+     */
+    protected $_any;
+
+    /**
+     * Indicates the personal namespace that the class will use to create new
+     * folders.
+     *
+     * @var Horde_Kolab_Storage_Driver_Namespace_Element
+     */
+    protected $_primaryPersonalNamespace;
+
+    /**
+     * A helper for iteration over the namespaces.
+     *
+     * @var array
+     */
+    protected $_iteration;
+
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->_charset = Horde_Nls::getCharset();
+        if (empty($this->_primaryPersonalNamespace)) {
+            $personal = null;
+            foreach ($this->_namespaces as $namespace) {
+                if ($namespace->getName() == 'INBOX') {
+                    $this->_primaryPersonalNamespace = $namespace;
+                    break;
+                }
+                if (empty($personal) && $namespace->getType() == self::PERSONAL) {
+                    $personal = $namespace;
+                }
+            }
+            if (empty($this->_primaryPersonalNamespace)) {
+                $this->_primaryPersonalNamespace = $personal;
+            }
+        }
+    }
+
+    /**
+     * Match a folder name with the corresponding namespace.
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return Horde_Kolab_Storage_Driver_Namespace_Element The corresponding namespace.
+     *
+     * @throws Horde_Kolab_Storage_Exception If the namespace of the folder
+     *                                       cannot be determined.
+     */
+    protected function matchNamespace($name)
+    {
+        foreach ($this->_namespaces as $namespace) {
+            if ($namespace->matches($name)) {
+                return $namespace;
+            }
+        }
+        if (!empty($this->_any)) {
+            return $this->_any;
+        }
+        throw new Horde_Kolab_Storage_Exception(
+            sprintf('Namespace of folder %s cannot be determined.', $name)
+        );
+    }
+
+    /**
+     * Get the character set used/expected when calling the getTitle() or
+     * setName() methods.
+     *
+     * @return string The character set.
+     */
+    public function getCharset()
+    {
+        return $this->_charset;
+    }
+
+    /**
+     * Return the title of a folder.
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return string The title of the folder.
+     */
+    public function getTitle($name)
+    {
+        $name = Horde_String::convertCharset($name, 'UTF7-IMAP', $this->_charset);
+        return $this->matchNamespace($name)->getTitle($name);
+    }
+
+    /**
+     * Return the owner of a folder.
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return string The owner of the folder.
+     */
+    public function getOwner($name)
+    {
+        $name = Horde_String::convertCharset($name, 'UTF7-IMAP', $this->_charset);
+        return $this->matchNamespace($name)->getOwner($name);
+    }
+
+    /**
+     * Get the sub path for the given folder name.
+     *
+     * @param string $name The folder name.
+     *
+     * @return string The sub path.
+     */
+    public function getSubpath($name)
+    {
+        $name = Horde_String::convertCharset($name, 'UTF7-IMAP', $this->_charset);
+        return $this->matchNamespace($name)->getSubpath($name);
+    }
+
+    /**
+     * Generate an IMAP folder name.
+     *
+     * @param string $name The new folder name.
+     *
+     * @return string The IMAP folder name.
+     */
+    public function setName($name)
+    {
+        $namespace = $this->matchNamespace($name);
+        $path = explode(':', $name);
+        if (empty($this->_sharedPrefix)
+            || (strpos($path[0], $this->_sharedPrefix) === false
+                && $namespace->getType() != self::OTHER)) {
+            array_unshift($path, $this->_primaryPersonalNamespace->getName());
+            $namespace = $this->_primaryPersonalNamespace;
+        }
+        return Horde_String::convertCharset($namespace->generateName($path), $this->_charset, 'UTF7-IMAP');
+    }
+
+    function rewind()
+    {
+        $this->_iterator = $this->_namespaces;
+        $this->_iterator[] = $this->_any;
+        return reset($this->_iterator);
+    }
+
+    function current()
+    {
+        return current($this->_iterator);
+    }
+
+    function key()
+    {
+        return key($this->_iterator);
+    }
+
+    function next()
+    {
+        return next($this->_iterator);
+    }
+
+    function valid()
+    {
+        return key($this->_iterator) !== null;
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Config.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Config.php
new file mode 100644 (file)
index 0000000..05f98a2
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * The Horde_Kolab_Storage_Driver_Namespace_Config:: allows to configure the available
+ * IMAP namespaces on the Kolab server.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Storage
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * The Horde_Kolab_Storage_Driver_Namespace_Config:: allows to configure the available
+ * IMAP namespaces on the Kolab server.
+ *
+ * Copyright 2004-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 <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_Driver_Namespace_Config
+extends  Horde_Kolab_Storage_Driver_Namespace
+{
+    /**
+     * Constructor.
+     */
+    public function __construct(array $configuration)
+    {
+        parent::__construct();
+        foreach ($configuration as $element) {
+            if ($element['type'] == Horde_Kolab_Storage_Driver_Namespace::SHARED
+                && isset($element['prefix'])) {
+                $namespace_element = new Horde_Kolab_Storage_Driver_Namespace_Element_SharedWithPrefix(
+                    $element['name'], $element['delimiter'], $element['prefix']
+                );
+                $this->_sharedPrefix = $element['prefix'];
+            } else {
+                $class = 'Horde_Kolab_Storage_Driver_Namespace_Element_' . ucfirst($element['type']);
+                $namespace_element = new $class($element['name'], $element['delimiter']);
+            }
+            if (empty($element['name'])) {
+                $this->_any = $namespace_element;
+            } else {
+                $this->_namespaces[] = $namespace_element;
+            }
+            if (isset($element['add'])) {
+                $this->_primaryPersonalNamespace = $namespace_element;
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element.php
new file mode 100644 (file)
index 0000000..86c6ecd
--- /dev/null
@@ -0,0 +1,135 @@
+<?php
+
+abstract class Horde_Kolab_Storage_Driver_Namespace_Element
+{
+    /**
+     * The prefix identifying this namespace.
+     *
+     * @var string
+     */
+    protected $_name;
+
+    /**
+     * The delimiter used for this namespace.
+     *
+     * @var string
+     */
+    protected $_delimiter;
+
+    /**
+     * Constructor.
+     *
+     * @param string $name      The prefix identifying this namespace.
+     * @param string $delimiter The delimiter used for this namespace.
+     */
+    public function __construct($name, $delimiter)
+    {
+        if (substr($name, -1) == $delimiter) {
+            $name = substr($name, 0, -1);
+        }
+        $this->_name = $name;
+        $this->_delimiter = $delimiter;
+    }
+
+    /**
+     * Return the type of this namespace (personal, other, or shared).
+     *
+     * @return string The type.
+     */
+    abstract public function getType();
+
+    /**
+     * Return the name of this namespace.
+     *
+     * @return string The name/prefix.
+     */
+    public function getName()
+    {
+        return $this->_name;
+    }
+
+    /**
+     * Return the delimiter for this namespace.
+     *
+     * @return string The delimiter.
+     */
+    public function getDelimiter()
+    {
+        return $this->_delimiter;
+    }
+
+    /**
+     * Does the folder name lie in this namespace?
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return boolean True if the folder is element of this namespace.
+     */
+    public function matches($name)
+    {
+        return (strpos($name, $this->_name) === 0);
+    }
+
+    /**
+     * Return the owner of a folder.
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return string The owner of the folder.
+     */
+    abstract public function getOwner($name);
+
+    /**
+     * Return the title of a folder.
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return string The title of the folder.
+     */
+    public function getTitle($name)
+    {
+        return join($this->_subpath($name), ':');
+    }
+
+    /**
+     * Get the sub path for the given folder name.
+     *
+     * @param string $name The folder name.
+     *
+     * @return string The sub path.
+     */
+    public function getSubpath($name)
+    {
+        return join($this->_subpath($name), $this->_delimiter);
+    }
+
+    /**
+     * Return an array describing the path elements of the folder.
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return array The path elements.
+     */
+    protected function _subpath($name)
+    {
+        $path = explode($this->_delimiter, $name);
+        if ($path[0] == $this->_name) {
+            array_shift($path);
+        }
+        //@todo: What about the potential trailing domain?
+        return $path;
+    }
+
+    /**
+     * Generate a folder path for the given path in this namespace.
+     *
+     * @param array $path The path of the folder.
+     *
+     * @return string The name of the folder.
+     */
+    public function generateName($path)
+    {
+        return join($path, $this->_delimiter);
+    }
+
+}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/Other.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/Other.php
new file mode 100644 (file)
index 0000000..f0921a7
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+class Horde_Kolab_Storage_Driver_Namespace_Element_Other
+extends Horde_Kolab_Storage_Driver_Namespace_Element
+{
+    /**
+     * Return the type of this namespace (personal, other, or shared).
+     *
+     * @return string The type.
+     */
+    public function getType()
+    {
+        return Horde_Kolab_Storage_Driver_Namespace::OTHER;
+    }
+
+    /**
+     * Return the owner of a folder.
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return string The owner of the folder.
+     */
+    public function getOwner($name)
+    {
+        $path = explode($this->_delimiter, $name);
+        $user = $path[1];
+        if (strpos($user, '@') === false) {
+            $domain = strstr(array_pop($path), '@');
+            if (!empty($domain)) {
+                $user .= $domain;
+            }
+        }
+        return Horde_Kolab_Storage_Driver_Namespace::OTHER . ':' . $user;
+    }
+
+    /**
+     * Return an array describing the path elements of the folder.
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return array The path elements.
+     */
+    protected function _subpath($name)
+    {
+        $path = parent::_subpath($name);
+        array_shift($path);
+        return $path;
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/Personal.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/Personal.php
new file mode 100644 (file)
index 0000000..dfe2c85
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+class Horde_Kolab_Storage_Driver_Namespace_Element_Personal
+extends Horde_Kolab_Storage_Driver_Namespace_Element
+{
+    /**
+     * Return the type of this namespace (personal, other, or shared).
+     *
+     * @return string The type.
+     */
+    public function getType()
+    {
+        return Horde_Kolab_Storage_Driver_Namespace::PERSONAL;
+    }
+
+    /**
+     * Return the owner of a folder.
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return string The owner of the folder.
+     */
+    public function getOwner($name)
+    {
+        return Horde_Kolab_Storage_Driver_Namespace::PERSONAL;
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/Shared.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/Shared.php
new file mode 100644 (file)
index 0000000..c6be66b
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+class Horde_Kolab_Storage_Driver_Namespace_Element_Shared
+extends Horde_Kolab_Storage_Driver_Namespace_Element
+{
+    /**
+     * Return the type of this namespace (personal, other, or shared).
+     *
+     * @return string The type.
+     */
+    public function getType()
+    {
+        return Horde_Kolab_Storage_Driver_Namespace::SHARED;
+    }
+
+    /**
+     * Return the owner of a folder.
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return string The owner of the folder.
+     */
+    public function getOwner($name)
+    {
+        return Horde_Kolab_Storage_Driver_Namespace::SHARED;
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/SharedWithPrefix.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Element/SharedWithPrefix.php
new file mode 100644 (file)
index 0000000..761fd14
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+class Horde_Kolab_Storage_Driver_Namespace_Element_SharedWithPrefix
+extends Horde_Kolab_Storage_Driver_Namespace_Element_Shared
+{
+    /**
+     * The prefix to hide when referencing this namespace.
+     *
+     * @var string
+     */
+    protected $_prefix;
+
+    /**
+     * Constructor.
+     *
+     * @param string $name      The prefix identifying this namespace.
+     * @param string $delimiter The delimiter used for this namespace.
+     * @param string $prefix The prefix to hide.
+     */
+    public function __construct($name, $delimiter, $prefix)
+    {
+        parent::__construct($name, $delimiter);
+        $this->_prefix = $prefix;
+    }
+
+    /**
+     * Return an array describing the path elements of the folder.
+     *
+     * @param string $name The name of the folder.
+     *
+     * @return array The path elements.
+     */
+    protected function _subpath($name)
+    {
+        $path = parent::_subpath($name);
+        if (strpos($path[0], $this->_prefix) === 0) {
+            $path[0] = substr($path[0], strlen($this->_prefix));
+        }
+        return $path;
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Fixed.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Fixed.php
new file mode 100644 (file)
index 0000000..6ab4aa1
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/**
+ * The Horde_Kolab_Storage_Driver_Namespace_Fixed:: implements the default IMAP
+ * namespaces on the Kolab server.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Storage
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * The Horde_Kolab_Storage_Driver_Namespace_Fixed:: implements the default IMAP
+ * namespaces on the Kolab server.
+ *
+ * Copyright 2004-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 <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_Driver_Namespace_Fixed
+extends  Horde_Kolab_Storage_Driver_Namespace
+{
+    /**
+     * Indicates the personal namespace that the class will use to create new
+     * folders.
+     *
+     * @var string
+     */
+    protected $_primaryPersonalNamespace = 'INBOX';
+
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        parent::__construct();
+
+        $personal = new Horde_Kolab_Storage_Driver_Namespace_Element_Personal('INBOX/', '/');
+        $other    = new Horde_Kolab_Storage_Driver_Namespace_Element_Other('user/', '/');
+        $shared   = new Horde_Kolab_Storage_Driver_Namespace_Element_SharedWithPrefix('', '/', 'shared.');
+
+        $this->_namespaces = array($personal, $other);
+        $this->_any = $shared;
+        $this->_primaryPersonalNamespace = $personal;
+        $this->_sharedPrefix = 'shared.';
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Imap.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace/Imap.php
new file mode 100644 (file)
index 0000000..20d0314
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+/**
+ * The Horde_Kolab_Storage_Driver_Namespace_Config:: allows to use the information from
+ * the IMAP NAMESPACE command to identify the IMAP namespaces on the Kolab
+ * server.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Storage
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * The Horde_Kolab_Storage_Driver_Namespace_Config:: allows to use the information from
+ * the IMAP NAMESPACE command to identify the IMAP namespaces on the Kolab
+ * server.
+ *
+ * Copyright 2004-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 <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_Driver_Namespace_Imap
+extends  Horde_Kolab_Storage_Driver_Namespace_Config
+{
+    /**
+     * Constructor.
+     */
+    public function __construct(array $namespaces, array $configuration = array())
+    {
+        $c = array();
+        foreach ($namespaces as $namespace) {
+            if (in_array($namespace['name'], array_keys($configuration))) {
+                $namespace = array_merge($namespace, $configuration[$namespace['name']]);
+            }
+            $c[] = $namespace;
+        }
+        parent::__construct($c);
+    }
+}
\ No newline at end of file
index a26ff73..168132d 100644 (file)
@@ -403,7 +403,7 @@ extends Horde_Kolab_Storage_Driver_Base
     /**
      * Retrieve the namespace information for this connection.
      *
-     * @return Horde_Kolab_Storage_Namespace The initialized namespace handler.
+     * @return Horde_Kolab_Storage_Driver_Namespace The initialized namespace handler.
      */
     public function getNamespace()
     {
@@ -426,7 +426,7 @@ extends Horde_Kolab_Storage_Driver_Base
                     $namespaces[] = $namespace;
                 }
             }
-            return new Horde_Kolab_Storage_Namespace_Imap(
+            return new Horde_Kolab_Storage_Driver_Namespace_Imap(
                 $namespaces,
                 $this->getParam('namespaces', array())
             );
index aba5f6f..8e91fa5 100644 (file)
@@ -496,10 +496,10 @@ implements Horde_Kolab_Storage_Folder
              * rather than in a module nearer to the applications.
              */
             switch ($owner) {
-            case Horde_Kolab_Storage_Namespace::PERSONAL:
+            case Horde_Kolab_Storage_Driver_Namespace::PERSONAL:
                 $this->_owner = $this->_driver->getAuth();
                 break;
-            case Horde_Kolab_Storage_Namespace::SHARED:
+            case Horde_Kolab_Storage_Driver_Namespace::SHARED:
                 $this->_owner = 'anonymous';
                 break;
             default:
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace.php
deleted file mode 100644 (file)
index d162881..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-<?php
-/**
- * The Horde_Kolab_Storage_Namespace:: class handles IMAP namespaces and allows
- * to derive folder information from folder names.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Storage
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Storage
- */
-
-/**
- * The Horde_Kolab_Storage_Namespace:: class handles IMAP namespaces and allows
- * to derive folder information from folder names.
- *
- * Copyright 2004-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 <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Storage
- */
-abstract class Horde_Kolab_Storage_Namespace
-implements Iterator
-{
-    /** The possible namespace types (RFC 2342 [5]) */
-    const PERSONAL = 'personal';
-    const OTHER    = 'other';
-    const SHARED   = 'shared';
-
-    /**
-     * The namespaces.
-     *
-     * @var array
-     */
-    protected $_namespaces = array();
-
-    /**
-     * The characterset this module uses to communicate with the outside world.
-     *
-     * @var string
-     */
-    protected $_charset;
-
-    /**
-     * A prefix in the shared namespaces that will be ignored/removed.
-     *
-     * @var string
-     */
-    protected $_sharedPrefix;
-
-    /**
-     * The namespace that matches any folder name not matching to another
-     * namespace.
-     *
-     * @var Horde_Kolab_Storage_Namespace_Element
-     */
-    protected $_any;
-
-    /**
-     * Indicates the personal namespace that the class will use to create new
-     * folders.
-     *
-     * @var Horde_Kolab_Storage_Namespace_Element
-     */
-    protected $_primaryPersonalNamespace;
-
-    /**
-     * A helper for iteration over the namespaces.
-     *
-     * @var array
-     */
-    protected $_iteration;
-
-    /**
-     * Constructor.
-     */
-    public function __construct()
-    {
-        $this->_charset = Horde_Nls::getCharset();
-        if (empty($this->_primaryPersonalNamespace)) {
-            $personal = null;
-            foreach ($this->_namespaces as $namespace) {
-                if ($namespace->getName() == 'INBOX') {
-                    $this->_primaryPersonalNamespace = $namespace;
-                    break;
-                }
-                if (empty($personal) && $namespace->getType() == self::PERSONAL) {
-                    $personal = $namespace;
-                }
-            }
-            if (empty($this->_primaryPersonalNamespace)) {
-                $this->_primaryPersonalNamespace = $personal;
-            }
-        }
-    }
-
-    /**
-     * Match a folder name with the corresponding namespace.
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return Horde_Kolab_Storage_Namespace_Element The corresponding namespace.
-     *
-     * @throws Horde_Kolab_Storage_Exception If the namespace of the folder
-     *                                       cannot be determined.
-     */
-    protected function matchNamespace($name)
-    {
-        foreach ($this->_namespaces as $namespace) {
-            if ($namespace->matches($name)) {
-                return $namespace;
-            }
-        }
-        if (!empty($this->_any)) {
-            return $this->_any;
-        }
-        throw new Horde_Kolab_Storage_Exception(
-            sprintf('Namespace of folder %s cannot be determined.', $name)
-        );
-    }
-
-    /**
-     * Get the character set used/expected when calling the getTitle() or
-     * setName() methods.
-     *
-     * @return string The character set.
-     */
-    public function getCharset()
-    {
-        return $this->_charset;
-    }
-
-    /**
-     * Return the title of a folder.
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return string The title of the folder.
-     */
-    public function getTitle($name)
-    {
-        $name = Horde_String::convertCharset($name, 'UTF7-IMAP', $this->_charset);
-        return $this->matchNamespace($name)->getTitle($name);
-    }
-
-    /**
-     * Return the owner of a folder.
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return string The owner of the folder.
-     */
-    public function getOwner($name)
-    {
-        $name = Horde_String::convertCharset($name, 'UTF7-IMAP', $this->_charset);
-        return $this->matchNamespace($name)->getOwner($name);
-    }
-
-    /**
-     * Get the sub path for the given folder name.
-     *
-     * @param string $name The folder name.
-     *
-     * @return string The sub path.
-     */
-    public function getSubpath($name)
-    {
-        $name = Horde_String::convertCharset($name, 'UTF7-IMAP', $this->_charset);
-        return $this->matchNamespace($name)->getSubpath($name);
-    }
-
-    /**
-     * Generate an IMAP folder name.
-     *
-     * @param string $name The new folder name.
-     *
-     * @return string The IMAP folder name.
-     */
-    public function setName($name)
-    {
-        $namespace = $this->matchNamespace($name);
-        $path = explode(':', $name);
-        if (empty($this->_sharedPrefix)
-            || (strpos($path[0], $this->_sharedPrefix) === false
-                && $namespace->getType() != self::OTHER)) {
-            array_unshift($path, $this->_primaryPersonalNamespace->getName());
-            $namespace = $this->_primaryPersonalNamespace;
-        }
-        return Horde_String::convertCharset($namespace->generateName($path), $this->_charset, 'UTF7-IMAP');
-    }
-
-    function rewind()
-    {
-        $this->_iterator = $this->_namespaces;
-        $this->_iterator[] = $this->_any;
-        return reset($this->_iterator);
-    }
-
-    function current()
-    {
-        return current($this->_iterator);
-    }
-
-    function key()
-    {
-        return key($this->_iterator);
-    }
-
-    function next()
-    {
-        return next($this->_iterator);
-    }
-
-    function valid()
-    {
-        return key($this->_iterator) !== null;
-    }
-}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Config.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Config.php
deleted file mode 100644 (file)
index e4e6ffd..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-/**
- * The Horde_Kolab_Storage_Namespace_Config:: allows to configure the available
- * IMAP namespaces on the Kolab server.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Storage
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Storage
- */
-
-/**
- * The Horde_Kolab_Storage_Namespace_Config:: allows to configure the available
- * IMAP namespaces on the Kolab server.
- *
- * Copyright 2004-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 <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Storage
- */
-class Horde_Kolab_Storage_Namespace_Config
-extends  Horde_Kolab_Storage_Namespace
-{
-    /**
-     * Constructor.
-     */
-    public function __construct(array $configuration)
-    {
-        parent::__construct();
-        foreach ($configuration as $element) {
-            if ($element['type'] == Horde_Kolab_Storage_Namespace::SHARED
-                && isset($element['prefix'])) {
-                $namespace_element = new Horde_Kolab_Storage_Namespace_Element_SharedWithPrefix(
-                    $element['name'], $element['delimiter'], $element['prefix']
-                );
-                $this->_sharedPrefix = $element['prefix'];
-            } else {
-                $class = 'Horde_Kolab_Storage_Namespace_Element_' . ucfirst($element['type']);
-                $namespace_element = new $class($element['name'], $element['delimiter']);
-            }
-            if (empty($element['name'])) {
-                $this->_any = $namespace_element;
-            } else {
-                $this->_namespaces[] = $namespace_element;
-            }
-            if (isset($element['add'])) {
-                $this->_primaryPersonalNamespace = $namespace_element;
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element.php
deleted file mode 100644 (file)
index fb1ab2e..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php
-
-abstract class Horde_Kolab_Storage_Namespace_Element
-{
-    /**
-     * The prefix identifying this namespace.
-     *
-     * @var string
-     */
-    protected $_name;
-
-    /**
-     * The delimiter used for this namespace.
-     *
-     * @var string
-     */
-    protected $_delimiter;
-
-    /**
-     * Constructor.
-     *
-     * @param string $name      The prefix identifying this namespace.
-     * @param string $delimiter The delimiter used for this namespace.
-     */
-    public function __construct($name, $delimiter)
-    {
-        if (substr($name, -1) == $delimiter) {
-            $name = substr($name, 0, -1);
-        }
-        $this->_name = $name;
-        $this->_delimiter = $delimiter;
-    }
-
-    /**
-     * Return the type of this namespace (personal, other, or shared).
-     *
-     * @return string The type.
-     */
-    abstract public function getType();
-
-    /**
-     * Return the name of this namespace.
-     *
-     * @return string The name/prefix.
-     */
-    public function getName()
-    {
-        return $this->_name;
-    }
-
-    /**
-     * Return the delimiter for this namespace.
-     *
-     * @return string The delimiter.
-     */
-    public function getDelimiter()
-    {
-        return $this->_delimiter;
-    }
-
-    /**
-     * Does the folder name lie in this namespace?
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return boolean True if the folder is element of this namespace.
-     */
-    public function matches($name)
-    {
-        return (strpos($name, $this->_name) === 0);
-    }
-
-    /**
-     * Return the owner of a folder.
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return string The owner of the folder.
-     */
-    abstract public function getOwner($name);
-
-    /**
-     * Return the title of a folder.
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return string The title of the folder.
-     */
-    public function getTitle($name)
-    {
-        return join($this->_subpath($name), ':');
-    }
-
-    /**
-     * Get the sub path for the given folder name.
-     *
-     * @param string $name The folder name.
-     *
-     * @return string The sub path.
-     */
-    public function getSubpath($name)
-    {
-        return join($this->_subpath($name), $this->_delimiter);
-    }
-
-    /**
-     * Return an array describing the path elements of the folder.
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return array The path elements.
-     */
-    protected function _subpath($name)
-    {
-        $path = explode($this->_delimiter, $name);
-        if ($path[0] == $this->_name) {
-            array_shift($path);
-        }
-        //@todo: What about the potential trailing domain?
-        return $path;
-    }
-
-    /**
-     * Generate a folder path for the given path in this namespace.
-     *
-     * @param array $path The path of the folder.
-     *
-     * @return string The name of the folder.
-     */
-    public function generateName($path)
-    {
-        return join($path, $this->_delimiter);
-    }
-
-}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/Other.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/Other.php
deleted file mode 100644 (file)
index e363d66..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-class Horde_Kolab_Storage_Namespace_Element_Other
-extends Horde_Kolab_Storage_Namespace_Element
-{
-    /**
-     * Return the type of this namespace (personal, other, or shared).
-     *
-     * @return string The type.
-     */
-    public function getType()
-    {
-        return Horde_Kolab_Storage_Namespace::OTHER;
-    }
-
-    /**
-     * Return the owner of a folder.
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return string The owner of the folder.
-     */
-    public function getOwner($name)
-    {
-        $path = explode($this->_delimiter, $name);
-        $user = $path[1];
-        if (strpos($user, '@') === false) {
-            $domain = strstr(array_pop($path), '@');
-            if (!empty($domain)) {
-                $user .= $domain;
-            }
-        }
-        return Horde_Kolab_Storage_Namespace::OTHER . ':' . $user;
-    }
-
-    /**
-     * Return an array describing the path elements of the folder.
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return array The path elements.
-     */
-    protected function _subpath($name)
-    {
-        $path = parent::_subpath($name);
-        array_shift($path);
-        return $path;
-    }
-}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/Personal.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/Personal.php
deleted file mode 100644 (file)
index a0f3686..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-class Horde_Kolab_Storage_Namespace_Element_Personal
-extends Horde_Kolab_Storage_Namespace_Element
-{
-    /**
-     * Return the type of this namespace (personal, other, or shared).
-     *
-     * @return string The type.
-     */
-    public function getType()
-    {
-        return Horde_Kolab_Storage_Namespace::PERSONAL;
-    }
-
-    /**
-     * Return the owner of a folder.
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return string The owner of the folder.
-     */
-    public function getOwner($name)
-    {
-        return Horde_Kolab_Storage_Namespace::PERSONAL;
-    }
-}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/Shared.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/Shared.php
deleted file mode 100644 (file)
index 8e63f21..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-class Horde_Kolab_Storage_Namespace_Element_Shared
-extends Horde_Kolab_Storage_Namespace_Element
-{
-    /**
-     * Return the type of this namespace (personal, other, or shared).
-     *
-     * @return string The type.
-     */
-    public function getType()
-    {
-        return Horde_Kolab_Storage_Namespace::SHARED;
-    }
-
-    /**
-     * Return the owner of a folder.
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return string The owner of the folder.
-     */
-    public function getOwner($name)
-    {
-        return Horde_Kolab_Storage_Namespace::SHARED;
-    }
-}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/SharedWithPrefix.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Element/SharedWithPrefix.php
deleted file mode 100644 (file)
index 053b0de..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-
-class Horde_Kolab_Storage_Namespace_Element_SharedWithPrefix
-extends Horde_Kolab_Storage_Namespace_Element_Shared
-{
-    /**
-     * The prefix to hide when referencing this namespace.
-     *
-     * @var string
-     */
-    protected $_prefix;
-
-    /**
-     * Constructor.
-     *
-     * @param string $name      The prefix identifying this namespace.
-     * @param string $delimiter The delimiter used for this namespace.
-     * @param string $prefix The prefix to hide.
-     */
-    public function __construct($name, $delimiter, $prefix)
-    {
-        parent::__construct($name, $delimiter);
-        $this->_prefix = $prefix;
-    }
-
-    /**
-     * Return an array describing the path elements of the folder.
-     *
-     * @param string $name The name of the folder.
-     *
-     * @return array The path elements.
-     */
-    protected function _subpath($name)
-    {
-        $path = parent::_subpath($name);
-        if (strpos($path[0], $this->_prefix) === 0) {
-            $path[0] = substr($path[0], strlen($this->_prefix));
-        }
-        return $path;
-    }
-}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Fixed.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Fixed.php
deleted file mode 100644 (file)
index 3b170b8..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-/**
- * The Horde_Kolab_Storage_Namespace_Fixed:: implements the default IMAP
- * namespaces on the Kolab server.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Storage
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Storage
- */
-
-/**
- * The Horde_Kolab_Storage_Namespace_Fixed:: implements the default IMAP
- * namespaces on the Kolab server.
- *
- * Copyright 2004-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 <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Storage
- */
-class Horde_Kolab_Storage_Namespace_Fixed
-extends  Horde_Kolab_Storage_Namespace
-{
-    /**
-     * Indicates the personal namespace that the class will use to create new
-     * folders.
-     *
-     * @var string
-     */
-    protected $_primaryPersonalNamespace = 'INBOX';
-
-    /**
-     * Constructor.
-     */
-    public function __construct()
-    {
-        parent::__construct();
-
-        $personal = new Horde_Kolab_Storage_Namespace_Element_Personal('INBOX/', '/');
-        $other    = new Horde_Kolab_Storage_Namespace_Element_Other('user/', '/');
-        $shared   = new Horde_Kolab_Storage_Namespace_Element_SharedWithPrefix('', '/', 'shared.');
-
-        $this->_namespaces = array($personal, $other);
-        $this->_any = $shared;
-        $this->_primaryPersonalNamespace = $personal;
-        $this->_sharedPrefix = 'shared.';
-    }
-}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Imap.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Imap.php
deleted file mode 100644 (file)
index b9f41ae..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/**
- * The Horde_Kolab_Storage_Namespace_Config:: allows to use the information from
- * the IMAP NAMESPACE command to identify the IMAP namespaces on the Kolab
- * server.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Storage
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Storage
- */
-
-/**
- * The Horde_Kolab_Storage_Namespace_Config:: allows to use the information from
- * the IMAP NAMESPACE command to identify the IMAP namespaces on the Kolab
- * server.
- *
- * Copyright 2004-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 <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Storage
- */
-class Horde_Kolab_Storage_Namespace_Imap
-extends  Horde_Kolab_Storage_Namespace_Config
-{
-    /**
-     * Constructor.
-     */
-    public function __construct(array $namespaces, array $configuration = array())
-    {
-        $c = array();
-        foreach ($namespaces as $namespace) {
-            if (in_array($namespace['name'], array_keys($configuration))) {
-                $namespace = array_merge($namespace, $configuration[$namespace['name']]);
-            }
-            $c[] = $namespace;
-        }
-        parent::__construct($c);
-    }
-}
\ No newline at end of file
index 4fa8357..4f28ea4 100644 (file)
@@ -31,8 +31,8 @@
   <email>jan@horde.org</email>
   <active>yes</active>
  </lead>
- <date>2010-04-27</date>
- <time>23:01:21</time>
+ <date>2010-04-28</date>
+ <time>00:43:56</time>
  <version>
   <release>0.4.0</release>
   <api>0.1.0</api>
          <file name="Base.php" role="php" />
          <file name="Log.php" role="php" />
         </dir> <!-- /lib/Horde/Kolab/Storage/Driver/Decorator -->
+        <dir name="Namespace">
+         <dir name="Element">
+          <file name="Other.php" role="php" />
+          <file name="Personal.php" role="php" />
+          <file name="Shared.php" role="php" />
+          <file name="SharedWithPrefix.php" role="php" />
+         </dir> <!-- /lib/Horde/Kolab/Storage/Driver/Namespace/Element -->
+         <file name="Config.php" role="php" />
+         <file name="Element.php" role="php" />
+         <file name="Fixed.php" role="php" />
+         <file name="Imap.php" role="php" />
+        </dir> <!-- /lib/Horde/Kolab/Storage/Driver/Namespace -->
         <file name="Base.php" role="php" />
         <file name="Cclient.php" role="php" />
         <file name="Imap.php" role="php" />
         <file name="Mock.php" role="php" />
+        <file name="Namespace.php" role="php" />
         <file name="Pear.php" role="php" />
        </dir> <!-- /lib/Horde/Kolab/Storage/Driver -->
        <dir name="Folder">
         <file name="Base.php" role="php" />
         <file name="Permission.php" role="php" />
        </dir> <!-- /lib/Horde/Kolab/Storage/Folder -->
-       <dir name="Namespace">
-        <dir name="Element">
-         <file name="Other.php" role="php" />
-         <file name="Personal.php" role="php" />
-         <file name="Shared.php" role="php" />
-         <file name="SharedWithPrefix.php" role="php" />
-        </dir> <!-- /lib/Horde/Kolab/Storage/Namespace/Element -->
-        <file name="Config.php" role="php" />
-        <file name="Element.php" role="php" />
-        <file name="Fixed.php" role="php" />
-        <file name="Imap.php" role="php" />
-       </dir> <!-- /lib/Horde/Kolab/Storage/Namespace -->
        <file name="Cache.php" role="php" />
        <file name="Data.php" role="php" />
        <file name="Driver.php" role="php" />
        <file name="Exception.php" role="php" />
        <file name="Folder.php" role="php" />
-       <file name="Namespace.php" role="php" />
       </dir> <!-- /lib/Horde/Kolab/Storage -->
       <file name="Storage.php" role="php" />
      </dir> <!-- /lib/Horde/Kolab -->
     <dir name="Horde">
      <dir name="Kolab">
       <dir name="Storage">
-       <file name="test_drivers.php" role="script">
-        <tasks:replace from="@PHP-TEST-DIR@" to="test_dir" type="pear-config" />
-       </file>
+       <file name="test_drivers.php" role="script" />
       </dir> <!-- /script/Horde/Kolab/Storage -->
      </dir> <!-- /script/Horde/Kolab -->
     </dir> <!-- /script/Horde -->
       <dir name="Storage">
        <dir name="Class">
         <dir name="Driver">
+         <file name="CclientTest.php" role="test" />
+         <file name="ImapTest.php" role="test" />
          <file name="MockTest.php" role="test" />
+         <file name="PearTest.php" role="test" />
         </dir> <!-- /test/Horde/Kolab/Storage/Class/Driver -->
        </dir> <!-- /test/Horde/Kolab/Storage/Class -->
        <dir name="Server">
    <install as="Horde/Kolab/Storage/Driver.php" name="lib/Horde/Kolab/Storage/Driver.php" />
    <install as="Horde/Kolab/Storage/Exception.php" name="lib/Horde/Kolab/Storage/Exception.php" />
    <install as="Horde/Kolab/Storage/Folder.php" name="lib/Horde/Kolab/Storage/Folder.php" />
-   <install as="Horde/Kolab/Storage/Namespace.php" name="lib/Horde/Kolab/Storage/Namespace.php" />
    <install as="Horde/Kolab/Storage/Driver/Base.php" name="lib/Horde/Kolab/Storage/Driver/Base.php" />
    <install as="Horde/Kolab/Storage/Driver/Cclient.php" name="lib/Horde/Kolab/Storage/Driver/Cclient.php" />
    <install as="Horde/Kolab/Storage/Driver/Imap.php" name="lib/Horde/Kolab/Storage/Driver/Imap.php" />
    <install as="Horde/Kolab/Storage/Driver/Mock.php" name="lib/Horde/Kolab/Storage/Driver/Mock.php" />
+   <install as="Horde/Kolab/Storage/Driver/Namespace.php" name="lib/Horde/Kolab/Storage/Driver/Namespace.php" />
    <install as="Horde/Kolab/Storage/Driver/Pear.php" name="lib/Horde/Kolab/Storage/Driver/Pear.php" />
    <install as="Horde/Kolab/Storage/Driver/Decorator/Base.php" name="lib/Horde/Kolab/Storage/Driver/Decorator/Base.php" />
    <install as="Horde/Kolab/Storage/Driver/Decorator/Log.php" name="lib/Horde/Kolab/Storage/Driver/Decorator/Log.php" />
+   <install as="Horde/Kolab/Storage/Driver/Namespace/Config.php" name="lib/Horde/Kolab/Storage/Driver/Namespace/Config.php" />
+   <install as="Horde/Kolab/Storage/Driver/Namespace/Element.php" name="lib/Horde/Kolab/Storage/Driver/Namespace/Element.php" />
+   <install as="Horde/Kolab/Storage/Driver/Namespace/Fixed.php" name="lib/Horde/Kolab/Storage/Driver/Namespace/Fixed.php" />
+   <install as="Horde/Kolab/Storage/Driver/Namespace/Imap.php" name="lib/Horde/Kolab/Storage/Driver/Namespace/Imap.php" />
+   <install as="Horde/Kolab/Storage/Driver/Namespace/Element/Other.php" name="lib/Horde/Kolab/Storage/Driver/Namespace/Element/Other.php" />
+   <install as="Horde/Kolab/Storage/Driver/Namespace/Element/Personal.php" name="lib/Horde/Kolab/Storage/Driver/Namespace/Element/Personal.php" />
+   <install as="Horde/Kolab/Storage/Driver/Namespace/Element/Shared.php" name="lib/Horde/Kolab/Storage/Driver/Namespace/Element/Shared.php" />
+   <install as="Horde/Kolab/Storage/Driver/Namespace/Element/SharedWithPrefix.php" name="lib/Horde/Kolab/Storage/Driver/Namespace/Element/SharedWithPrefix.php" />
    <install as="Horde/Kolab/Storage/Folder/Base.php" name="lib/Horde/Kolab/Storage/Folder/Base.php" />
    <install as="Horde/Kolab/Storage/Folder/Permission.php" name="lib/Horde/Kolab/Storage/Folder/Permission.php" />
    <install as="Horde/Kolab/Storage/Folder/Decorator/Base.php" name="lib/Horde/Kolab/Storage/Folder/Decorator/Base.php" />
    <install as="Horde/Kolab/Storage/Folder/Permission/Element/Group.php" name="lib/Horde/Kolab/Storage/Folder/Permission/Element/Group.php" />
    <install as="Horde/Kolab/Storage/Folder/Permission/Element/Guest.php" name="lib/Horde/Kolab/Storage/Folder/Permission/Element/Guest.php" />
    <install as="Horde/Kolab/Storage/Folder/Permission/Element/User.php" name="lib/Horde/Kolab/Storage/Folder/Permission/Element/User.php" />
-   <install as="Horde/Kolab/Storage/Namespace/Config.php" name="lib/Horde/Kolab/Storage/Namespace/Config.php" />
-   <install as="Horde/Kolab/Storage/Namespace/Element.php" name="lib/Horde/Kolab/Storage/Namespace/Element.php" />
-   <install as="Horde/Kolab/Storage/Namespace/Fixed.php" name="lib/Horde/Kolab/Storage/Namespace/Fixed.php" />
-   <install as="Horde/Kolab/Storage/Namespace/Imap.php" name="lib/Horde/Kolab/Storage/Namespace/Imap.php" />
-   <install as="Horde/Kolab/Storage/Namespace/Element/Other.php" name="lib/Horde/Kolab/Storage/Namespace/Element/Other.php" />
-   <install as="Horde/Kolab/Storage/Namespace/Element/Personal.php" name="lib/Horde/Kolab/Storage/Namespace/Element/Personal.php" />
-   <install as="Horde/Kolab/Storage/Namespace/Element/Shared.php" name="lib/Horde/Kolab/Storage/Namespace/Element/Shared.php" />
-   <install as="Horde/Kolab/Storage/Namespace/Element/SharedWithPrefix.php" name="lib/Horde/Kolab/Storage/Namespace/Element/SharedWithPrefix.php" />
    <install as="test_drivers" name="script/Horde/Kolab/Storage/test_drivers.php" />
    <install as="Horde/Kolab/Storage/AclTest.php" name="test/Horde/Kolab/Storage/AclTest.php" />
    <install as="Horde/Kolab/Storage/AllTests.php" name="test/Horde/Kolab/Storage/AllTests.php" />
    <install as="Horde/Kolab/Storage/Scenario.php" name="test/Horde/Kolab/Storage/Scenario.php" />
    <install as="Horde/Kolab/Storage/StorageTest.php" name="test/Horde/Kolab/Storage/StorageTest.php" />
    <install as="Horde/Kolab/Storage/TriggerTest.php" name="test/Horde/Kolab/Storage/TriggerTest.php" />
+   <install as="Horde/Kolab/Storage/Class/Driver/CclientTest.php" name="test/Horde/Kolab/Storage/Class/Driver/CclientTest.php" />
+   <install as="Horde/Kolab/Storage/Class/Driver/ImapTest.php" name="test/Horde/Kolab/Storage/Class/Driver/ImapTest.php" />
    <install as="Horde/Kolab/Storage/Class/Driver/MockTest.php" name="test/Horde/Kolab/Storage/Class/Driver/MockTest.php" />
+   <install as="Horde/Kolab/Storage/Class/Driver/PearTest.php" name="test/Horde/Kolab/Storage/Class/Driver/PearTest.php" />
    <install as="Horde/Kolab/Storage/Server/DriverTest.php" name="test/Horde/Kolab/Storage/Server/DriverTest.php" />
   </filelist>
  </phprelease>
     <release>alpha</release>
     <api>alpha</api>
    </stability>
-   <date>2010-04-27</date>
+   <date>2010-04-28</date>
    <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
    <notes>
 * Added namespace support (Bug #6691).
index 109d8b2..f115c1f 100644 (file)
@@ -45,17 +45,17 @@ class Horde_Kolab_Storage_AclTest extends PHPUnit_Framework_TestCase
                     array(
                         array(
                             'name'      => 'INBOX/',
-                            'type'      =>  Horde_Kolab_Storage_Namespace::PERSONAL,
+                            'type'      =>  Horde_Kolab_Storage_Driver_Namespace::PERSONAL,
                             'delimiter' => '/',
                         ),
                         array(
                             'name'      => 'user/',
-                            'type'      =>  Horde_Kolab_Storage_Namespace::OTHER,
+                            'type'      =>  Horde_Kolab_Storage_Driver_Namespace::OTHER,
                             'delimiter' => '/',
                         ),
                         array(
                             'name'      => '',
-                            'type'      =>  Horde_Kolab_Storage_Namespace::SHARED,
+                            'type'      =>  Horde_Kolab_Storage_Driver_Namespace::SHARED,
                             'delimiter' => '/',
                         )
                     )
index 75e96f1..8696378 100644 (file)
@@ -51,7 +51,7 @@ extends PHPUnit_Framework_TestCase
             array()
         );
         $this->assertType(
-            'Horde_Kolab_Storage_Namespace',
+            'Horde_Kolab_Storage_Driver_Namespace',
             $driver->getNamespace()
         );
     }
index f52ae74..7546434 100644 (file)
@@ -52,7 +52,7 @@ extends PHPUnit_Framework_TestCase
             array()
         );
         $this->assertType(
-            'Horde_Kolab_Storage_Namespace',
+            'Horde_Kolab_Storage_Driver_Namespace',
             $driver->getNamespace()
         );
     }
index aaed025..78a645f 100644 (file)
@@ -67,7 +67,7 @@ extends PHPUnit_Framework_TestCase
             array()
         );
         $this->assertType(
-            'Horde_Kolab_Storage_Namespace',
+            'Horde_Kolab_Storage_Driver_Namespace',
             $driver->getNamespace()
         );
     }
index 17d2224..5607858 100644 (file)
@@ -52,7 +52,7 @@ extends PHPUnit_Framework_TestCase
             array()
         );
         $this->assertType(
-            'Horde_Kolab_Storage_Namespace',
+            'Horde_Kolab_Storage_Driver_Namespace',
             $driver->getNamespace()
         );
     }
index 5c6b9fe..da160bf 100644 (file)
@@ -66,7 +66,7 @@ class Horde_Kolab_Storage_FolderTest extends PHPUnit_Framework_TestCase
         $GLOBALS['language'] = 'de_DE';
         $folder = new Horde_Kolab_Storage_Folder_Base(
             'INBOX/Contacts',
-            new Horde_Kolab_Storage_Namespace_Fixed()
+            new Horde_Kolab_Storage_Driver_Namespace_Fixed()
         );
         $this->assertEquals('INBOX/Contacts', $folder->name);
         $this->assertTrue(is_array($folder->_data));
@@ -84,7 +84,7 @@ class Horde_Kolab_Storage_FolderTest extends PHPUnit_Framework_TestCase
         $connection = $this->getMock('Horde_Kolab_Storage_Driver');
         $connection->expects($this->once())
             ->method('getNamespace')
-            ->will($this->returnValue(new Horde_Kolab_Storage_Namespace_Fixed()));
+            ->will($this->returnValue(new Horde_Kolab_Storage_Driver_Namespace_Fixed()));
         $folder = new Horde_Kolab_Storage_Folder_Base('INBOX/Contacts');
         $folder->restore($storage, $connection);
         $folder->setName('TestAÖÜ');
index 9af2982..bbdce74 100644 (file)
@@ -266,43 +266,43 @@ class Horde_Kolab_Storage_NamespaceTest extends PHPUnit_Framework_TestCase
     private function _getNamespaces()
     {
         return array(
-            new Horde_Kolab_Storage_Namespace_Fixed(),
-            new Horde_Kolab_Storage_Namespace_Config(
+            new Horde_Kolab_Storage_Driver_Namespace_Fixed(),
+            new Horde_Kolab_Storage_Driver_Namespace_Config(
                 array(
                     array(
-                        'type' => Horde_Kolab_Storage_Namespace::PERSONAL,
+                        'type' => Horde_Kolab_Storage_Driver_Namespace::PERSONAL,
                         'name' => 'INBOX/',
                         'delimiter' => '/',
                         'add' => true,
                     ),
                     array(
-                        'type' => Horde_Kolab_Storage_Namespace::OTHER,
+                        'type' => Horde_Kolab_Storage_Driver_Namespace::OTHER,
                         'name' => 'user/',
                         'delimiter' => '/',
                     ),
                     array(
-                        'type' => Horde_Kolab_Storage_Namespace::SHARED,
+                        'type' => Horde_Kolab_Storage_Driver_Namespace::SHARED,
                         'name' => '',
                         'delimiter' => '/',
                         'prefix' => 'shared.'
                     ),
                 )
             ),
-            new Horde_Kolab_Storage_Namespace_Imap(
+            new Horde_Kolab_Storage_Driver_Namespace_Imap(
                 array(
                     array(
                         'name'      => 'INBOX/',
-                        'type'      =>  Horde_Kolab_Storage_Namespace::PERSONAL,
+                        'type'      =>  Horde_Kolab_Storage_Driver_Namespace::PERSONAL,
                         'delimiter' => '/',
                     ),
                     array(
                         'name'      => 'user/',
-                        'type'      =>  Horde_Kolab_Storage_Namespace::OTHER,
+                        'type'      =>  Horde_Kolab_Storage_Driver_Namespace::OTHER,
                         'delimiter' => '/',
                     ),
                     array(
                         'name'      => '',
-                        'type'      =>  Horde_Kolab_Storage_Namespace::SHARED,
+                        'type'      =>  Horde_Kolab_Storage_Driver_Namespace::SHARED,
                         'delimiter' => '/',
                     ),
                 ),
index 47aec9e..8add6ed 100644 (file)
@@ -124,10 +124,10 @@ class Horde_Kolab_Storage_PermissionTest extends PHPUnit_Framework_TestCase
             ->method('getNamespace')
             ->will(
                 $this->returnValue(
-                    new Horde_Kolab_Storage_Namespace_Imap(
+                    new Horde_Kolab_Storage_Driver_Namespace_Imap(
                         array(
                             array(
-                                'type' => Horde_Kolab_Storage_Namespace::PERSONAL,
+                                'type' => Horde_Kolab_Storage_Driver_Namespace::PERSONAL,
                                 'name' => 'INBOX/',
                                 'delimiter' => '/',
                                 'add' => true,
@@ -257,10 +257,10 @@ class Horde_Kolab_Storage_PermissionTest extends PHPUnit_Framework_TestCase
             ->method('getNamespace')
             ->will(
                 $this->returnValue(
-                    new Horde_Kolab_Storage_Namespace_Imap(
+                    new Horde_Kolab_Storage_Driver_Namespace_Imap(
                         array(
                             array(
-                                'type' => Horde_Kolab_Storage_Namespace::PERSONAL,
+                                'type' => Horde_Kolab_Storage_Driver_Namespace::PERSONAL,
                                 'name' => 'INBOX/',
                                 'delimiter' => '/',
                                 'add' => true,