forked from extern/egroupware
More ldap filtering fixes
This commit is contained in:
parent
dac252934e
commit
9917a39116
@ -491,7 +491,7 @@
|
|||||||
$ldap_fields['phpgwtypeid'] = $tid;
|
$ldap_fields['phpgwtypeid'] = $tid;
|
||||||
$ldap_fields['phpgwowner'] = $owner;
|
$ldap_fields['phpgwowner'] = $owner;
|
||||||
$ldap_fields['phpgwaccess'] = $access;
|
$ldap_fields['phpgwaccess'] = $access;
|
||||||
$ldap_fields["cat_id"] = $cat_id;
|
$ldap_fields["phpgwcatid"] = $cat_id;
|
||||||
$ldap_fields['uidnumber'] = $this->nextid;
|
$ldap_fields['uidnumber'] = $this->nextid;
|
||||||
$ldap_fields['objectclass'][0] = 'person';
|
$ldap_fields['objectclass'][0] = 'person';
|
||||||
$ldap_fields['objectclass'][1] = 'organizationalPerson';
|
$ldap_fields['objectclass'][1] = 'organizationalPerson';
|
||||||
|
@ -135,13 +135,17 @@
|
|||||||
* case of a user array this is the username; with the group array it is the group name.
|
* case of a user array this is the username; with the group array it is the group name.
|
||||||
* asortby
|
* asortby
|
||||||
*/
|
*/
|
||||||
function asortbyindex ($sortarray, $index) {
|
function asortbyindex ($sortarray, $index)
|
||||||
|
{
|
||||||
$lastindex = count($sortarray) - 2;
|
$lastindex = count($sortarray) - 2;
|
||||||
for ($subindex = 0; $subindex < $lastindex; $subindex++) {
|
for ($subindex = 0; $subindex < $lastindex; $subindex++)
|
||||||
|
{
|
||||||
$lastiteration = $lastindex - $subindex;
|
$lastiteration = $lastindex - $subindex;
|
||||||
for ($iteration = 0; $iteration < $lastiteration; $iteration++) {
|
for ($iteration = 0; $iteration < $lastiteration; $iteration++)
|
||||||
|
{
|
||||||
$nextchar = 0;
|
$nextchar = 0;
|
||||||
if ($this->comesafter($sortarray[$iteration][$index], $sortarray[$iteration + 1][$index])) {
|
if ($this->comesafter($sortarray[$iteration][$index], $sortarray[$iteration + 1][$index]))
|
||||||
|
{
|
||||||
$temp = $sortarray[$iteration];
|
$temp = $sortarray[$iteration];
|
||||||
$sortarray[$iteration] = $sortarray[$iteration + 1];
|
$sortarray[$iteration] = $sortarray[$iteration + 1];
|
||||||
$sortarray[$iteration + 1] = $temp;
|
$sortarray[$iteration + 1] = $temp;
|
||||||
@ -151,13 +155,17 @@
|
|||||||
return ($sortarray);
|
return ($sortarray);
|
||||||
}
|
}
|
||||||
|
|
||||||
function arsortbyindex ($sortarray, $index) {
|
function arsortbyindex ($sortarray, $index)
|
||||||
|
{
|
||||||
$lastindex = count($sortarray) - 1;
|
$lastindex = count($sortarray) - 1;
|
||||||
for ($subindex = $lastindex; $subindex > 0; $subindex--) {
|
for ($subindex = $lastindex; $subindex > 0; $subindex--)
|
||||||
|
{
|
||||||
$lastiteration = $lastindex - $subindex;
|
$lastiteration = $lastindex - $subindex;
|
||||||
for ($iteration = $lastiteration; $iteration > 0; $iteration--) {
|
for ($iteration = $lastiteration; $iteration > 0; $iteration--)
|
||||||
|
{
|
||||||
$nextchar = 0;
|
$nextchar = 0;
|
||||||
if ($this->comesafter($sortarray[$iteration][$index], $sortarray[$iteration - 1][$index])) {
|
if ($this->comesafter($sortarray[$iteration][$index], $sortarray[$iteration - 1][$index]))
|
||||||
|
{
|
||||||
$temp = $sortarray[$iteration];
|
$temp = $sortarray[$iteration];
|
||||||
$sortarray[$iteration] = $sortarray[$iteration - 1];
|
$sortarray[$iteration] = $sortarray[$iteration - 1];
|
||||||
$sortarray[$iteration - 1] = $temp;
|
$sortarray[$iteration - 1] = $temp;
|
||||||
@ -167,28 +175,53 @@
|
|||||||
return ($sortarray);
|
return ($sortarray);
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter_ldap ($ldap_fields,$filterfields,$DEBUG=0) {
|
function filter_ldap ($ldap_fields,$filterfields,$DEBUG=0)
|
||||||
|
{
|
||||||
$match = 0;
|
$match = 0;
|
||||||
reset($filterfields);
|
if($DEBUG) { echo "<br>"; }
|
||||||
for($i=0;$i<count($ldap_fields);$i++) {
|
for($i=0;$i<count($ldap_fields);$i++) {
|
||||||
while (list($col,$filt) = each($filterfields)) {
|
$matched = "";
|
||||||
if($DEBUG) { echo '<br>Testing "'.$col.'" for "'.$filt.'"'."\n"; }
|
$allmatched = False;
|
||||||
if ($ldap_fields[$i][$col][0] == $filt) {
|
reset($filterfields);
|
||||||
if($DEBUG) { echo ', and number '.$ldap_fields[$i]["uidnumber"][0].' matched!'."\n"; }
|
|
||||||
$matched[$col][$i] = True;
|
while (list($col,$filt) = each($filterfields))
|
||||||
|
{
|
||||||
|
if($DEBUG) { echo ' Testing "'.$col.'" for "'.$filt.'"'; }
|
||||||
|
if ($ldap_fields[$i][$col][0] == $filt)
|
||||||
|
{
|
||||||
|
if($DEBUG) { echo ', and number '.$ldap_fields[$i]["uidnumber"][0].' matched.'." "; }
|
||||||
|
$matched[$col] = True;
|
||||||
$match++;
|
$match++;
|
||||||
} else {
|
}
|
||||||
$matched[$col][$i] = False;
|
else
|
||||||
if($DEBUG) { echo ', and number '.$ldap_fields[$i]["uidnumber"][0].' did not match!'."\n"; }
|
{
|
||||||
|
$matched[$col] = False;
|
||||||
|
if($DEBUG) { echo ', but number '.$ldap_fields[$i]["uidnumber"][0].' did not match.'." "; }
|
||||||
$match--;
|
$match--;
|
||||||
}
|
}
|
||||||
if ($matched[$col][$i]) { $allmatched[$i] = True; }
|
|
||||||
|
while (list($colmatch) = each($matched))
|
||||||
|
{
|
||||||
|
if ($matched[$col])
|
||||||
|
{
|
||||||
|
$allmatched = True;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$allmatched = False;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reset($filterfields);
|
|
||||||
if ($allmatched[$i]) {
|
if ($allmatched)
|
||||||
if($DEBUG) { echo ', and number '.$ldap_fields[$i]["uidnumber"][0].' matched!'."\n"; }
|
{
|
||||||
|
if($DEBUG) { echo $ldap_fields[$i]["uidnumber"][0].' matched all!'."<br>"; }
|
||||||
$new_ldap[$i] = $ldap_fields[$i];
|
$new_ldap[$i] = $ldap_fields[$i];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if($DEBUG) { echo $ldap_fields[$i]["uidnumber"][0].' did not match all.'."<br>"; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($match) { if($DEBUG) { echo '<br'.$match.' total matches.'."\n"; } }
|
if ($match) { if($DEBUG) { echo '<br'.$match.' total matches.'."\n"; } }
|
||||||
else { if($DEBUG) { echo '<br>No matches :('."\n"; } }
|
else { if($DEBUG) { echo '<br>No matches :('."\n"; } }
|
||||||
|
Loading…
Reference in New Issue
Block a user