fixed issue when saving '0' values

This commit is contained in:
Roland Gruber 2017-09-24 09:48:42 +02:00
parent a5522c29ab
commit 38cf0b2108
1 changed files with 35 additions and 22 deletions

View File

@ -1494,10 +1494,14 @@ class accountContainer {
foreach ($orig[$name] as $j => $value) {
if (is_array($attributes[$name])) {
if (!in_array($value, $attributes[$name], true)) {
if ($value != '') $torem[$name][] = $value;
if (($value !== null) && ($value !== '')) {
$torem[$name][] = $value;
}
}
else if ($value != '') $torem[$name][] = $value;
}
elseif (($value !== null) && ($value !== '')) {
$torem[$name][] = $value;
}
}
}
// find new attributes
@ -1505,17 +1509,19 @@ class accountContainer {
foreach ($attributes[$name] as $j => $value) {
if (isset($orig[$name]) && is_array($orig[$name])) {
if (!in_array($value, $orig[$name], true))
if ($value != '') {
if (($value !== null) && ($value !== '')) {
$toadd[$name][] = $value;
}
}
else if ($value != '') $toadd[$name][] = $value;
elseif (($value !== null) && ($value !== '')) {
$toadd[$name][] = $value;
}
}
}
// find unchanged attributes
if (isset($orig[$name]) && is_array($orig[$name]) && is_array($attributes[$name])) {
foreach ($attributes[$name] as $j => $value) {
if (($value != '') && in_array($value, $orig[$name], true)) {
if (($value !== null) && ($value !== '') && in_array($value, $orig[$name], true)) {
$notchanged[$name][] = $value;
}
}
@ -1524,8 +1530,7 @@ class accountContainer {
// create modify with add and remove
$attributes2 = array_keys($toadd);
for ($i=0; $i<count($attributes2); $i++) {
if (isset($torem[$attributes2[$i]]))
if ((count($toadd[$attributes2[$i]]) > 0) && (count($torem[$attributes2[$i]]) > 0)) {
if (isset($torem[$attributes2[$i]]) && (count($toadd[$attributes2[$i]]) > 0) && (count($torem[$attributes2[$i]]) > 0)) {
// found attribute which should be modified
$tomodify[$attributes2[$i]] = $toadd[$attributes2[$i]];
// merge unchanged values
@ -1538,10 +1543,18 @@ class accountContainer {
unset($torem[$attributes2[$i]]);
}
}
if (count($toadd)!=0) $return[$this->dn_orig]['add'] = $toadd;
if (count($torem)!=0) $return[$this->dn_orig]['remove'] = $torem;
if (count($tomodify)!=0) $return[$this->dn_orig]['modify'] = $tomodify;
if (count($notchanged)!=0) $return[$this->dn_orig]['notchanged'] = $notchanged;
if (count($toadd) > 0) {
$return[$this->dn_orig]['add'] = $toadd;
}
if (count($torem) > 0) {
$return[$this->dn_orig]['remove'] = $torem;
}
if (count($tomodify) > 0) {
$return[$this->dn_orig]['modify'] = $tomodify;
}
if (count($notchanged) > 0) {
$return[$this->dn_orig]['notchanged'] = $notchanged;
}
return $return;
}