From f649783f861774f8af3aa6f08cb78ec83e9e3970 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 14 Oct 2008 13:02:03 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSldap=20:=20Ajout=20de=20debug=20-=20LSlda?= =?UTF-8?q?pObject=20:=20Modification=20des=20triggers=20after=5Fmodify=20?= =?UTF-8?q?et=20before=5Fmodify=20des=20=09attributs=20pour=20les=20rendre?= =?UTF-8?q?=20multiple=20si=20n=C3=A9c=C3=A9ssaire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/class/class.LSldap.php | 2 + trunk/includes/class/class.LSldapObject.php | 44 ++++++++++++++------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/trunk/includes/class/class.LSldap.php b/trunk/includes/class/class.LSldap.php index 5a96ff15..6e43d425 100644 --- a/trunk/includes/class/class.LSldap.php +++ b/trunk/includes/class/class.LSldap.php @@ -290,9 +290,11 @@ class LSldap { LSdebug('drop :
'.print_r($dropAttr,true).'
'); if ($new) { + LSdebug('LSldap :: add()'); $ret = $this -> cnx -> add($entry); } else { + LSdebug('LSldap :: update()'); $ret = $entry -> update(); } diff --git a/trunk/includes/class/class.LSldapObject.php b/trunk/includes/class/class.LSldapObject.php index c2daa0b5..bc3c30f8 100644 --- a/trunk/includes/class/class.LSldapObject.php +++ b/trunk/includes/class/class.LSldapObject.php @@ -319,15 +319,23 @@ class LSldapObject { // $this -> attrs[*] => before_modify foreach($new_data as $attr_name => $attr_val) { if(isset($this -> config['attrs'][$attr_name]['before_modify'])) { - if(function_exists($this -> config['attrs'][$attr_name]['before_modify'])) { - if(!$this -> config['attrs'][$attr_name]['before_modify']($this)) { - $GLOBALS['LSerror'] -> addErrorCode(309,array('func' => $this -> config['attrs'][$attr_name]['before_modify'],'attr' => $attr_name)); - return; - } + if (!is_array($this -> config['attrs'][$attr_name]['before_modify'])) { + $funcs = array($this -> config['attrs'][$attr_name]['before_modify']); } else { - $GLOBALS['LSerror'] -> addErrorCode(308,array('func' => $this -> config['attrs'][$attr_name]['before_modify'],'attr' => $attr_name)); - return; + $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; + } + } + else { + $GLOBALS['LSerror'] -> addErrorCode(308,array('func' => $func,'attr' => $attr_name)); + return; + } } } } @@ -357,15 +365,23 @@ class LSldapObject { // $this -> attrs[*] => After Modify foreach($new_data as $attr_name => $attr_val) { if(isset($this -> config['attrs'][$attr_name]['after_modify'])) { - if(function_exists($this -> config['attrs'][$attr_name]['after_modify'])) { - if(!$this -> config['attrs'][$attr_name]['after_modify']($this)) { - $GLOBALS['LSerror'] -> addErrorCode(307,array('func' => $this -> config['after_modify'],'attr' => $attr_name)); - return; - } + if (!is_array($this -> config['attrs'][$attr_name]['after_modify'])) { + $funcs = array($this -> config['attrs'][$attr_name]['after_modify']); } else { - $GLOBALS['LSerror'] -> addErrorCode(306,array('func' => $this -> config['after_modify'],'attr' => $attr_name)); - return; + $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; + } + } + else { + $GLOBALS['LSerror'] -> addErrorCode(306,array('func' => $func,'attr' => $attr_name)); + return; + } } } }