From 746a61f5cd660b17b32925a60667fcc50d045f31 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel
Date: Wed, 11 Feb 2009 23:20:30 +0000 Subject: [PATCH] Additional abstract methods. --- framework/Kolab_Server/lib/Horde/Kolab/Server.php | 85 +++++++++------------- .../Kolab_Server/lib/Horde/Kolab/Server/ldap.php | 6 +- .../test/Horde/Kolab/Server/ServerTest.php | 27 ++++++- .../test/Horde/Kolab/Server/testTest.php | 14 ++-- 4 files changed, 69 insertions(+), 63 deletions(-) diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server.php b/framework/Kolab_Server/lib/Horde/Kolab/Server.php index bee428c5b..7894d9449 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server.php @@ -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); } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php index 96bf0267c..06b82756c 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/ldap.php @@ -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: diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php index e4f3218c9..7a05d66de 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php @@ -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; } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/testTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/testTest.php index 9db3f11c0..ca851a829 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/testTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/testTest.php @@ -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); } -- 2.11.0