Additional abstract methods.
authorGunnar Wrobel <p@rdus.de>
Wed, 11 Feb 2009 23:20:30 +0000 (23:20 +0000)
committerGunnar Wrobel <p@rdus.de>
Wed, 11 Feb 2009 23:20:30 +0000 (23:20 +0000)
framework/Kolab_Server/lib/Horde/Kolab/Server.php
framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php
framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/testTest.php

index bee428c..7894d94 100644 (file)
@@ -166,16 +166,6 @@ abstract class Horde_Kolab_Server
     }
 
     /**
-     * Return the root of the UID values on this server.
-     *
-     * @return string The base UID on this server (base DN on ldap).
-     */
-    public function getBaseUid()
-    {
-        return '';
-    }
-
-    /**
      * Fetch a Kolab object.
      *
      * This method will not necessarily retrieve any data from the server and
@@ -194,7 +184,7 @@ abstract class Horde_Kolab_Server
             $uid = $this->uid;
         }
         if (empty($type)) {
-            $type = $this->_determineType($uid);
+            $type = $this->determineType($uid);
             if (is_a($type, 'PEAR_Error')) {
                 return $type;
             }
@@ -240,15 +230,13 @@ abstract class Horde_Kolab_Server
     }
 
     /**
-     * Determine the type of a Kolab object.
-     *
-     * @param string $uid The UID of the object to examine.
+     * Return the root of the UID values on this server.
      *
-     * @return string The corresponding Kolab object type.
+     * @return string The base UID on this server (base DN on ldap).
      */
-    function _determineType($uid)
+    public function getBaseUid()
     {
-        return KOLAB_OBJECT_USER;
+        return '';
     }
 
     /**
@@ -303,7 +291,7 @@ abstract class Horde_Kolab_Server
      * @return mixed|PEAR_Error The UID or false if there was no result.
      */
     public function uidForAttr($attr, $value,
-                       $restrict = KOLAB_SERVER_RESULT_SINGLE)
+                               $restrict = KOLAB_SERVER_RESULT_SINGLE)
     {
         /* In the default class we just return false */
         return false;
@@ -320,7 +308,7 @@ abstract class Horde_Kolab_Server
      * @return mixed|PEAR_Error The GID or false if there was no result.
      */
     public function gidForAttr($attr, $value,
-                        $restrict = KOLAB_SERVER_RESULT_SINGLE)
+                               $restrict = KOLAB_SERVER_RESULT_SINGLE)
     {
         /* In the default class we just return false */
         return false;
@@ -350,7 +338,7 @@ abstract class Horde_Kolab_Server
      * @return mixed|PEAR_Error The UID or false if there was no result.
      */
     public function uidForId($id,
-                      $restrict = KOLAB_SERVER_RESULT_SINGLE)
+                             $restrict = KOLAB_SERVER_RESULT_SINGLE)
     {
         return $this->uidForAttr('uid', $id);
     }
@@ -364,7 +352,7 @@ abstract class Horde_Kolab_Server
      * @return mixed|PEAR_Error The UID or false if there was no result.
      */
     public function uidForMail($mail,
-                        $restrict = KOLAB_SERVER_RESULT_SINGLE)
+                               $restrict = KOLAB_SERVER_RESULT_SINGLE)
     {
         return $this->uidForAttr('mail', $mail);
     }
@@ -378,7 +366,7 @@ abstract class Horde_Kolab_Server
      * @return mixed|PEAR_Error The GID or false if there was no result.
      */
     public function gidForMail($mail,
-                        $restrict = KOLAB_SERVER_RESULT_SINGLE)
+                               $restrict = KOLAB_SERVER_RESULT_SINGLE)
     {
         return $this->gidForAttr('mail', $mail);
     }
@@ -408,7 +396,7 @@ abstract class Horde_Kolab_Server
      * @return mixed|PEAR_Error The UID or false if there was no result.
      */
     public function uidForAlias($mail,
-                      $restrict = KOLAB_SERVER_RESULT_SINGLE)
+                                $restrict = KOLAB_SERVER_RESULT_SINGLE)
     {
         return $this->uidForAttr('alias', $mail);
     }
@@ -461,7 +449,7 @@ abstract class Horde_Kolab_Server
      */
     public function listHash($type, $params = null)
     {
-        $list = $this->_listObjects($type, $params);
+        $list = $this->listObjects($type, $params);
         if (is_a($list, 'PEAR_Error')) {
             return $list;
         }
@@ -481,32 +469,6 @@ abstract class Horde_Kolab_Server
     }
 
     /**
-     * List all objects of a specific type
-     *
-     * @param string $type   The type of the objects to be listed
-     * @param array  $params Additional parameters.
-     *
-     * @return array|PEAR_Error An array of Kolab objects.
-     */
-    public function listObjects($type, $params = null)
-    {
-        return $this->_listObjects($type, $params);
-    }
-
-    /**
-     * List all objects of a specific type
-     *
-     * @param string $type   The type of the objects to be listed
-     * @param array  $params Additional parameters.
-     *
-     * @return array|PEAR_Error An array of Kolab objects.
-     */
-    public function _listObjects($type, $params = null)
-    {
-        return array();
-    }
-
-    /**
      * Generates a unique ID for the given information.
      *
      * @param string $type The type of the object to create.
@@ -527,7 +489,7 @@ abstract class Horde_Kolab_Server
         if (is_a($id, 'PEAR_Error')) {
             return $id;
         }
-        return $this->_generateUid($type, $id, $info);
+        return $this->generateServerUid($type, $id, $info);
     }
 
     /**
@@ -541,6 +503,25 @@ abstract class Horde_Kolab_Server
     abstract public function read($uid, $attrs = null);
 
     /**
+     * Determine the type of a Kolab object.
+     *
+     * @param string $uid The UID of the object to examine.
+     *
+     * @return string The corresponding Kolab object type.
+     */
+    abstract protected function determineType($uid);
+
+    /**
+     * List all objects of a specific type
+     *
+     * @param string $type   The type of the objects to be listed
+     * @param array  $params Additional parameters.
+     *
+     * @return array|PEAR_Error An array of Kolab objects.
+     */
+    abstract public function listObjects($type, $params = null);
+
+    /**
      * Generates a UID for the given information.
      *
      * @param string $type The type of the object to create.
@@ -549,6 +530,6 @@ abstract class Horde_Kolab_Server
      *
      * @return string|PEAR_Error The UID.
      */
