From: Gunnar Wrobel
Date: Tue, 14 Apr 2009 08:06:22 +0000 (+0200) Subject: Added methods to identify the parent object and to search sub objects. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a4bfdc12b9f7963be7b65659e071d7aa08547305;p=horde.git Added methods to identify the parent object and to search sub objects. --- diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php index f38c3c44c..2648109b4 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php @@ -462,6 +462,30 @@ class Horde_Kolab_Server_Object } /** + * Get the parent UID of this object + * + * @return string the parent UID of this object + */ + public function getParentUid() + { + $base = Net_LDAP2_Util::ldap_explode_dn($this->uid, + array('casefold' => 'none', + 'reverse' => false, + 'onlyvalues' => false)); + if ($base instanceOf PEAR_Error) { + throw new Horde_Kolab_Server_Exception($base, + Horde_Kolab_Server_Exception::SYSTEM); + } + $id = array_shift($base); + $parent = Net_LDAP2_Util::canonical_dn($base, array('casefold' => 'none')); + if ($parent instanceOf PEAR_Error) { + throw new Horde_Kolab_Server_Exception($parent, + Horde_Kolab_Server_Exception::SYSTEM); + } + return $parent; + } + + /** * Get the ID of this object * * @return string the ID of this object @@ -786,6 +810,7 @@ class Horde_Kolab_Server_Object $searches = array( 'basicUidForSearch', 'attrsForSearch', + 'objectsForUid', ); return $searches; } @@ -841,4 +866,34 @@ class Horde_Kolab_Server_Object } return self::attrsFromResult($data, $attrs, $restrict); } + + /** + * Returns the UIDs of the sub objects of the given object class for the + * object with the given uid. + * + * @param Horde_Kolab_Server $server The server to query. + * @param string $uid Returns subobjects for this uid. + * @param string $oc Objectclass of the objects to search. + * + * @return mixed The UIDs or false if there was no result. + * + * @throws Horde_Kolab_Server_Exception + */ + static public function objectsForUid($server, $uid, $oc) + { + $params = array('attributes' => self::ATTRIBUTE_UID); + $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_OC, + 'op' => '=', + 'test' => $oc), + ), + ); + $filter = $server->searchQuery($criteria); + $result = $server->search($filter, $params, $uid); + $data = $result->as_struct(); + if (is_a($data, 'PEAR_Error')) { + throw new Horde_Kolab_Server_Exception($data->getMessage()); + } + return self::uidFromResult($data, Horde_Kolab_Server_Object::RESULT_MANY); + } + };