mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2025-03-28 14:51:34 +01:00
Fix handling "0" (zero string) value
This commit is contained in:
parent
822d777dfd
commit
052882eb49
7 changed files with 33 additions and 15 deletions
|
@ -94,9 +94,8 @@ class LSattr_html extends LSlog_staticLoggerClass {
|
||||||
LSerror :: addErrorCode('LSform_06',$this -> name);
|
LSerror :: addErrorCode('LSform_06',$this -> name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($data) {
|
if (!is_null($data))
|
||||||
$element -> setValue($data);
|
$element -> setValue($data);
|
||||||
}
|
|
||||||
return $element;
|
return $element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,9 +115,10 @@ class LSattribute extends LSlog_staticLoggerClass {
|
||||||
* @retval boolean true
|
* @retval boolean true
|
||||||
*/
|
*/
|
||||||
public function loadData($attr_data) {
|
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);
|
$attr_data = array($attr_data);
|
||||||
}
|
|
||||||
$this -> data = $attr_data;
|
$this -> data = $attr_data;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -231,13 +232,13 @@ class LSattribute extends LSlog_staticLoggerClass {
|
||||||
if($this -> myRights() == 'n') {
|
if($this -> myRights() == 'n') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ($value) {
|
if (!is_null($value)) {
|
||||||
$data = $value;
|
$data = $value;
|
||||||
}
|
}
|
||||||
else if($this -> data !='') {
|
else if(!is_empty($this -> data)) {
|
||||||
$data = $this -> getFormVal();
|
$data = $this -> getFormVal();
|
||||||
}
|
}
|
||||||
else if ($this -> getConfig('default_value')) {
|
else if (!is_empty($this -> getConfig('default_value'))) {
|
||||||
$data = $obj -> getFData($this -> getConfig('default_value'));
|
$data = $obj -> getFData($this -> getConfig('default_value'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -338,11 +339,11 @@ class LSattribute extends LSlog_staticLoggerClass {
|
||||||
LSerror :: addErrorCode('LSattribute_09',array('type' => 'html','name' => $this -> name));
|
LSerror :: addErrorCode('LSattribute_09',array('type' => 'html','name' => $this -> name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($this -> data !='') {
|
if(!is_empty($this -> data)) {
|
||||||
$data=$this -> getFormVal();
|
$data = $this -> getFormVal();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$data='';
|
$data=null;
|
||||||
}
|
}
|
||||||
$element = $this -> html -> addToForm($form,'view',$data);
|
$element = $this -> html -> addToForm($form,'view',$data);
|
||||||
if(!$element instanceof LSformElement) {
|
if(!$element instanceof LSformElement) {
|
||||||
|
|
|
@ -412,7 +412,7 @@ class LSform extends LSlog_staticLoggerClass {
|
||||||
*/
|
*/
|
||||||
public function checkRequired($data) {
|
public function checkRequired($data) {
|
||||||
foreach($data as $val) {
|
foreach($data as $val) {
|
||||||
if (!empty($val)||(is_string($val)&&($val=="0")))
|
if (!is_empty($val))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -258,7 +258,7 @@ class LSformElement extends LSlog_staticLoggerClass {
|
||||||
$post[$name] = array($post[$name]);
|
$post[$name] = array($post[$name]);
|
||||||
}
|
}
|
||||||
foreach($post[$name] as $key => $val) {
|
foreach($post[$name] as $key => $val) {
|
||||||
if (!empty($val)||(is_string($val)&&($val=="0"))) {
|
if (!is_empty($val)) {
|
||||||
$return[$key] = $val;
|
$return[$key] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ class LSformElement_labeledValue extends LSformElement {
|
||||||
}
|
}
|
||||||
foreach($_POST[$this -> name."_labels"] as $key => $label) {
|
foreach($_POST[$this -> name."_labels"] as $key => $label) {
|
||||||
$val=$_POST[$this -> name."_values"][$key];
|
$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";
|
$return[$this -> name][$key] = "[$label]$val";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,14 +314,14 @@ class LSldap extends LSlog_staticLoggerClass {
|
||||||
$drop = true;
|
$drop = true;
|
||||||
if (is_array($attrVal)) {
|
if (is_array($attrVal)) {
|
||||||
foreach($attrVal as $val) {
|
foreach($attrVal as $val) {
|
||||||
if (!empty($val)||(is_string($val)&&($val=="0"))) {
|
if (!is_empty($val)) {
|
||||||
$drop = false;
|
$drop = false;
|
||||||
$changed_attrs[$attrName][]=$val;
|
$changed_attrs[$attrName][]=$val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!empty($attrVal)||(is_string($attrVal)&&($attrVal=="0"))) {
|
if (!is_empty($val)) {
|
||||||
$drop = false;
|
$drop = false;
|
||||||
$changed_attrs[$attrName][]=$attrVal;
|
$changed_attrs[$attrName][]=$attrVal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -764,3 +764,21 @@ function format_callable($callable) {
|
||||||
else
|
else
|
||||||
return $callable."()";
|
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);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue