From 4368a079f5f88e92e18c5366e80126fe35dc8608 Mon Sep 17 00:00:00 2001 From: alecpl Date: Sat, 29 Aug 2009 20:56:00 +0000 Subject: - Fix gn and givenName should be synonymous in LDAP addressbook (#1485892) --- program/include/rcube_ldap.php | 28 ++++++++++++++++++++++++---- program/steps/addressbook/func.inc | 1 - program/steps/addressbook/search.inc | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) (limited to 'program') diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php index e73508670..71476ced7 100644 --- a/program/include/rcube_ldap.php +++ b/program/include/rcube_ldap.php @@ -55,7 +55,10 @@ class rcube_ldap extends rcube_addressbook foreach ($p as $prop => $value) if (preg_match('/^(.+)_field$/', $prop, $matches)) - $this->fieldmap[$matches[1]] = strtolower($value); + $this->fieldmap[$matches[1]] = $this->_attr_name(strtolower($value)); + + foreach ($this->prop['required_fields'] as $key => $val) + $this->prop['required_fields'][$key] = $this->_attr_name(strtolower($val)); $this->sort_col = $p['sort']; @@ -552,7 +555,7 @@ class rcube_ldap extends rcube_addressbook * * @access private */ - function _exec_search() + private function _exec_search() { if ($this->ready) { @@ -569,7 +572,7 @@ class rcube_ldap extends rcube_addressbook /** * @access private */ - function _ldap2result($rec) + private function _ldap2result($rec) { global $RCMAIL; @@ -595,12 +598,29 @@ class rcube_ldap extends rcube_addressbook /** * @access private */ - function _map_field($field) + private function _map_field($field) { return $this->fieldmap[$field]; } + /** + * @access private + */ + private function _attr_name($name) + { + // list of known attribute aliases + $aliases = array( + 'gn' => 'givenname', + 'rfc822mailbox' => 'mail', + 'userid' => 'uid', + 'emailaddress' => 'email', + 'pkcs9email' => 'email', + ); + return isset($aliases[$name]) ? $aliases[$name] : $name; + } + + /** * @static */ diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index 1ea5ad1b6..ebf5546db 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -56,7 +56,6 @@ else if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']])) $CONTACTS->set_search_set($_SESSION['search'][$_REQUEST['_search']]); - // set data source env $OUTPUT->set_env('source', $source ? $source : '0'); $OUTPUT->set_env('readonly', $CONTACTS->readonly, false); diff --git a/program/steps/addressbook/search.inc b/program/steps/addressbook/search.inc index 01233a0bd..790db060d 100644 --- a/program/steps/addressbook/search.inc +++ b/program/steps/addressbook/search.inc @@ -32,7 +32,7 @@ if ($result->count > 0) { // save search settings in session $_SESSION['search'][$search_request] = $CONTACTS->get_search_set(); - + // create javascript list rcmail_js_contacts_list($result); } -- cgit v1.2.3