From: Gunnar Wrobel
Date: Wed, 11 Feb 2009 23:06:38 +0000 (+0000) Subject: Remove functions that are unnecessary. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=97d473dfdf2f92218d8ff8bdcf92157e538e296d;p=horde.git Remove functions that are unnecessary. --- diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server.php b/framework/Kolab_Server/lib/Horde/Kolab/Server.php index bb5bc0029..bee428c5b 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server.php @@ -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. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php index 931117582..96bf0267c 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php @@ -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; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/test.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/test.php index 80470f161..211107b1f 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/test.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/test.php @@ -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(); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php index 04086eb35..e4f3218c9 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php @@ -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; } + } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/ldapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/ldapTest.php index cd61abc9c..dceeb1378 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/ldapTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/ldapTest.php @@ -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');