Aleksander Machniak
2013-12-04 18b40c1a3214518764e99f69b581bd7c90426091
program/lib/Roundcube/rcube_ldap.php
@@ -706,7 +706,7 @@
            if ($result = $this->ldap->search($m[1], $filter, $m[2], $attrs, $this->group_data)) {
                $entries = $result->entries();
                for ($j = 0; $j < $entries['count']; $j++) {
                    if (self::is_group_entry($entries[$j]) && ($nested_group_members = $this->list_group_members($entries[$j]['dn'], $count)))
                    if ($this->is_group_entry($entries[$j]) && ($nested_group_members = $this->list_group_members($entries[$j]['dn'], $count)))
                        $group_members = array_merge($group_members, $nested_group_members);
                    else
                        $group_members[] = $entries[$j];
@@ -1324,8 +1324,10 @@
    /**
     * Remove all contact records
     *
     * @param bool $with_groups Delete also groups if enabled
     */
    function delete_all()
    function delete_all($with_groups = false)
    {
        // searching for contact entries
        $dn_list = $this->ldap->list_entries($this->base_dn, $this->prop['filter'] ? $this->prop['filter'] : '(objectclass=*)');
@@ -1335,6 +1337,16 @@
                $dn_list[$idx] = self::dn_encode($entry['dn']);
            }
            $this->delete($dn_list);
        }
        if ($with_groups && $this->groups && ($groups = $this->_fetch_groups()) && count($groups)) {
            foreach ($groups as $group) {
                $this->ldap->delete($group['dn']);
            }
            if ($this->cache) {
                $this->cache->remove('groups');
            }
        }
    }
@@ -1391,7 +1403,7 @@
            $out[$this->primary_key] = self::dn_encode($rec['dn']);
        // determine record type
        if (self::is_group_entry($rec)) {
        if ($this->is_group_entry($rec)) {
            $out['_type'] = 'group';
            $out['readonly'] = true;
            $fieldmap['name'] = $this->group_data['name_attr'] ? $this->group_data['name_attr'] : $this->prop['groups']['name_attr'];
@@ -1516,7 +1528,7 @@
    /**
     * Determines whether the given LDAP entry is a group record
     */
    private static function is_group_entry($entry)
    private function is_group_entry($entry)
    {
        $classes = array_map('strtolower', (array)$entry['objectclass']);