From: Andreas Gohr Date: Wed, 27 Jun 2007 12:03:22 +0000 (+0200) Subject: simple phone number searching X-Git-Tag: 0.7.1~45 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e7fbf6ea14de3e1afa92ab5be737f702c4a3349c;p=contagged simple phone number searching If you enter a numeric search query it is treated as part of a phone number. Because ConTagged has to deal with any possible formatting in the phone number entries and the limits of LDAP search filters it will match any number where the given digits occur in the same order (but not nesserally besides each others) Eg. a search for 3940 will match the number +49 30 22 49 46 30 darcs-hash:20070627120322-6e07b-6c934b3f883a8cb9f84f171e2f7670727c51bdf0.gz --- diff --git a/index.php b/index.php index 8fdc91c..26c5912 100644 --- a/index.php +++ b/index.php @@ -100,6 +100,7 @@ if (empty($_REQUEST['search'])) { $_REQUEST['search']=''; } if (empty($_REQUEST['org'])) { $_REQUEST['org']=''; } if (empty($_REQUEST['marker'])) { $_REQUEST['marker']=''; } + if(is_numeric($_REQUEST['search'])) $number = $_REQUEST['search']; $filter = ldap_filterescape($_REQUEST['filter']); $search = ldap_filterescape($_REQUEST['search']); $org = ldap_filterescape($_REQUEST['org']); @@ -116,6 +117,25 @@ $ldapfilter .= '('.$FIELDS['_marker'].'='.$m.')'; } $ldapfilter .= ')'; + }elseif($number){ + // Search by telephone number + $filter = ''; + // add wildcards between digits to compensate for any formatting + $length = strlen($number); + for($i=0; $i <$length; $i++){ + $filter .= '*'.$number{$i}; + } + $filter .= '*'; + $ldapfilter = '(&'. + '(objectClass=inetOrgPerson)'. + '(|'. + '(|'. + '('.$FIELDS['phone'].'='.$filter.')'. + '('.$FIELDS['homephone'].'='.$filter.')'. + ')'. + '('.$FIELDS['homephone'].'='.$filter.')'. + ')'. + ')'; }elseif(!empty($search)){ // Search name and organization $search = trim($search);