mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-26 21:01:30 +02:00
LDAP filtering adjustments
This commit is contained in:
parent
035e4efa0e
commit
ab11b27114
@ -70,47 +70,54 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function asc_sort($a,$b) {
|
function asc_sort($a,$b)
|
||||||
|
{
|
||||||
echo "<br>A:'".$a."' B:'".$b;
|
echo "<br>A:'".$a."' B:'".$b;
|
||||||
if($a[1]==$b[1]) return 0;
|
if($a[1]==$b[1]) return 0;
|
||||||
return ($a[1]>$b[1])?1:-1;
|
return ($a[1]>$b[1])?1:-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function desc_sort($a,$b) {
|
function desc_sort($a,$b)
|
||||||
|
{
|
||||||
echo "<br>A:'".$a."' B:'".$b;
|
echo "<br>A:'".$a."' B:'".$b;
|
||||||
if($a[1]==$b[1]) return 0;
|
if($a[1]==$b[1]) return 0;
|
||||||
return ($a[1]<$b[1])?1:-1;
|
return ($a[1]<$b[1])?1:-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** comesafter ($s1, $s2)
|
** comesafter ($s1, $s2)
|
||||||
**
|
**
|
||||||
** Returns 1 if $s1 comes after $s2 alphabetically, 0 if not.
|
** Returns 1 if $s1 comes after $s2 alphabetically, 0 if not.
|
||||||
**/
|
**/
|
||||||
function comesafter ($s1, $s2) {
|
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.
|
** 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;
|
$order = 1;
|
||||||
|
|
||||||
if ( (strlen($s1) == 0) ) {
|
if ( (strlen($s1) == 0) )
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (strlen($s2) == 0) ) {
|
if ( (strlen($s2) == 0) )
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen ($s1) > strlen ($s2)) {
|
if (strlen ($s1) > strlen ($s2))
|
||||||
|
{
|
||||||
$temp = $s1;
|
$temp = $s1;
|
||||||
$s1 = $s2;
|
$s1 = $s2;
|
||||||
$s2 = $temp;
|
$s2 = $temp;
|
||||||
$order = 0;
|
$order = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($index = 0; $index < strlen ($s1); $index++) {
|
for ($index = 0; $index < strlen ($s1); $index++)
|
||||||
/* $s1 comes after $s2 */
|
{
|
||||||
|
/* $s1 comes after $s2 */
|
||||||
if (strtolower($s1[$index]) > strtolower($s2[$index])) { return ($order); }
|
if (strtolower($s1[$index]) > strtolower($s2[$index])) { return ($order); }
|
||||||
|
|
||||||
/* $s1 comes before $s2 */
|
/* $s1 comes before $s2 */
|
||||||
@ -118,7 +125,7 @@
|
|||||||
}
|
}
|
||||||
/* Special case in which $s1 is a substring of $s2 */
|
/* Special case in which $s1 is a substring of $s2 */
|
||||||
|
|
||||||
return ($order);
|
return ($order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -176,36 +183,48 @@
|
|||||||
for($i=0;$i<count($ldap_fields);$i++) {
|
for($i=0;$i<count($ldap_fields);$i++) {
|
||||||
$yes = True;
|
$yes = True;
|
||||||
|
|
||||||
reset($filterfields);
|
if ($ldap_fields[$i]["uidnumber"][0])
|
||||||
while (list($col,$filt) = each($filterfields))
|
|
||||||
{
|
{
|
||||||
if($DEBUG) { echo ' Testing "'.$col.'" for "'.$filt.'"'; }
|
reset($filterfields);
|
||||||
if ($ldap_fields[$i][$col][0] == $filt)
|
while (list($col,$filt) = each($filterfields))
|
||||||
{
|
{
|
||||||
if($DEBUG) { echo ', and number '.$ldap_fields[$i]["uidnumber"][0].' matched.'." "; }
|
if($DEBUG) { echo ' Testing "'.$col.'" for "'.$filt.'"'; }
|
||||||
$yes &= True;
|
if ($ldap_fields[$i][$col][0] == $filt)
|
||||||
$match++;
|
{
|
||||||
|
if($DEBUG) { echo ', and number '.$ldap_fields[$i]["uidnumber"][0].' matched.'." "; }
|
||||||
|
$yes &= True;
|
||||||
|
$match++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if($DEBUG) { echo ', but number '.$ldap_fields[$i]["uidnumber"][0].' did not match.'." "; }
|
||||||
|
$yes &= False;
|
||||||
|
$match--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($yes)
|
||||||
|
{
|
||||||
|
if($DEBUG) { echo $ldap_fields[$i]["uidnumber"][0].' matched all!'."<br>"; }
|
||||||
|
$new_ldap[] = $ldap_fields[$i];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if($DEBUG) { echo ', but number '.$ldap_fields[$i]["uidnumber"][0].' did not match.'." "; }
|
if($DEBUG) { echo $ldap_fields[$i]["uidnumber"][0].' did not match all.'."<br>"; }
|
||||||
$yes &= False;
|
|
||||||
$match--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($yes)
|
if($DEBUG)
|
||||||
|
{
|
||||||
|
if($match)
|
||||||
{
|
{
|
||||||
if($DEBUG) { echo $ldap_fields[$i]["uidnumber"][0].' matched all!'."<br>"; }
|
echo '<br>'.$match.' total matches.'."\n";
|
||||||
$new_ldap[] = $ldap_fields[$i];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if($DEBUG) { echo $ldap_fields[$i]["uidnumber"][0].' did not match all.'."<br>"; }
|
echo '<br>No matches :('."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($match) { if($DEBUG) { echo '<br'.$match.' total matches.'."\n"; } }
|
|
||||||
else { if($DEBUG) { echo '<br>No matches :('."\n"; } }
|
|
||||||
$this->total_records = count($new_ldap);
|
$this->total_records = count($new_ldap);
|
||||||
|
|
||||||
return $new_ldap;
|
return $new_ldap;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user