mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 14:33:49 +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
|
||||
if ($justCheck) {
|
||||
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"
|
||||
);
|
||||
}
|
||||
else {
|
||||
foreach($attr -> getConfig('validation', array(), 'array') as $test) {
|
||||
self :: log_trace(
|
||||
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
|
||||
"validateAttrData(".($LSform?$LSform->idForm:null).", {$attr->name}): ".
|
||||
"run validation with following config:\n".varDump($test)
|
||||
);
|
||||
|
||||
|
@ -636,12 +636,23 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
|
||||
// Handle base_dn parameter
|
||||
$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);
|
||||
}
|
||||
|
||||
// If except_current_object (and not create form), list matching objets to exclude current one
|
||||
if (LSconfig :: get('except_current_object', false, 'bool', $test) &&
|
||||
$LSform -> idForm != 'create') {
|
||||
if (
|
||||
LSconfig :: get('except_current_object', false, 'bool', $test)
|
||||
&& (!$LSform || $LSform -> idForm != 'create')
|
||||
) {
|
||||
$sret = LSldap :: search($sfilter, $sbasedn, $sparams);
|
||||
$dn = $this->getDn();
|
||||
$ret = 0;
|
||||
|
@ -667,7 +678,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
) {
|
||||
$retval = false;
|
||||
self :: log_warning(
|
||||
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
|
||||
"validateAttrData(".($LSform?$LSform->idForm:null).", {$attr->name}): ".
|
||||
"validation with LDAP search on base DN='$sbasedn' and ".
|
||||
"filter='".($sfilter?$sfilter->as_string():null)."' error ($ret object(s) found)"
|
||||
);
|
||||
|
@ -676,7 +687,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
}
|
||||
else {
|
||||
self :: log_trace(
|
||||
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
|
||||
"validateAttrData(".($LSform?$LSform->idForm:null).", {$attr->name}): ".
|
||||
"validation with LDAP search on base DN='$sbasedn' and ".
|
||||
"filter='".($sfilter?$sfilter->as_string():null)."' success ($ret object(s) found)"
|
||||
);
|
||||
|
@ -721,7 +732,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
$dependsAttrs = $attr->getDependsAttrs();
|
||||
if (empty($dependsAttrs)) {
|
||||
self :: log_trace(
|
||||
"validateAttrData(".$LSform->idForm.", ".$attr->name."): ".
|
||||
"validateAttrData(".($LSform?$LSform->idForm:null).", {$attr->name}): ".
|
||||
"no dependent attribute"
|
||||
);
|
||||
}
|
||||
|
@ -735,7 +746,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
continue;
|
||||
}
|
||||
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
|
||||
);
|
||||
if($this -> attrs[$dependAttr] -> canBeGenerated()) {
|
||||
|
|
Loading…
Reference in a new issue