summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-07-03 14:22:17 +0200
committerAleksander Machniak <alec@alec.pl>2013-07-03 14:22:17 +0200
commit3e7b9be05c68fca5617c3c01b0cf3bf5f3b32113 (patch)
tree00d596201cc387067a540dc65c36e7ab07ed05f3 /program
parent42b9ce64151f86e4f77d4b01b3fa36461ae9abcc (diff)
Store group objectclass to member attribute mapping in one place, cs fixes
Diffstat (limited to 'program')
-rw-r--r--program/lib/Roundcube/rcube_ldap.php49
1 files changed, 27 insertions, 22 deletions
diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php
index 29da13c13..555a56471 100644
--- a/program/lib/Roundcube/rcube_ldap.php
+++ b/program/lib/Roundcube/rcube_ldap.php
@@ -27,7 +27,7 @@
*/
class rcube_ldap extends rcube_addressbook
{
- /** public properties */
+ // public properties
public $primary_key = 'ID';
public $groups = false;
public $readonly = true;
@@ -35,7 +35,7 @@ class rcube_ldap extends rcube_addressbook
public $group_id = 0;
public $coltypes = array();
- /** private properties */
+ // private properties
protected $ldap;
protected $prop = array();
protected $fieldmap = array();
@@ -46,6 +46,21 @@ class rcube_ldap extends rcube_addressbook
protected $mail_domain = '';
protected $debug = false;
+ /**
+ * Group objectclass (lowercase) to member attribute mapping
+ *
+ * @var array
+ */
+ private static $group_types = array(
+ 'group' => 'member',
+ 'groupofnames' => 'member',
+ 'kolabgroupofnames' => 'member',
+ 'groupofuniquenames' => 'uniqueMember',
+ 'kolabgroupofuniquenames' => 'uniqueMember',
+ 'univentiongroup' => 'uniqueMember',
+ 'groupofurls' => null,
+ );
+
private $base_dn = '';
private $groups_base_dn = '';
private $group_url;
@@ -831,7 +846,6 @@ class rcube_ldap extends rcube_addressbook
if (!empty($this->filter)) { // Use global search filter
$prop['filter'] = $this->filter;
}
-
$count = $this->ldap->search($prop['base_dn'], $prop['filter'], $prop['scope'], array('dn'), $prop, true);
}
@@ -1444,11 +1458,11 @@ class rcube_ldap extends rcube_addressbook
{
// list of known attribute aliases
static $aliases = array(
- 'gn' => 'givenname',
+ 'gn' => 'givenname',
'rfc822mailbox' => 'email',
- 'userid' => 'uid',
- 'emailaddress' => 'email',
- 'pkcs9email' => 'email',
+ 'userid' => 'uid',
+ 'emailaddress' => 'email',
+ 'pkcs9email' => 'email',
);
list($name, $limit) = explode(':', $namev, 2);
@@ -1462,11 +1476,9 @@ class rcube_ldap extends rcube_addressbook
*/
private static function is_group_entry($entry)
{
- return array_intersect(
- array('group', 'groupofnames', 'kolabgroupofnames', 'groupofuniquenames',
- 'kolabgroupofuniquenames', 'groupofurls', 'univentiongroup'),
- array_map('strtolower', (array)$entry['objectclass'])
- );
+ $classes = array_map('strtolower', (array)$entry['objectclass']);
+
+ return count(array_intersect(array_keys(self::$group_types), $classes)) > 0;
}
/**
@@ -1863,6 +1875,7 @@ class rcube_ldap extends rcube_addressbook
$name_attr = $this->prop['groups']['name_attr'] ? $this->prop['groups']['name_attr'] : 'cn';
$member_attr = $this->get_group_member_attr();
$add_filter = '';
+
if ($member_attr != 'member' && $member_attr != 'uniqueMember')
$add_filter = "($member_attr=$contact_dn)";
$filter = strtr("(|(member=$contact_dn)(uniqueMember=$contact_dn)$add_filter)", array('\\' => '\\\\'));
@@ -1895,16 +1908,8 @@ class rcube_ldap extends rcube_addressbook
if (!empty($object_classes)) {
foreach ((array)$object_classes as $oc) {
- switch (strtolower($oc)) {
- case 'group':
- case 'groupofnames':
- case 'kolabgroupofnames':
- return 'member';
-
- case 'groupofuniquenames':
- case 'kolabgroupofuniquenames':
- case 'univentiongroup':
- return 'uniqueMember';
+ if ($attr = self::$group_types[strtolower($oc)]) {
+ return $attr;
}
}
}