From d7b65d3455f35a74def99005b7f7a70ef907e6a1 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 15 Oct 2008 10:46:09 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSformElement=5Fboolean=20:=20Correction=20?= =?UTF-8?q?des=20bugs=20par=20rapport=20=C3=A0=20la=20diff=C3=A9rentiation?= =?UTF-8?q?=20=09des=20valeurs=20false/vide?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LSobjects/config.LSobjects.LSeepeople.php | 2 +- .../class/class.LSattr_ldap_boolean.php | 28 ++++++++++++++++--- .../class/class.LSformElement_boolean.php | 19 ++++++++++++- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php index 650a87db..00ace6ea 100644 --- a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php +++ b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php @@ -229,7 +229,7 @@ $GLOBALS['LSobjects']['LSeepeople'] = array ( 'ldap_type' => 'boolean', 'html_type' => 'boolean', 'required' => 1, - 'default_value' => '/bin/false', + 'default_value' => 'no', 'rights' => array( 'self' => 'r', 'admin' => 'w' diff --git a/trunk/includes/class/class.LSattr_ldap_boolean.php b/trunk/includes/class/class.LSattr_ldap_boolean.php index 0fa8b913..84dcc102 100644 --- a/trunk/includes/class/class.LSattr_ldap_boolean.php +++ b/trunk/includes/class/class.LSattr_ldap_boolean.php @@ -34,9 +34,11 @@ class LSattr_ldap_boolean extends LSattr_ldap { * @retval mixed La valeur d'affichage de l'attribut */ function getDisplayValue($data) { - if ($data==NULL) - return; - return ($this -> isTrue($data))?'yes':'no'; + if ($this -> isTrue($data)) + return 'yes'; + if ($this -> isFalse($data)) + return 'no'; + return; } /** @@ -50,9 +52,10 @@ class LSattr_ldap_boolean extends LSattr_ldap { if ($data[0]=='yes') { return array($this -> config['true_value']); } - else { + if ($data[0]=='no') { return array($this -> config['false_value']); } + return array(); } /** @@ -71,6 +74,23 @@ class LSattr_ldap_boolean extends LSattr_ldap { } 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; + } } ?> diff --git a/trunk/includes/class/class.LSformElement_boolean.php b/trunk/includes/class/class.LSformElement_boolean.php index 3a965aa3..bd6b6d32 100644 --- a/trunk/includes/class/class.LSformElement_boolean.php +++ b/trunk/includes/class/class.LSformElement_boolean.php @@ -49,7 +49,7 @@ class LSformElement_boolean extends LSformElement { } else { foreach ($this -> values as $value) { - $return['html'] .= "
  • isTrue($this -> values))?'checked':'')." /> "._('Oui')." isTrue($this -> values))?'':'checked')." /> "._('Non')."
  • \n"; + $return['html'] .= "
  • isTrue($this -> values))?'checked':'')." /> "._('Oui')." isFalse($this -> values))?'checked':'')." /> "._('Non')."
  • \n"; } } $return['html'] .= "\n"; @@ -97,6 +97,23 @@ class LSformElement_boolean extends LSformElement { 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; + } + } ?>