- LSldapObject : Toutes les règles de validation des données d'un objet

sont executées avant le retour.
This commit is contained in:
Benjamin Renard 2008-11-10 15:32:56 +00:00
parent 270e48d872
commit b03848b1a1

View file

@ -364,13 +364,14 @@ class LSldapObject {
* @retval boolean true si les données sont valides, false sinon * @retval boolean true si les données sont valides, false sinon
*/ */
function validateAttrsData($idForm) { function validateAttrsData($idForm) {
$retval = true;
$LSform=$this -> forms[$idForm][0]; $LSform=$this -> forms[$idForm][0];
foreach($this -> attrs as $attr) { foreach($this -> attrs as $attr) {
$attr_values = $attr -> getValue(); $attr_values = $attr -> getValue();
if (!$attr -> isValidate()) { if (!$attr -> isValidate()) {
if($attr -> isUpdate()) { if($attr -> isUpdate()) {
if (!$this -> validateAttrData($LSform, $attr)) { if (!$this -> validateAttrData($LSform, $attr)) {
return; $retval = false;
} }
} }
else if( (empty($attr_values)) && ($attr -> isRequired()) ) { else if( (empty($attr_values)) && ($attr -> isRequired()) ) {
@ -378,23 +379,22 @@ class LSldapObject {
if ($attr -> generateValue()) { if ($attr -> generateValue()) {
if (!$this -> validateAttrData($LSform, $attr)) { if (!$this -> validateAttrData($LSform, $attr)) {
$GLOBALS['LSerror'] -> addErrorCode(48,$attr -> getLabel()); $GLOBALS['LSerror'] -> addErrorCode(48,$attr -> getLabel());
return; $retval = false;
} }
} }
else { else {
$GLOBALS['LSerror'] -> addErrorCode(47,$attr -> getLabel()); $GLOBALS['LSerror'] -> addErrorCode(47,$attr -> getLabel());
return; $retval = false;
} }
} }
else { else {
$GLOBALS['LSerror'] -> addErrorCode(46,$attr -> getLabel()); $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 * @retval boolean true si les données sont valides, false sinon
*/ */
function validateAttrData(&$LSform,&$attr) { function validateAttrData(&$LSform,&$attr) {
$retval = true;
$vconfig=$attr -> getValidateConfig(); $vconfig=$attr -> getValidateConfig();
$data=$attr -> getUpdateData(); $data=$attr -> getUpdateData();
@ -455,13 +457,13 @@ class LSldapObject {
if($test['result']==0) { if($test['result']==0) {
if($ret!=0) { if($ret!=0) {
$LSform -> setElementError($attr,$msg_error); $LSform -> setElementError($attr,$msg_error);
return; $retval = false;
} }
} }
else { else {
if($ret<0) { if($ret<0) {
$LSform -> setElementError($attr,$msg_error); $LSform -> setElementError($attr,$msg_error);
return; $retval = false;
} }
} }
} }
@ -470,17 +472,17 @@ class LSldapObject {
if (function_exists($test['function'])) { if (function_exists($test['function'])) {
if(!$test['function']($this)) { if(!$test['function']($this)) {
$LSform -> setElementError($attr,$msg_error); $LSform -> setElementError($attr,$msg_error);
return; $retval = false;
} }
} }
else { else {
$GLOBALS['LSerror'] -> addErrorCode(24,array('attr' => $attr->name,'obj' => $this->getType(),'func' => $test['function'])); $GLOBALS['LSerror'] -> addErrorCode(24,array('attr' => $attr->name,'obj' => $this->getType(),'func' => $test['function']));
return; $retval = false;
} }
} }
else { else {
$GLOBALS['LSerror'] -> addErrorCode(25,array('attr' => $attr->name,'obj' => $this->getType())); $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] -> canBeGenerated()) {
if (!$this -> attrs[$dependAttr] -> generateValue()) { if (!$this -> attrs[$dependAttr] -> generateValue()) {
$GLOBALS['LSerror'] -> addErrorCode(47,$this -> attrs[$dependAttr] -> getLabel()); $GLOBALS['LSerror'] -> addErrorCode(47,$this -> attrs[$dependAttr] -> getLabel());
return; $retval = false;
} }
} }
else { else {
$GLOBALS['LSerror'] -> addErrorCode(46,$this -> attrs[$dependAttr] -> getLabel()); $GLOBALS['LSerror'] -> addErrorCode(46,$this -> attrs[$dependAttr] -> getLabel());
return; $retval = false;
} }
} }
} }
$attr -> validate(); $attr -> validate();
unset($this -> other_values['val']); unset($this -> other_values['val']);
return true; return $retval;
} }
/** /**