From c3fd2b1a66fa79fde4e73b44228e3df734ad62bc Mon Sep 17 00:00:00 2001
From: A. Täffner <darkalex@firesplash.de>
Date: Wed, 20 Jan 2016 07:48:04 -0500
Subject: [PATCH] cleanup

---
 interface/lib/classes/listform.inc.php |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/interface/lib/classes/listform.inc.php b/interface/lib/classes/listform.inc.php
index c8a9225..120e652 100644
--- a/interface/lib/classes/listform.inc.php
+++ b/interface/lib/classes/listform.inc.php
@@ -124,6 +124,17 @@
 				$this->errorMessage .= "Custom datasource class or function is empty<br />\r\n";
 			}
 		}
+		
+		if($api == false && isset($field['filters']) && is_array($field['filters'])) {
+			$new_values = array();
+			foreach($values as $index => $value) {
+				$new_index = $app->tform->filterField($index, $index, $field['filters'], 'SHOW');
+				$new_values[$new_index] = $app->tform->filterField($index, (isset($values[$index]))?$values[$index]:'', $field['filters'], 'SHOW');
+			}
+			$values = $new_values;
+			unset($new_values);
+			unset($new_index);
+		}
 		return $values;
 	}
 
@@ -186,6 +197,22 @@
 				$table = $i['table'];
 
 				$searchval = $_SESSION['search'][$list_name][$search_prefix.$field];
+				// IDN
+				if($searchval != ''){
+					if(is_array($i['filters'])) {
+						foreach($i['filters'] as $searchval_filter) {
+							if($searchval_filter['event'] == 'SHOW') {
+								switch ($searchval_filter['type']) {
+								case 'IDNTOUTF8':
+									$searchval = $app->functions->idn_encode($searchval);
+									//echo $searchval;
+									break;
+								}
+							}
+						}
+					}
+				}
+		
 				// format user date format to MySQL date format 0000-00-00
 				if($i['datatype'] == 'DATE' && $this->lng('conf_format_dateshort') != 'Y-m-d'){
 					$dateformat = preg_replace("@[^Ymd]@", "", $this->lng('conf_format_dateshort'));
@@ -230,10 +257,23 @@
 						$searchval = $year.'-'.$month.'-'.$day;
 					}
 				}
+				
+				if($i['datatype'] == 'BOOLEAN' && $searchval != ''){
+					if (!function_exists('boolval')) {
+						$searchval = (bool) $searchval;
+						if($searchval === true){
+							$searchval = 'TRUE';
+						} else {
+							$searchval = 'FALSE';
+						}
+					} else {
+						$searchval = boolval($searchval)? 'TRUE' : 'FALSE';
+					}
+				}
 
 				// if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and";
 				if(isset($searchval) && $searchval != ''){
-					$sql_where .= " ".($table != ''? $table.'.' : $this->listDef['table'].'.')."$field ".$i['op']." '".$app->db->quote($i['prefix'].$searchval.$i['suffix'])."' and";
+					$sql_where .= " ".($table != ''? $table.'.' : $this->listDef['table'].'.')."$field ".$i['op']." ".($i['datatype'] == 'BOOLEAN'? "" : "'").$app->db->quote($i['prefix'].$searchval.$i['suffix']).($i['datatype'] == 'BOOLEAN'? "" : "'")." and";
 				}
 			}
 		}
@@ -357,7 +397,7 @@
 		if(isset($vars['show_page_back']) && $vars['show_page_back'] == 1){
 			$content .= '<li><a href="#" data-load-content="'.$vars['list_file'].'?page=0'.$vars['page_params'].'" aria-label="First">
 			<span aria-hidden="true">&laquo;</span></a></li>';
-			$content .= '<li><a href="#" data-load-content='.$vars['list_file'].'?page='.$vars['last_page'].$vars['page_params'].'" aria-label="Previous">
+			$content .= '<li><a href="#" data-load-content="'.$vars['list_file'].'?page='.$vars['last_page'].$vars['page_params'].'" aria-label="Previous">
 			<span aria-hidden="true">&lsaquo;</span></a></li>';
 		}
 		$prev = -1;
@@ -474,6 +514,14 @@
 					case 'CURRENCY':
 						$record[$key] = $app->functions->currency_format($record[$key]);
 						break;
+						
+					case 'BOOLEAN':
+						if (!function_exists('boolval')) {
+							$record[$key] = (bool) $record[$key];
+						} else {
+							$record[$key] = boolval($record[$key]);
+						}
+						break;
 
 					default:
 						$record[$key] = htmlentities(stripslashes($record[$key]), ENT_QUOTES, $conf["html_content_encoding"]);
@@ -537,6 +585,14 @@
 				case 'CURRENCY':
 					$record[$key] = str_replace(',', '.', $record[$key]);
 					break;
+				
+				case 'BOOLEAN':
+					if (!function_exists('boolval')) {
+						$record[$key] = (bool) $record[$key];
+					} else {
+						$record[$key] = boolval($record[$key]);
+					}
+					break;
 				}
 			}
 		}

--
Gitblit v1.9.1