-    abstract protected function _generateUid($type, $id, $info);
+    abstract protected function generateServerUid($type, $id, $info);
 
 }
index 96bf026..06b8275 100644 (file)
@@ -561,7 +561,7 @@ class Horde_Kolab_Server_ldap extends Horde_Kolab_Server
      *
      * @return int The corresponding Kolab object type.
      */
-    function _determineType($dn)
+    function determineType($dn)
     {
         $oc = $this->_getObjectClasses($dn);
         if (is_a($oc, 'PEAR_Error')) {
@@ -851,7 +851,7 @@ class Horde_Kolab_Server_ldap extends Horde_Kolab_Server
      *
      * @return array|PEAR_Error An array of Kolab objects.
      */
-    function _listObjects($type, $params = null)
+    function listObjects($type, $params = null)
     {
         if (empty($params['base_dn'])) {
             $base = $this->_base_dn;
@@ -932,7 +932,7 @@ class Horde_Kolab_Server_ldap extends Horde_Kolab_Server
      *
      * @return string|PEAR_Error The DN.
      */
-    function _generateUid($type, $id, $info)
+    function generateServerUid($type, $id, $info)
     {
         switch ($type) {
         case KOLAB_OBJECT_USER:
index e4f3218..7a05d66 100644 (file)
@@ -101,6 +101,31 @@ class Horde_Kolab_Server_none extends Horde_Kolab_Server
     }
 
     /**
+     * Determine the type of a Kolab object.
+     *
+     * @param string $uid The UID of the object to examine.
+     *
+     * @return string The corresponding Kolab object type.
+     */
+    protected function determineType($uid)
+    {
+        return KOLAB_OBJECT_USER;
+    }
+
+    /**
+     * List all objects of a specific type
+     *
+     * @param string $type   The type of the objects to be listed
+     * @param array  $params Additional parameters.
+     *
+     * @return array|PEAR_Error An array of Kolab objects.
+     */
+    public function listObjects($type, $params = null)
+    {
+        return array();
+    }
+
+    /**
      * Generates a UID for the given information.
      *
      * @param string $type The type of the object to create.
@@ -109,7 +134,7 @@ class Horde_Kolab_Server_none extends Horde_Kolab_Server
      *
      * @return string|PEAR_Error The UID.
      */
-    protected function _generateUid($type, $id, $info)
+    protected function generateServerUid($type, $id, $info)
     {
         return $id;
     }
index 9db3f11..ca851a8 100644 (file)
@@ -139,31 +139,31 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
      */
     public function testDetermineType()
     {
-        $type = $this->ldap->_determineType('cn=empty.group@example.org,dc=example,dc=org');
+        $type = $this->ldap->determineType('cn=empty.group@example.org,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals(KOLAB_OBJECT_GROUP, $type);
 
-        $type = $this->ldap->_determineType('cn=shared@example.org,dc=example,dc=org');
+        $type = $this->ldap->determineType('cn=shared@example.org,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals(KOLAB_OBJECT_SHAREDFOLDER, $type);
 
-        $type = $this->ldap->_determineType('cn=The Administrator,dc=example,dc=org');
+        $type = $this->ldap->determineType('cn=The Administrator,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals(KOLAB_OBJECT_ADMINISTRATOR, $type);
 
-        $type = $this->ldap->_determineType('cn=Main Tainer,dc=example,dc=org');
+        $type = $this->ldap->determineType('cn=Main Tainer,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals(KOLAB_OBJECT_MAINTAINER, $type);
 
-        $type = $this->ldap->_determineType('cn=Domain Maintainer,dc=example,dc=org');
+        $type = $this->ldap->determineType('cn=Domain Maintainer,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals(KOLAB_OBJECT_DOMAINMAINTAINER, $type);
 
-        $type = $this->ldap->_determineType('cn=Test Address,cn=external,dc=example,dc=org');
+        $type = $this->ldap->determineType('cn=Test Address,cn=external,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals(KOLAB_OBJECT_ADDRESS, $type);
 
-        $type = $this->ldap->_determineType('cn=Gunnar Wrobel,dc=example,dc=org');
+        $type = $this->ldap->determineType('cn=Gunnar Wrobel,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals(KOLAB_OBJECT_USER, $type);
     }