Add the other two namespace drivers.
authorGunnar Wrobel <p@rdus.de>
Mon, 22 Mar 2010 16:28:07 +0000 (17:28 +0100)
committerGunnar Wrobel <wrobel@temple.(none)>
Tue, 23 Mar 2010 06:53:32 +0000 (07:53 +0100)
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Config.php [new file with mode: 0644]
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Imap.php [new file with mode: 0644]
framework/Kolab_Storage/package.xml
framework/Kolab_Storage/test/Horde/Kolab/Storage/NamespaceTest.php

diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Config.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace/Config.php
new file mode 100644 (file)
index 0000000..b1f8f05
--- /dev/null
@@ -0,0 +1,81 @@
+<?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
+{
+    /**
+     * The namespaces.
+     *
+     * @var array
+     */
+    protected $_namespaces = array(
+        self::PRIV => array(
+            'INBOX' => '/',
+        ),
+        self::OTHER => array(
+            'user' => '/',
+        ),
+        self::SHARED => array(
+            '' => '/',
+        ),
+    );
+
+    /**
+     * A prefix in the shared namespaces that will be ignored/removed.
+     *
+     * @var string
+     */
+    protected $_sharedPrefix = '';
+
+    /**
+     * Indicates the personal namespace that the class will use to create new
+     * folders.
+     *
+     * @var string
+     */
+    protected $_primaryPersonalNamespace = 'INBOX';
+
+    /**
+     * Constructor.
+     */
+    public function __construct(array $configuration)
+    {
+        if (isset($configuration['elements'])) {
+            $this->_namespaces = $configuration['elements'];
+        }
+        if (isset($configuration['shared_prefix'])) {
+            $this->_sharedPrefix = $configuration['shared_prefix'];
+        }
+        if (isset($configuration['add_namespace'])) {
+            $this->_primaryPersonalNamespace = $configuration['add_namespace'];
+        }
+        $this->_charset = Horde_Nls::getCharset();
+    }
+}
\ 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
new file mode 100644 (file)
index 0000000..89a9ae5
--- /dev/null
@@ -0,0 +1,73 @@
+<?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
+{
+    /**
+     * The namespaces.
+     *
+     * @var array
+     */
+    protected $_namespaces = array();
+
+    /**
+     * A prefix in the shared namespaces that will be ignored/removed.
+     *
+     * @var string
+     */
+    protected $_sharedPrefix = '';
+
+    /**
+     * Indicates the personal namespace that the class will use to create new
+     * folders.
+     *
+     * @var string
+     */
+    protected $_primaryPersonalNamespace = 'INBOX';
+
+    /**
+     * Constructor.
+     */
+    public function __construct(array $namespaces, array $configuration)
+    {
+        foreach ($namespaces as $namespace) {
+            $this->_namespaces[$namespace['type']][$namespace['name']] = $namespace['delimiter'];
+        }
+        if (isset($configuration['shared_prefix'])) {
+            $this->_sharedPrefix = $configuration['shared_prefix'];
+        }
+        if (isset($configuration['add_namespace'])) {
+            $this->_primaryPersonalNamespace = $configuration['add_namespace'];
+        }
+        $this->_charset = Horde_Nls::getCharset();
+    }
+}
\ No newline at end of file
index 74d52cd..30b4073 100644 (file)
@@ -81,7 +81,9 @@
        <file name="Folder.php" role="php" />
        <file name="Namespace.php" role="php" />
        <dir name="Namespace">
+        <file name="Config.php" role="php" />
         <file name="Fixed.php" role="php" />
+        <file name="Imap.php" role="php" />
        </dir> <!-- /lib/Horde/Kolab/Storage/Namespace -->
        <file name="Permission.php" role="php" />
       </dir> <!-- /lib/Horde/Kolab/Storage -->
    <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/Namespace/Config.php" name="lib/Horde/Kolab/Storage/Namespace/Config.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/Permission.php" name="lib/Horde/Kolab/Storage/Permission.php" />
    <install as="Horde/Kolab/Storage/Driver/Imap.php" name="lib/Horde/Kolab/Storage/Driver/Imap.php" />
    <install as="Horde/Kolab/Storage/AllTests.php" name="test/Horde/Kolab/Storage/AllTests.php" />
index f2de7d4..bc949de 100644 (file)
@@ -267,7 +267,48 @@ 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_Fixed(),
+            new Horde_Kolab_Storage_Namespace_Config(
+                array(
+                    'elements' => array(
+                        Horde_Kolab_Storage_Namespace::PRIV => array(
+                            'INBOX' => '/',
+                        ),
+                        Horde_Kolab_Storage_Namespace::OTHER => array(
+                            'user' => '/',
+                        ),
+                        Horde_Kolab_Storage_Namespace::SHARED => array(
+                            '' => '/',
+                        ),
+                    ),
+                    'shared_prefix' => 'shared.',
+                    'add_namespace' => 'INBOX',
+                )
+            ),
+            new Horde_Kolab_Storage_Namespace_Imap(
+                array(
+                    array(
+                        'name'      => 'INBOX',
+                        'type'      =>  Horde_Kolab_Storage_Namespace::PRIV,
+                        'delimiter' => '/',
+                    ),
+                    array(
+                        'name'      => 'user',
+                        'type'      =>  Horde_Kolab_Storage_Namespace::OTHER,
+                        'delimiter' => '/',
+                    ),
+                    array(
+                        'name'      => '',
+                        'type'      =>  Horde_Kolab_Storage_Namespace::SHARED,
+                        'delimiter' => '/',
+                    ),
+                ),
+                array(
+                    'shared_prefix' => 'shared.',
+                    'add_namespace' => 'INBOX',
+                )
+            ),
+            
         );
     }
 }
\ No newline at end of file