LSldapObject::submitChange(): code cleaning

This commit is contained in:
Benjamin Renard 2020-12-22 19:46:57 +01:00
parent a353ca5c37
commit 7ef6e57c49

View file

@ -675,49 +675,48 @@ class LSldapObject extends LSlog_staticLoggerClass {
} }
} }
if(!empty($submitData)) { if(!empty($submitData)) {
$dn=$this -> getDn(); $dn = $this -> getDn();
if (!$dn) {
if($dn) {
$this -> dn=$dn;
self :: log_debug($this." -> submitChange($idForm): submitData=".varDump($submitData));
if ($new) {
// Check DN is not already exist
if (LSldap :: exists($dn)) {
return;
}
if (!$this -> fireEvent('before_create')) {
LSerror :: addErrorCode('LSldapObject_20');
return;
}
foreach ($submitData as $attr_name => $attr) {
if (!$this -> attrs[$attr_name] -> fireEvent('before_create')) {
LSerror :: addErrorCode('LSldapObject_20');
return;
}
}
}
if (!LSldap :: update($this -> getType(),$dn, $submitData)) {
return;
}
self :: log_debug($this." -> submitChange($idForm): changes applied in LDAP");
if ($new) {
if (!$this -> fireEvent('after_create')) {
LSerror :: addErrorCode('LSldapObject_21');
return;
}
foreach ($submitData as $attr_name => $attr) {
if (!$this -> attrs[$attr_name] -> fireEvent('after_create')) {
LSerror :: addErrorCode('LSldapObject_21');
return;
}
}
}
return true;
}
else {
LSerror :: addErrorCode('LSldapObject_13'); LSerror :: addErrorCode('LSldapObject_13');
return; return;
} }
$this -> dn = $dn;
self :: log_debug($this." -> submitChange($idForm): submitData=".varDump($submitData));
if ($new) {
// Check DN is not already exist
if (LSldap :: exists($dn)) {
return;
}
if (!$this -> fireEvent('before_create')) {
LSerror :: addErrorCode('LSldapObject_20');
return;
}
foreach ($submitData as $attr_name => $attr) {
if (!$this -> attrs[$attr_name] -> fireEvent('before_create')) {
LSerror :: addErrorCode('LSldapObject_20');
return;
}
}
}
if (!LSldap :: update($this -> getType(),$dn, $submitData)) {
self :: log_debug($this." -> submitChange($idForm): LSldap :: update() failed");
return;
}
self :: log_debug($this." -> submitChange($idForm): changes applied in LDAP");
if ($new) {
if (!$this -> fireEvent('after_create')) {
LSerror :: addErrorCode('LSldapObject_21');
return;
}
foreach ($submitData as $attr_name => $attr) {
if (!$this -> attrs[$attr_name] -> fireEvent('after_create')) {
LSerror :: addErrorCode('LSldapObject_21');
return;
}
}
}
return true;
} }
else { else {
self :: log_debug($this." -> submitChange($idForm): no change"); self :: log_debug($this." -> submitChange($idForm): no change");