From: Gunnar Wrobel
Date: Sat, 25 Apr 2009 06:02:08 +0000 (+0200)
Subject: Added getGroupAddresses() to return the mail addresses of groups
X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7aedf9ac133b63020a805955963a8d5542945664;p=horde.git
Added getGroupAddresses() to return the mail addresses of groups
the user belongs to.
---
diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabgroupofnames.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabgroupofnames.php
index aabcd7944..228c7bab0 100644
--- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabgroupofnames.php
+++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabgroupofnames.php
@@ -147,6 +147,7 @@ class Horde_Kolab_Server_Object_Kolabgroupofnames extends Horde_Kolab_Server_Obj
$searches = array(
'gidForMail',
'memberOfGroupAddress',
+ 'getGroupAddresses',
);
return $searches;
}
@@ -200,4 +201,46 @@ class Horde_Kolab_Server_Object_Kolabgroupofnames extends Horde_Kolab_Server_Obj
return !empty($result);
}
+
+ /**
+ * Get the mail addresses for the group of this object.
+ *
+ * @param string $uid The UID of the object to fetch.
+ *
+ * @return array An array of mail addresses.
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ static public function getGroupAddresses($server, $uid)
+ {
+ $criteria = array('AND' =>
+ array(
+ array('field' => self::ATTRIBUTE_OC,
+ 'op' => '=',
+ 'test' => self::OBJECTCLASS_GROUPOFNAMES),
+ array('field' => self::ATTRIBUTE_MEMBER,
+ 'op' => '=',
+ 'test' => $uid),
+ ),
+ );
+
+ $data = self::attrsForSearch($server, $criteria, array(self::ATTRIBUTE_MAIL),
+ self::RESULT_MANY);
+
+ if (empty($data)) {
+ return array();
+ }
+
+ $mails = array();
+ foreach ($data as $element) {
+ if (isset($element[self::ATTRIBUTE_MAIL])) {
+ if (is_array($element[self::ATTRIBUTE_MAIL])) {
+ $mails = array_merge($mails, $element[self::ATTRIBUTE_MAIL]);
+ } else {
+ $mails[] = $element[self::ATTRIBUTE_MAIL];
+ }
+ }
+ }
+ return $mails;
+ }
}
diff --git a/framework/Kolab_Server/package.xml b/framework/Kolab_Server/package.xml
index 40b02c532..111e4d528 100644
--- a/framework/Kolab_Server/package.xml
+++ b/framework/Kolab_Server/package.xml
@@ -51,6 +51,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
* Added LDAP write support.
* Real LDAP server unit testing.
* Support configurable attribute mapping.
+ * Added getGroupAddresses() to return the mail addresses of groups
+ the user belongs to.