replaced some for loops by foreach loops

This commit is contained in:
Roland Gruber 2007-10-28 12:48:13 +00:00
parent ca9869174d
commit 11acadddd1
1 changed files with 19 additions and 15 deletions

View File

@ -1146,29 +1146,33 @@ class accountContainer {
// find changed attributes // find changed attributes
foreach ($attr_names as $i => $name) { foreach ($attr_names as $i => $name) {
// find deleted attributes // find deleted attributes
for ($j = 0; $j < count($orig[$name]); $j++) { if (isset($orig[$name]) && is_array($orig[$name])) {
if (is_array($attributes[$name])) { foreach ($orig[$name] as $j => $value) {
if (!in_array($orig[$name][$j], $attributes[$name])) { if (is_array($attributes[$name])) {
if (($orig[$name][$j] != '') && ($name != 'objectClass')) $torem[$name][] = $orig[$name][$j]; if (!in_array($value, $attributes[$name])) {
if (($value != '') && ($name != 'objectClass')) $torem[$name][] = $value;
}
} }
else if (($value != '') && ($name != 'objectClass')) $torem[$name][] = $value;
} }
else if (($orig[$name][$j] != '') && ($name != 'objectClass')) $torem[$name][] = $orig[$name][$j];
} }
// find new attributes // find new attributes
for ($j = 0; $j < count($attributes[$name]); $j++) { if (isset($attributes[$name]) && is_array($attributes[$name])) {
if (is_array($orig[$name])) { foreach ($attributes[$name] as $j => $value) {
if (!in_array($attributes[$name][$j], $orig[$name])) if (is_array($orig[$name])) {
if ($attributes[$name][$j]!='') { if (!in_array($value, $orig[$name]))
$toadd[$name][] = $attributes[$name][$j]; if ($value != '') {
} $toadd[$name][] = $value;
}
}
else if ($value != '') $toadd[$name][] = $value;
} }
else if ($attributes[$name][$j]!='') $toadd[$name][] = $attributes[$name][$j];
} }
// find unchanged attributes // find unchanged attributes
if (is_array($orig[$name]) && is_array($attributes[$name])) { if (is_array($orig[$name]) && is_array($attributes[$name])) {
for ($j=0; $j<count($attributes[$name]); $j++) { foreach ($attributes[$name] as $j => $value) {
if (($attributes[$name][$j] != '') && in_array($attributes[$name][$j], $orig[$name])) { if (($value != '') && in_array($value, $orig[$name])) {
$notchanged[$name][] = $attributes[$name][$j]; $notchanged[$name][] = $value;
} }
} }
} }