- LSldap : Ajout de debug

- LSldapObject : Modification des triggers after_modify et before_modify des
	attributs pour les rendre multiple si nécéssaire
This commit is contained in:
Benjamin Renard 2008-10-14 13:02:03 +00:00
parent 74afda65d5
commit f649783f86
2 changed files with 32 additions and 14 deletions

View file

@ -290,9 +290,11 @@ class LSldap {
LSdebug('drop : <pre>'.print_r($dropAttr,true).'</pre>'); LSdebug('drop : <pre>'.print_r($dropAttr,true).'</pre>');
if ($new) { if ($new) {
LSdebug('LSldap :: add()');
$ret = $this -> cnx -> add($entry); $ret = $this -> cnx -> add($entry);
} }
else { else {
LSdebug('LSldap :: update()');
$ret = $entry -> update(); $ret = $entry -> update();
} }

View file

@ -319,18 +319,26 @@ class LSldapObject {
// $this -> attrs[*] => before_modify // $this -> attrs[*] => before_modify
foreach($new_data as $attr_name => $attr_val) { foreach($new_data as $attr_name => $attr_val) {
if(isset($this -> config['attrs'][$attr_name]['before_modify'])) { if(isset($this -> config['attrs'][$attr_name]['before_modify'])) {
if(function_exists($this -> config['attrs'][$attr_name]['before_modify'])) { if (!is_array($this -> config['attrs'][$attr_name]['before_modify'])) {
if(!$this -> config['attrs'][$attr_name]['before_modify']($this)) { $funcs = array($this -> config['attrs'][$attr_name]['before_modify']);
$GLOBALS['LSerror'] -> addErrorCode(309,array('func' => $this -> config['attrs'][$attr_name]['before_modify'],'attr' => $attr_name)); }
else {
$funcs = $this -> config['attrs'][$attr_name]['before_modify'];
}
foreach($funcs as $func) {
if(function_exists($func)) {
if(!$func($this)) {
$GLOBALS['LSerror'] -> addErrorCode(309,array('func' => $func,'attr' => $attr_name));
return; return;
} }
} }
else { else {
$GLOBALS['LSerror'] -> addErrorCode(308,array('func' => $this -> config['attrs'][$attr_name]['before_modify'],'attr' => $attr_name)); $GLOBALS['LSerror'] -> addErrorCode(308,array('func' => $func,'attr' => $attr_name));
return; return;
} }
} }
} }
}
if ($this -> submitChange($idForm)) { if ($this -> submitChange($idForm)) {
LSdebug('Les modifications sont submitées'); LSdebug('Les modifications sont submitées');
@ -357,18 +365,26 @@ class LSldapObject {
// $this -> attrs[*] => After Modify // $this -> attrs[*] => After Modify
foreach($new_data as $attr_name => $attr_val) { foreach($new_data as $attr_name => $attr_val) {
if(isset($this -> config['attrs'][$attr_name]['after_modify'])) { if(isset($this -> config['attrs'][$attr_name]['after_modify'])) {
if(function_exists($this -> config['attrs'][$attr_name]['after_modify'])) { if (!is_array($this -> config['attrs'][$attr_name]['after_modify'])) {
if(!$this -> config['attrs'][$attr_name]['after_modify']($this)) { $funcs = array($this -> config['attrs'][$attr_name]['after_modify']);
$GLOBALS['LSerror'] -> addErrorCode(307,array('func' => $this -> config['after_modify'],'attr' => $attr_name)); }
else {
$funcs = $this -> config['attrs'][$attr_name]['after_modify'];
}
foreach($funcs as $func) {
if(function_exists($func)) {
if(!$func($this)) {
$GLOBALS['LSerror'] -> addErrorCode(307,array('func' => $func,'attr' => $attr_name));
return; return;
} }
} }
else { else {
$GLOBALS['LSerror'] -> addErrorCode(306,array('func' => $this -> config['after_modify'],'attr' => $attr_name)); $GLOBALS['LSerror'] -> addErrorCode(306,array('func' => $func,'attr' => $attr_name));
return; return;
} }
} }
} }
}
return true; return true;
} }
else { else {