replaced some for loops by foreach loops

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

View File

@ -1138,37 +1138,37 @@ class accountContainer {
$attr_names = array_keys($attributes); $attr_names = array_keys($attributes);
$orig_names = array_keys($orig); $orig_names = array_keys($orig);
// find deleted attributes (in $orig but no longer in $attributes) // find deleted attributes (in $orig but no longer in $attributes)
for ($i = 0; $i < sizeof($orig_names); $i++) { foreach ($orig_names as $i => $value) {
if (!isset($attributes[$orig_names[$i]])) { if (!isset($attributes[$value])) {
$torem[$orig_names[$i]] = $orig[$orig_names[$i]]; $torem[$value] = $orig[$value];
} }
} }
// find changed attributes // find changed attributes
for ($i=0; $i<count($attr_names); $i++) { foreach ($attr_names as $i => $name) {
// find deleted attributes // find deleted attributes
for ($j=0; $j<count($orig[$attr_names[$i]]); $j++) { for ($j = 0; $j < count($orig[$name]); $j++) {
if (is_array($attributes[$attr_names[$i]])) { if (is_array($attributes[$name])) {
if (!in_array($orig[$attr_names[$i]][$j], $attributes[$attr_names[$i]])) { if (!in_array($orig[$name][$j], $attributes[$name])) {
if (($orig[$attr_names[$i]][$j]!='') && ($attr_names[$i]!='objectClass')) $torem[$attr_names[$i]][] = $orig[$attr_names[$i]][$j]; if (($orig[$name][$j] != '') && ($name != 'objectClass')) $torem[$name][] = $orig[$name][$j];
} }
} }
else if (($orig[$attr_names[$i]][$j]!='') && ($attr_names[$i]!='objectClass')) $torem[$attr_names[$i]][] = $orig[$attr_names[$i]][$j]; else if (($orig[$name][$j] != '') && ($name != 'objectClass')) $torem[$name][] = $orig[$name][$j];
} }
// find new attributes // find new attributes
for ($j=0; $j<count($attributes[$attr_names[$i]]); $j++) { for ($j = 0; $j < count($attributes[$name]); $j++) {
if (is_array($orig[$attr_names[$i]])) { if (is_array($orig[$name])) {
if (!in_array($attributes[$attr_names[$i]][$j], $orig[$attr_names[$i]])) if (!in_array($attributes[$name][$j], $orig[$name]))
if ($attributes[$attr_names[$i]][$j]!='') { if ($attributes[$name][$j]!='') {
$toadd[$attr_names[$i]][] = $attributes[$attr_names[$i]][$j]; $toadd[$name][] = $attributes[$name][$j];
} }
} }
else if ($attributes[$attr_names[$i]][$j]!='') $toadd[$attr_names[$i]][] = $attributes[$attr_names[$i]][$j]; else if ($attributes[$name][$j]!='') $toadd[$name][] = $attributes[$name][$j];
} }
// find unchanged attributes // find unchanged attributes
if (is_array($orig[$attr_names[$i]]) && is_array($attributes[$attr_names[$i]])) { if (is_array($orig[$name]) && is_array($attributes[$name])) {
for ($j=0; $j<count($attributes[$attr_names[$i]]); $j++) { for ($j=0; $j<count($attributes[$name]); $j++) {
if (($attributes[$attr_names[$i]][$j] != '') && in_array($attributes[$attr_names[$i]][$j], $orig[$attr_names[$i]])) { if (($attributes[$name][$j] != '') && in_array($attributes[$name][$j], $orig[$name])) {
$notchanged[$attr_names[$i]][] = $attributes[$attr_names[$i]][$j]; $notchanged[$name][] = $attributes[$name][$j];
} }
} }
} }