mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-25 11:29:06 +01:00
LSldapObject::validateAttrData(): fix validation on the current object it self (base DN=%{dn}) in create form and clean some PHP warnings
This commit is contained in:
parent
6646ca91f1
commit
d6a080c22c
1 changed files with 20 additions and 9 deletions
|
@ -583,14 +583,14 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
||||||
// Validate attribute values
|
// Validate attribute values
|
||||||
if ($justCheck) {
|
if ($justCheck) {
|
||||||
self :: log_trace(
|
self :: log_trace(
|
||||||
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
|
"validateAttrData(".($LSform?$LSform->idForm:null).", {$attr->name}): ".
|
||||||
"just check mode: do not validate attribute data using LDAP search"
|
"just check mode: do not validate attribute data using LDAP search"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach($attr -> getConfig('validation', array(), 'array') as $test) {
|
foreach($attr -> getConfig('validation', array(), 'array') as $test) {
|
||||||
self :: log_trace(
|
self :: log_trace(
|
||||||
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
|
"validateAttrData(".($LSform?$LSform->idForm:null).", {$attr->name}): ".
|
||||||
"run validation with following config:\n".varDump($test)
|
"run validation with following config:\n".varDump($test)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -636,12 +636,23 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
||||||
|
|
||||||
// Handle base_dn parameter
|
// Handle base_dn parameter
|
||||||
$sbasedn = LSconfig :: get('basedn', null, 'string', $test);
|
$sbasedn = LSconfig :: get('basedn', null, 'string', $test);
|
||||||
if ($sbasedn)
|
if ($sbasedn) {
|
||||||
|
if ($sbasedn == "%{dn}" && $LSform && $LSform -> idForm == 'create') {
|
||||||
|
self :: log_info(
|
||||||
|
"validateAttrData({$LSform->idForm}, {$attr->name}): Ignore attribute ".
|
||||||
|
"validation with filter '{$sfilter->asString()}' on the current object it self ".
|
||||||
|
"(base DN=$sbasedn) in create form"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$sbasedn = $this -> getFData($sbasedn);
|
$sbasedn = $this -> getFData($sbasedn);
|
||||||
|
}
|
||||||
|
|
||||||
// If except_current_object (and not create form), list matching objets to exclude current one
|
// If except_current_object (and not create form), list matching objets to exclude current one
|
||||||
if (LSconfig :: get('except_current_object', false, 'bool', $test) &&
|
if (
|
||||||
$LSform -> idForm != 'create') {
|
LSconfig :: get('except_current_object', false, 'bool', $test)
|
||||||
|
&& (!$LSform || $LSform -> idForm != 'create')
|
||||||
|
) {
|
||||||
$sret = LSldap :: search($sfilter, $sbasedn, $sparams);
|
$sret = LSldap :: search($sfilter, $sbasedn, $sparams);
|
||||||
$dn = $this->getDn();
|
$dn = $this->getDn();
|
||||||
$ret = 0;
|
$ret = 0;
|
||||||
|
@ -667,7 +678,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
||||||
) {
|
) {
|
||||||
$retval = false;
|
$retval = false;
|
||||||
self :: log_warning(
|
self :: log_warning(
|
||||||
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
|
"validateAttrData(".($LSform?$LSform->idForm:null).", {$attr->name}): ".
|
||||||
"validation with LDAP search on base DN='$sbasedn' and ".
|
"validation with LDAP search on base DN='$sbasedn' and ".
|
||||||
"filter='".($sfilter?$sfilter->as_string():null)."' error ($ret object(s) found)"
|
"filter='".($sfilter?$sfilter->as_string():null)."' error ($ret object(s) found)"
|
||||||
);
|
);
|
||||||
|
@ -676,7 +687,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
self :: log_trace(
|
self :: log_trace(
|
||||||
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
|
"validateAttrData(".($LSform?$LSform->idForm:null).", {$attr->name}): ".
|
||||||
"validation with LDAP search on base DN='$sbasedn' and ".
|
"validation with LDAP search on base DN='$sbasedn' and ".
|
||||||
"filter='".($sfilter?$sfilter->as_string():null)."' success ($ret object(s) found)"
|
"filter='".($sfilter?$sfilter->as_string():null)."' success ($ret object(s) found)"
|
||||||
);
|
);
|
||||||
|
@ -721,7 +732,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
||||||
$dependsAttrs = $attr->getDependsAttrs();
|
$dependsAttrs = $attr->getDependsAttrs();
|
||||||
if (empty($dependsAttrs)) {
|
if (empty($dependsAttrs)) {
|
||||||
self :: log_trace(
|
self :: log_trace(
|
||||||
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
|
"validateAttrData(".($LSform?$LSform->idForm:null).", {$attr->name}): ".
|
||||||
"no dependent attribute"
|
"no dependent attribute"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -735,7 +746,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
self :: log_debug(
|
self :: log_debug(
|
||||||
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
|
"validateAttrData(".($LSform?$LSform->idForm:null).", {$attr->name}): ".
|
||||||
'Attribute '.$attr->name.' updated: generate new value for attribute '.$dependAttr
|
'Attribute '.$attr->name.' updated: generate new value for attribute '.$dependAttr
|
||||||
);
|
);
|
||||||
if($this -> attrs[$dependAttr] -> canBeGenerated()) {
|
if($this -> attrs[$dependAttr] -> canBeGenerated()) {
|
||||||
|
|
Loading…
Reference in a new issue