From 6b603da6f16591b63f809ef967554d260bd0d891 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Wed, 15 Aug 2007 16:28:01 -0400
Subject: [PATCH] LDAP improvements
---
CHANGELOG | 7 +++++++
program/include/main.inc | 5 ++++-
program/include/rcube_contacts.inc | 7 +++++++
config/main.inc.php.dist | 4 +++-
program/js/app.js | 1 +
program/include/rcube_ldap.inc | 13 +++++++++++--
program/steps/addressbook/copy.inc | 5 ++++-
7 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 48d73ae..2d564a5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,13 @@
CHANGELOG RoundCube Webmail
---------------------------
+2007/08/15 (thomasb)
+----------
+- Applied patch for LDAP contacts listing by Glen Ogilvie
+- Applied patch for more address fields in LDAP contacts (#1484402)
+- Close LDAP connections on script shutdown
+
+
2007/08/13 (thomasb)
----------
- Add alternative for getallheaders() (fix #1484508)
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index d11888d..a5b94d9 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -202,8 +202,10 @@
* 'search_fields' => array('mail', 'cn'), // fields to search in
* 'name_field' => 'cn', // this field represents the contact's name
* 'email_field' => 'mail', // this field represents the contact's e-mail
+ * 'surname_field' => 'sn', // this field represents the contact's last name
+ * 'firstname_field' => 'gn', // this field represents the contact's first name
* 'scope' => 'sub', // search mode: sub|base|list
- * 'filter' => '', // will be &'d with search field ex: (status=act)
+ * 'filter' => '', // used for basic listing (if not empty) and will be &'d with search queries. ex: (status=act)
* 'fuzzy_search' => true); // server allows wildcard search
*/
diff --git a/program/include/main.inc b/program/include/main.inc
index f938174..bd4ebd0 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -299,7 +299,7 @@
*/
function rcmail_shutdown()
{
- global $IMAP;
+ global $IMAP, $CONTACTS;
if (is_object($IMAP))
{
@@ -307,6 +307,9 @@
$IMAP->write_cache();
}
+ if (is_object($CONTACTS))
+ $CONTACTS->close();
+
// before closing the database connection, write session data
session_write_close();
}
diff --git a/program/include/rcube_contacts.inc b/program/include/rcube_contacts.inc
index 9ba965e..f01d222 100644
--- a/program/include/rcube_contacts.inc
+++ b/program/include/rcube_contacts.inc
@@ -128,6 +128,13 @@
/**
+ * Close connection to source
+ * Called on script shutdown
+ */
+ function close(){}
+
+
+ /**
* List the current set of contact records
*
* @param array List of cols to show
diff --git a/program/include/rcube_ldap.inc b/program/include/rcube_ldap.inc
index 976b73d..e6a15d9 100644
--- a/program/include/rcube_ldap.inc
+++ b/program/include/rcube_ldap.inc
@@ -58,7 +58,6 @@
if (preg_match('/^(.+)_field$/', $prop, $matches))
$this->fieldmap[$matches[1]] = $value;
- // $this->filter = "(dn=*)";
$this->connect();
}
@@ -142,7 +141,10 @@
function close()
{
if ($this->conn)
+ {
@ldap_unbind($this->conn);
+ $this->conn = null;
+ }
}
@@ -212,6 +214,13 @@
*/
function list_records($cols=null, $subset=0)
{
+ // add general filter to query
+ if (!empty($this->prop['filter']))
+ {
+ $filter = $this->prop['filter'];
+ $this->set_search_set($filter);
+ }
+
// exec LDAP search if no result resource is stored
if ($this->conn && !$this->ldap_result)
$this->_exec_search();
@@ -442,4 +451,4 @@
}
-?>
\ No newline at end of file
+?>
diff --git a/program/js/app.js b/program/js/app.js
index 48597c5..1d09fe9 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -2253,6 +2253,7 @@
{
page = 1;
this.env.current_page = page;
+ this.reset_qsearch();
}
this.select_folder(src, this.env.source);
diff --git a/program/steps/addressbook/copy.inc b/program/steps/addressbook/copy.inc
index e6d917e..af8b87c 100644
--- a/program/steps/addressbook/copy.inc
+++ b/program/steps/addressbook/copy.inc
@@ -36,8 +36,11 @@
$OUTPUT->show_message('copyerror', 'error');
else
$OUTPUT->show_message('copysuccess', 'notice', array('nr' => count($success)));
+
+ // close connection to second address directory
+ $TARGET->close();
}
-
+
// send response
$OUTPUT->send();
--
Gitblit v1.9.1