From ab11b27114f5c5165dcd32ce78fc560201e4fb53 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Mon, 9 Apr 2001 12:54:43 +0000 Subject: [PATCH] LDAP filtering adjustments --- addressbook/inc/class.contacts_shared.inc.php | 99 +++++++++++-------- 1 file changed, 59 insertions(+), 40 deletions(-) diff --git a/addressbook/inc/class.contacts_shared.inc.php b/addressbook/inc/class.contacts_shared.inc.php index 94f32e3b07..eada4f0aab 100644 --- a/addressbook/inc/class.contacts_shared.inc.php +++ b/addressbook/inc/class.contacts_shared.inc.php @@ -70,47 +70,54 @@ } } - function asc_sort($a,$b) { + function asc_sort($a,$b) + { echo "
A:'".$a."' B:'".$b; - if($a[1]==$b[1]) return 0; - return ($a[1]>$b[1])?1:-1; + if($a[1]==$b[1]) return 0; + return ($a[1]>$b[1])?1:-1; } - function desc_sort($a,$b) { + function desc_sort($a,$b) + { echo "
A:'".$a."' B:'".$b; - if($a[1]==$b[1]) return 0; - return ($a[1]<$b[1])?1:-1; + if($a[1]==$b[1]) return 0; + return ($a[1]<$b[1])?1:-1; } - /** - ** comesafter ($s1, $s2) - ** - ** Returns 1 if $s1 comes after $s2 alphabetically, 0 if not. - **/ - function comesafter ($s1, $s2) { - /** - ** We don't want to overstep the bounds of one of the strings and segfault, - ** so let's see which one is shorter. - **/ + /** + ** comesafter ($s1, $s2) + ** + ** Returns 1 if $s1 comes after $s2 alphabetically, 0 if not. + **/ + function comesafter ($s1, $s2) + { + /** + ** We don't want to overstep the bounds of one of the strings and segfault, + ** so let's see which one is shorter. + **/ $order = 1; - if ( (strlen($s1) == 0) ) { + if ( (strlen($s1) == 0) ) + { return 0; } - - if ( (strlen($s2) == 0) ) { + + if ( (strlen($s2) == 0) ) + { return 1; } - if (strlen ($s1) > strlen ($s2)) { + if (strlen ($s1) > strlen ($s2)) + { $temp = $s1; $s1 = $s2; $s2 = $temp; $order = 0; } - for ($index = 0; $index < strlen ($s1); $index++) { - /* $s1 comes after $s2 */ + for ($index = 0; $index < strlen ($s1); $index++) + { + /* $s1 comes after $s2 */ if (strtolower($s1[$index]) > strtolower($s2[$index])) { return ($order); } /* $s1 comes before $s2 */ @@ -118,7 +125,7 @@ } /* Special case in which $s1 is a substring of $s2 */ - return ($order); + return ($order); } /* @@ -176,36 +183,48 @@ for($i=0;$i"; } + $new_ldap[] = $ldap_fields[$i]; } else { - if($DEBUG) { echo ', but number '.$ldap_fields[$i]["uidnumber"][0].' did not match.'."  "; } - $yes &= False; - $match--; + if($DEBUG) { echo $ldap_fields[$i]["uidnumber"][0].' did not match all.'."
"; } } } - - if ($yes) + } + if($DEBUG) + { + if($match) { - if($DEBUG) { echo $ldap_fields[$i]["uidnumber"][0].' matched all!'."
"; } - $new_ldap[] = $ldap_fields[$i]; + echo '
'.$match.' total matches.'."\n"; } else { - if($DEBUG) { echo $ldap_fields[$i]["uidnumber"][0].' did not match all.'."
"; } + echo '
No matches :('."\n"; } } - if ($match) { if($DEBUG) { echo 'No matches :('."\n"; } } $this->total_records = count($new_ldap); return $new_ldap;