- LSformElement_boolean : Correction des bugs par rapport à la différentiation

des valeurs false/vide
This commit is contained in:
Benjamin Renard 2008-10-15 10:46:09 +00:00
parent 220dcd7352
commit d7b65d3455
3 changed files with 43 additions and 6 deletions

View file

@ -229,7 +229,7 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
'ldap_type' => 'boolean', 'ldap_type' => 'boolean',
'html_type' => 'boolean', 'html_type' => 'boolean',
'required' => 1, 'required' => 1,
'default_value' => '/bin/false', 'default_value' => 'no',
'rights' => array( 'rights' => array(
'self' => 'r', 'self' => 'r',
'admin' => 'w' 'admin' => 'w'

View file

@ -34,9 +34,11 @@ class LSattr_ldap_boolean extends LSattr_ldap {
* @retval mixed La valeur d'affichage de l'attribut * @retval mixed La valeur d'affichage de l'attribut
*/ */
function getDisplayValue($data) { function getDisplayValue($data) {
if ($data==NULL) if ($this -> isTrue($data))
return 'yes';
if ($this -> isFalse($data))
return 'no';
return; return;
return ($this -> isTrue($data))?'yes':'no';
} }
/** /**
@ -50,9 +52,10 @@ class LSattr_ldap_boolean extends LSattr_ldap {
if ($data[0]=='yes') { if ($data[0]=='yes') {
return array($this -> config['true_value']); return array($this -> config['true_value']);
} }
else { if ($data[0]=='no') {
return array($this -> config['false_value']); return array($this -> config['false_value']);
} }
return array();
} }
/** /**
@ -71,6 +74,23 @@ class LSattr_ldap_boolean extends LSattr_ldap {
} }
return; return;
} }
/**
* Determine si la valeur passé en paramètre correspond a False ou non
*
* @param[in] $data La valeur de l'attribut
*
* @retval boolean True ou False
*/
function isFalse($data) {
if (!is_array($data)) {
$data=array($data);
}
if ($data[0] == $this -> config['false_value']) {
return true;
}
return;
}
} }
?> ?>

View file

@ -49,7 +49,7 @@ class LSformElement_boolean extends LSformElement {
} }
else { else {
foreach ($this -> values as $value) { foreach ($this -> values as $value) {
$return['html'] .= "<li class='LSformElement_boolean'><input type='radio' value='yes' name='".$this -> name."[0]' ".(($this -> isTrue($this -> values))?'checked':'')." /> "._('Oui')."<input type='radio' value='no' name='".$this -> name."[0]' ".(($this -> isTrue($this -> values))?'':'checked')." /> "._('Non')."</li>\n"; $return['html'] .= "<li class='LSformElement_boolean'><input type='radio' value='yes' name='".$this -> name."[0]' ".(($this -> isTrue($this -> values))?'checked':'')." /> "._('Oui')."<input type='radio' value='no' name='".$this -> name."[0]' ".(($this -> isFalse($this -> values))?'checked':'')." /> "._('Non')."</li>\n";
} }
} }
$return['html'] .= "</ul>\n"; $return['html'] .= "</ul>\n";
@ -97,6 +97,23 @@ class LSformElement_boolean extends LSformElement {
return; return;
} }
/**
* Determine si la valeur passé en paramètre correspond a False ou non
*
* @param[in] $data La valeur de l'attribut
*
* @retval boolean True ou False
*/
function isFalse($data) {
if(!is_array($data)) {
$data=array($data);
}
if($data[0]=='no') {
return true;
}
return;
}
} }
?> ?>