From b03848b1a1ca0fc3a97d4511f6f7c18076406bd6 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 10 Nov 2008 15:32:56 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSldapObject=20:=20Toutes=20les=20r=C3=A8gl?= =?UTF-8?q?es=20de=20validation=20des=20donn=C3=A9es=20d'un=20objet=20=09s?= =?UTF-8?q?ont=20execut=C3=A9es=20avant=20le=20retour.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/class/class.LSldapObject.php | 30 +++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/trunk/includes/class/class.LSldapObject.php b/trunk/includes/class/class.LSldapObject.php index 61b446dc..f9aaf093 100644 --- a/trunk/includes/class/class.LSldapObject.php +++ b/trunk/includes/class/class.LSldapObject.php @@ -364,13 +364,14 @@ class LSldapObject { * @retval boolean true si les données sont valides, false sinon */ function validateAttrsData($idForm) { + $retval = true; $LSform=$this -> forms[$idForm][0]; foreach($this -> attrs as $attr) { $attr_values = $attr -> getValue(); if (!$attr -> isValidate()) { if($attr -> isUpdate()) { if (!$this -> validateAttrData($LSform, $attr)) { - return; + $retval = false; } } else if( (empty($attr_values)) && ($attr -> isRequired()) ) { @@ -378,23 +379,22 @@ class LSldapObject { if ($attr -> generateValue()) { if (!$this -> validateAttrData($LSform, $attr)) { $GLOBALS['LSerror'] -> addErrorCode(48,$attr -> getLabel()); - return; + $retval = false; } } else { $GLOBALS['LSerror'] -> addErrorCode(47,$attr -> getLabel()); - return; + $retval = false; } } else { $GLOBALS['LSerror'] -> addErrorCode(46,$attr -> getLabel()); - return; + $retval = false; } - } } } - return true; + return $retval; } /** @@ -408,6 +408,8 @@ class LSldapObject { * @retval boolean true si les données sont valides, false sinon */ function validateAttrData(&$LSform,&$attr) { + $retval = true; + $vconfig=$attr -> getValidateConfig(); $data=$attr -> getUpdateData(); @@ -455,13 +457,13 @@ class LSldapObject { if($test['result']==0) { if($ret!=0) { $LSform -> setElementError($attr,$msg_error); - return; + $retval = false; } } else { if($ret<0) { $LSform -> setElementError($attr,$msg_error); - return; + $retval = false; } } } @@ -470,17 +472,17 @@ class LSldapObject { if (function_exists($test['function'])) { if(!$test['function']($this)) { $LSform -> setElementError($attr,$msg_error); - return; + $retval = false; } } else { $GLOBALS['LSerror'] -> addErrorCode(24,array('attr' => $attr->name,'obj' => $this->getType(),'func' => $test['function'])); - return; + $retval = false; } } else { $GLOBALS['LSerror'] -> addErrorCode(25,array('attr' => $attr->name,'obj' => $this->getType())); - return; + $retval = false; } } } @@ -496,19 +498,19 @@ class LSldapObject { if($this -> attrs[$dependAttr] -> canBeGenerated()) { if (!$this -> attrs[$dependAttr] -> generateValue()) { $GLOBALS['LSerror'] -> addErrorCode(47,$this -> attrs[$dependAttr] -> getLabel()); - return; + $retval = false; } } else { $GLOBALS['LSerror'] -> addErrorCode(46,$this -> attrs[$dependAttr] -> getLabel()); - return; + $retval = false; } } } $attr -> validate(); unset($this -> other_values['val']); - return true; + return $retval; } /**