diff options
author | thomascube <thomas@roundcube.net> | 2011-08-24 19:38:50 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2011-08-24 19:38:50 +0000 |
commit | c63e571f021cf946270cfdaf84c87f83ecbaa316 (patch) | |
tree | 87615c12e7e50c1b0593745304bf66506010a59b | |
parent | 6354da5b8c75f1c95b3f136cd9483a177c2ee182 (diff) |
Fix group members listing for ldap directories
-rw-r--r-- | program/include/rcube_ldap.php | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php index c363dc572..bf978a7ff 100644 --- a/program/include/rcube_ldap.php +++ b/program/include/rcube_ldap.php @@ -431,34 +431,41 @@ class rcube_ldap extends rcube_addressbook // we have a search result resource if ($this->ldap_result && $this->result->count > 0) { + // sorting still on the ldap server if ($this->sort_col && $this->prop['scope'] !== 'base' && !$this->vlv_active) ldap_sort($this->conn, $this->ldap_result, $this->sort_col); + // start and end of the page $start_row = $this->vlv_active ? 0 : $this->result->first; $start_row = $subset < 0 ? $start_row + $this->page_size + $subset : $start_row; $last_row = $this->result->first + $this->page_size; $last_row = $subset != 0 ? $start_row + abs($subset) : $last_row; + // get all entries from the ldap server $entries = ldap_get_entries($this->conn, $this->ldap_result); - for ($i = $start_row; $i < min($entries['count'], $last_row); $i++) - $this->result->add($this->_ldap2result($entries[$i])); - } - // temp hack for filtering group members - if ($this->groups and $this->group_id) - { - $result = new rcube_result_set(); - while ($record = $this->result->iterate()) + // filtering for group members + if ($this->groups and $this->group_id) { - if ($this->group_members[$record['ID']]) + $count = 0; + $members = array(); + foreach ($entries as $entry) { - $result->add($record); - $result->count++; + if ($this->group_members[base64_encode($entry['dn'])]) + { + $members[] = $entry; + $count++; + } } + $entries = $members; + $entries['count'] = $count; + $this->result->count = $count; } - $this->result = $result; - } + // filter entries for this page + for ($i = $start_row; $i < min($entries['count'], $last_row); $i++) + $this->result->add($this->_ldap2result($entries[$i])); + } return $this->result; } |