From ea0becbbe77a1b93c1ebb2a87f6d161df47009f4 Mon Sep 17 00:00:00 2001 From: Andy Wettstein Date: Wed, 3 Dec 2008 12:48:18 +0100 Subject: [PATCH] Configurable search fields Makes it possible to configure what LDAP fields are considered when doing search. darcs-hash:20081203114818-18fff-3297461c8eac6bf3852dad6efadfcbe549f7c2d8.gz --- inc/config.php | 3 +++ index.php | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/inc/config.php b/inc/config.php index 782f9a4..c03cbc7 100644 --- a/inc/config.php +++ b/inc/config.php @@ -34,6 +34,9 @@ // Where to store private contacts (relative to $conf['usertree']) $conf['privatebook'] = 'ou=contacts'; + // What fields to look at when searching? + $conf['searchfields'] = array('uid','mail','name','givenname','o'); + // Should the public address book be viewable by logged in users only? (0|1) $conf['userlogreq'] = 0; diff --git a/index.php b/index.php index 7fcf106..17240ac 100644 --- a/index.php +++ b/index.php @@ -94,6 +94,7 @@ */ function _makeldapfilter(){ global $FIELDS; + global $conf; //handle given filter @@ -143,9 +144,14 @@ $words=preg_split('/\s+/',$search); $filter=''; foreach($words as $word){ - $filter .= '(|(|('.$FIELDS['name'].'=*'.$word.'*)('. - $FIELDS['givenname'].'=*'.$word.'*))('. - $FIELDS['organization'].'=*'.$word.'*))'; + $wordfilter=''; + foreach($conf['searchfields'] as $field) { + $wordfilter .= '('.$field.'=*'.$word.'*)'; + } + for($i=0; $i