diff --git a/src/includes/class/class.LSattr_html.php b/src/includes/class/class.LSattr_html.php
index d373af1a..fba6eb06 100644
--- a/src/includes/class/class.LSattr_html.php
+++ b/src/includes/class/class.LSattr_html.php
@@ -94,9 +94,8 @@ class LSattr_html extends LSlog_staticLoggerClass {
LSerror :: addErrorCode('LSform_06',$this -> name);
return;
}
- if ($data) {
+ if (!is_null($data))
$element -> setValue($data);
- }
return $element;
}
diff --git a/src/includes/class/class.LSattribute.php b/src/includes/class/class.LSattribute.php
index d98752bb..19812c93 100644
--- a/src/includes/class/class.LSattribute.php
+++ b/src/includes/class/class.LSattribute.php
@@ -115,9 +115,10 @@ class LSattribute extends LSlog_staticLoggerClass {
* @retval boolean true
*/
public function loadData($attr_data) {
- if ((!is_array($attr_data))&&(!empty($attr_data))) {
+ if (is_empty($attr_data) || $attr_data === false)
+ $attr_data = null;
+ elseif (!is_array($attr_data))
$attr_data = array($attr_data);
- }
$this -> data = $attr_data;
return true;
}
@@ -231,13 +232,13 @@ class LSattribute extends LSlog_staticLoggerClass {
if($this -> myRights() == 'n') {
return true;
}
- if ($value) {
+ if (!is_null($value)) {
$data = $value;
}
- else if($this -> data !='') {
+ else if(!is_empty($this -> data)) {
$data = $this -> getFormVal();
}
- else if ($this -> getConfig('default_value')) {
+ else if (!is_empty($this -> getConfig('default_value'))) {
$data = $obj -> getFData($this -> getConfig('default_value'));
}
else {
@@ -338,11 +339,11 @@ class LSattribute extends LSlog_staticLoggerClass {
LSerror :: addErrorCode('LSattribute_09',array('type' => 'html','name' => $this -> name));
return;
}
- if($this -> data !='') {
- $data=$this -> getFormVal();
+ if(!is_empty($this -> data)) {
+ $data = $this -> getFormVal();
}
else {
- $data='';
+ $data=null;
}
$element = $this -> html -> addToForm($form,'view',$data);
if(!$element instanceof LSformElement) {
diff --git a/src/includes/class/class.LSform.php b/src/includes/class/class.LSform.php
index 522d6173..82bb739a 100644
--- a/src/includes/class/class.LSform.php
+++ b/src/includes/class/class.LSform.php
@@ -412,7 +412,7 @@ class LSform extends LSlog_staticLoggerClass {
*/
public function checkRequired($data) {
foreach($data as $val) {
- if (!empty($val)||(is_string($val)&&($val=="0")))
+ if (!is_empty($val))
return true;
}
return;
diff --git a/src/includes/class/class.LSformElement.php b/src/includes/class/class.LSformElement.php
index 1c8c6721..0b2e0356 100644
--- a/src/includes/class/class.LSformElement.php
+++ b/src/includes/class/class.LSformElement.php
@@ -258,7 +258,7 @@ class LSformElement extends LSlog_staticLoggerClass {
$post[$name] = array($post[$name]);
}
foreach($post[$name] as $key => $val) {
- if (!empty($val)||(is_string($val)&&($val=="0"))) {
+ if (!is_empty($val)) {
$return[$key] = $val;
}
}
diff --git a/src/includes/class/class.LSformElement_labeledValue.php b/src/includes/class/class.LSformElement_labeledValue.php
index c0b8ed16..36c6d270 100644
--- a/src/includes/class/class.LSformElement_labeledValue.php
+++ b/src/includes/class/class.LSformElement_labeledValue.php
@@ -122,7 +122,7 @@ class LSformElement_labeledValue extends LSformElement {
}
foreach($_POST[$this -> name."_labels"] as $key => $label) {
$val=$_POST[$this -> name."_values"][$key];
- if (!empty($label) && (!empty($val)||(is_string($val)&&($val=="0")))) {
+ if (!empty($label) && !is_empty($val)) {
$return[$this -> name][$key] = "[$label]$val";
}
}
diff --git a/src/includes/class/class.LSldap.php b/src/includes/class/class.LSldap.php
index 249cf0da..21f083b9 100644
--- a/src/includes/class/class.LSldap.php
+++ b/src/includes/class/class.LSldap.php
@@ -314,14 +314,14 @@ class LSldap extends LSlog_staticLoggerClass {
$drop = true;
if (is_array($attrVal)) {
foreach($attrVal as $val) {
- if (!empty($val)||(is_string($val)&&($val=="0"))) {
+ if (!is_empty($val)) {
$drop = false;
$changed_attrs[$attrName][]=$val;
}
}
}
else {
- if (!empty($attrVal)||(is_string($attrVal)&&($attrVal=="0"))) {
+ if (!is_empty($val)) {
$drop = false;
$changed_attrs[$attrName][]=$attrVal;
}
diff --git a/src/includes/functions.php b/src/includes/functions.php
index 4b8da721..19bbfbf5 100644
--- a/src/includes/functions.php
+++ b/src/includes/functions.php
@@ -764,3 +764,21 @@ function format_callable($callable) {
else
return $callable."()";
}
+
+function is_empty($val) {
+ switch(gettype($val)) {
+ case "boolean":
+ case "integer":
+ case "double":
+ case "object":
+ case "resource":
+ return False;
+ case "array":
+ case "string":
+ if ($val == "0") return false;
+ return empty($val);
+ case "NULL":
+ return True;
+ }
+ return empty($val);
+}