From d6eb7c0fbb189d342c624c5c53cd1e3c68d20b28 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Tue, 10 Apr 2012 03:47:15 -0400
Subject: [PATCH] - Fix removing all folders on import to LDAP addressbook (added rcube_ldap::delete_all()) - Fix removing sub-entries in delete()
---
program/include/rcube_ldap.php | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php
index 61c66f3..9f8086b 100644
--- a/program/include/rcube_ldap.php
+++ b/program/include/rcube_ldap.php
@@ -1284,7 +1284,7 @@
// Need to delete all sub-entries first
if ($this->sub_filter) {
- if ($entries = $this->ldap_list($dn, $this->sub_filter, array_keys($this->props['sub_fields']))) {
+ if ($entries = $this->ldap_list($dn, $this->sub_filter)) {
foreach ($entries as $entry) {
if (!$this->ldap_delete($entry['dn'])) {
$this->set_error(self::ERROR_SAVING, 'errorsaving');
@@ -1311,6 +1311,23 @@
} // end foreach
return count($ids);
+ }
+
+
+ /**
+ * Remove all contact records
+ */
+ function delete_all()
+ {
+ //searching for contact entries
+ $dn_list = $this->ldap_list($this->base_dn, $this->prop['filter'] ? $this->prop['filter'] : '(objectclass=*)');
+
+ if (!empty($dn_list)) {
+ foreach ($dn_list as $idx => $entry) {
+ $dn_list[$idx] = self::dn_encode($entry['dn']);
+ }
+ $this->delete($dn_list);
+ }
}
@@ -2172,7 +2189,7 @@
/**
* Wrapper for ldap_list()
*/
- protected function ldap_list($dn, $filter, $attrs)
+ protected function ldap_list($dn, $filter, $attrs = array(''))
{
$list = array();
$this->_debug("C: List [dn: $dn] [{$filter}]");
--
Gitblit v1.9.1