Remove functions that are unnecessary.
authorGunnar Wrobel <p@rdus.de>
Wed, 11 Feb 2009 23:06:38 +0000 (23:06 +0000)
committerGunnar Wrobel <p@rdus.de>
Wed, 11 Feb 2009 23:06:38 +0000 (23:06 +0000)
framework/Kolab_Server/lib/Horde/Kolab/Server.php
framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php
framework/Kolab_Server/lib/Horde/Kolab/Server/test.php
framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/ldapTest.php

index bb5bc00..bee428c 100644 (file)
@@ -178,6 +178,11 @@ abstract class Horde_Kolab_Server
     /**
      * Fetch a Kolab object.
      *
+     * This method will not necessarily retrieve any data from the server and
+     * might simply generate a new instance for hte desired object. This method
+     * can also be used in order to fetch non-existing objects that will be
+     * saved later.
+     *
      * @param string $uid  The UID of the object to fetch.
      * @param string $type The type of the object to fetch.
      *
@@ -235,80 +240,6 @@ abstract class Horde_Kolab_Server
     }
 
     /**
-     * Update or create a Kolab object.
-     *
-     * @param string $type The type of the object to store.
-     * @param array  $info Any additional information about the object to store.
-     * @param string $uid  The unique id of the object to store.
-     *
-     * @return Kolab_Object|PEAR_Error The updated Kolab object.
-     */
-    public function &store($type, $info, $uid = null)
-    {
-        if (empty($uid)) {
-            $uid = $this->generateUid($type, $info);
-        }
-
-        $object = &Horde_Kolab_Server_Object::factory($type, $uid, $this);
-        $result = $object->save($info);
-        if (is_a($result, 'PEAR_Error')) {
-            return $result;
-        }
-        return $object;
-    }
-
-    /**
-     * Get the groups for this object
-     *
-     * @param string $uid The UID of the object to fetch.
-     *
-     * @return array|PEAR_Error An array of group ids.
-     */
-    public function getGroups($uid)
-    {
-        return array();
-    }
-
-    /**
-     * Read object data.
-     *
-     * @param string $uid   The object to retrieve.
-     * @param string $attrs Restrict to these attributes.
-     *
-     * @return array|PEAR_Error An array of attributes.
-     */
-    public function read($uid, $attrs = null)
-    {
-        return $this->_read($uid, $attrs);
-    }
-
-    /**
-     * Stub for reading object data.
-     *
-     * @param string $uid   The object to retrieve.
-     * @param string $attrs Restrict to these attributes.
-     *
-     * @return array|PEAR_Error An array of attributes.
-     */
-    function _read($uid, $attrs = null)
-    {
-        return PEAR::raiseError(_("Not implemented!"));
-    }
-
-    /**
-     * Stub for saving object data.
-     *
-     * @param string $uid  The object to save.
-     * @param string $data The data of the object.
-     *
-     * @return array|PEAR_Error An array of attributes.
-     */
-    public function save($uid, $data)
-    {
-        return PEAR::raiseError(_("Not implemented!"));
-    }
-
-    /**
      * Determine the type of a Kolab object.
      *
      * @param string $uid The UID of the object to examine.
@@ -600,6 +531,16 @@ abstract class Horde_Kolab_Server
     }
 
     /**
+     * Stub for reading object data.
+     *
+     * @param string $uid   The object to retrieve.
+     * @param string $attrs Restrict to these attributes.
+     *
+     * @return array|PEAR_Error An array of attributes.
+     */
+    abstract public function read($uid, $attrs = null);
+
+    /**
      * Generates a UID for the given information.
      *
      * @param string $type The type of the object to create.
index 9311175..96bf026 100644 (file)
@@ -199,7 +199,7 @@ class Horde_Kolab_Server_ldap extends Horde_Kolab_Server
      *
      * @return array|PEAR_Error An array of attributes.
      */
-    function _read($dn, $attrs = null)
+    function read($dn, $attrs = null)
     {
         if (!$this->_bound) {
             $result = $this->_bind();
@@ -616,7 +616,7 @@ class Horde_Kolab_Server_ldap extends Horde_Kolab_Server
      */
     function _getObjectClasses($dn)
     {
-        $object = $this->_read($dn, array('objectClass'));
+        $object = $this->read($dn, array('objectClass'));
         if (is_a($object, 'PEAR_Error')) {
             return $object;
         }
index 80470f1..211107b 100644 (file)
@@ -122,7 +122,7 @@ class Horde_Kolab_Server_test extends Horde_Kolab_Server_ldap
 
             $this->_bound = true;
 
-            $data = $this->_read($dn, $attrs = array('userPassword'));
+            $data = $this->read($dn, $attrs = array('userPassword'));
             if (is_a($data, 'PEAR_Error')) {
                 $this->_bound = false;
                 return $data;
@@ -375,7 +375,7 @@ class Horde_Kolab_Server_test extends Horde_Kolab_Server_ldap
      *
      * @return array|PEAR_Error An array of attributes.
      */
-    function _read($dn, $attrs = null)
+    function read($dn, $attrs = null)
     {
         if (!$this->_bound) {
             $result = $this->_bind();
index 04086eb..e4f3218 100644 (file)
@@ -88,6 +88,19 @@ class Horde_Kolab_Server_ServerTest extends PHPUnit_Framework_TestCase
 class Horde_Kolab_Server_none extends Horde_Kolab_Server
 {
     /**
+     * Stub for reading object data.
+     *
+     * @param string $uid   The object to retrieve.
+     * @param string $attrs Restrict to these attributes.
+     *
+     * @return array|PEAR_Error An array of attributes.
+     */
+    public function read($uid, $attrs = null)
+    {
+            return PEAR::raiseError('Not implemented!');
+    }
+
+    /**
      * Generates a UID for the given information.
      *
      * @param string $type The type of the object to create.
@@ -96,7 +109,9 @@ class Horde_Kolab_Server_none extends Horde_Kolab_Server
      *
      * @return string|PEAR_Error The UID.
      */
-    protected function _generateUid($type, $id, $info) {
+    protected function _generateUid($type, $id, $info)
+    {
         return $id;
     }
+
 }
index cd61abc..dceeb13 100644 (file)
@@ -45,9 +45,9 @@ class Horde_Kolab_Server_ldapTest extends PHPUnit_Framework_TestCase
      */
     public function testGetObjectClasses()
     {
-        $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_read'));
+        $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('read'));
         $ldap->expects($this->any())
-            ->method('_read')
+            ->method('read')
             ->will($this->returnValue(array (
                                           'objectClass' =>
                                           array (
@@ -61,13 +61,16 @@ class Horde_Kolab_Server_ldapTest extends PHPUnit_Framework_TestCase
                                           'count' => 1)));
 
         $classes = $ldap->_getObjectClasses('cn=Gunnar Wrobel,dc=example,dc=org');
+        if (is_a($classes, 'PEAR_Error')) {
+            $this->assertEquals('', $classes->getMessage());
+        }
         $this->assertContains('top', $classes);
         $this->assertContains('kolabinetorgperson', $classes);
         $this->assertContains('hordeperson', $classes);
 
-        $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_read'));
+        $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('read'));
         $ldap->expects($this->any())
-             ->method('_read')
+             ->method('read')
              ->will($this->returnValue(PEAR::raiseError('LDAP Error: No such object: cn=DOES NOT EXIST,dc=example,dc=org: No such object')));
 
         $classes = $ldap->_getObjectClasses('cn=DOES NOT EXIST,dc=example,dc=org');