From: Andy Wettstein Date: Wed, 3 Dec 2008 11:48:18 +0000 (+0100) Subject: Configurable search fields X-Git-Tag: 0.7.1~22 X-Git-Url: https://git.sur5r.net/?p=contagged;a=commitdiff_plain;h=ea0becbbe77a1b93c1ebb2a87f6d161df47009f4 Configurable search fields Makes it possible to configure what LDAP fields are considered when doing search. darcs-hash:20081203114818-18fff-3297461c8eac6bf3852dad6efadfcbe549f7c2d8.gz --- 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