From 0a8f0e4ece06642808c1b52d7ea9c4af3ea356a1 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Mon, 22 Oct 2012 07:18:05 -0400
Subject: [PATCH] Fixed: FS#2362 - client_id from remoting.inc.php functions is ignored
---
interface/lib/classes/tform.inc.php | 62 +++++++++++++++---------------
1 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php
index b01ea91..7789a81 100644
--- a/interface/lib/classes/tform.inc.php
+++ b/interface/lib/classes/tform.inc.php
@@ -54,14 +54,14 @@
* SEPARATOR
* - separator char used for fileds with multiple values
*
-* Hint: The auto increment (ID) filed of the table has not be be definied eoarately.
+* Hint: The auto increment (ID) filed of the table has not be be definied separately.
*
*/
class tform {
/**
- * Table definition (array)
+ * Definition of the database table (array)
* @var tableDef
*/
var $tableDef;
@@ -79,25 +79,25 @@
var $table_name;
/**
- * Enable debigging
+ * Debug Variable
* @var debug
*/
var $debug = 0;
/**
- * name of the primary field of the datbase table (string)
+ * name of the primary field of the database table (string)
* @var table_index
*/
var $table_index;
/**
- * contains the error message
+ * contains the error messages
* @var errorMessage
*/
var $errorMessage = '';
var $dateformat = "d.m.Y";
- var $formDef;
+ var $formDef = array();
var $wordbook;
var $module;
var $primary_id;
@@ -124,7 +124,7 @@
function loadFormDef($file,$module = '') {
global $app,$conf;
- include_once($file);
+ include($file);
$this->formDef = $form;
$this->module = $module;
@@ -169,7 +169,7 @@
if(!is_array($this->formDef['tabs'][$tab])) $app->error("Tab does not exist or the tab is empty (TAB: $tab).");
$new_record = '';
$table_idx = $this->formDef['db_table_idx'];
- if(isset($record[$table_idx])) $new_record[$table_idx] = intval($record[$table_idx ]);
+ if(isset($record[$table_idx])) $new_record[$table_idx] = $app->functions->intval($record[$table_idx ]);
if(is_array($record)) {
foreach($this->formDef['tabs'][$tab]['fields'] as $key => $field) {
@@ -202,7 +202,7 @@
break;
case 'INTEGER':
- $new_record[$key] = intval($record[$key]);
+ $new_record[$key] = $app->functions->intval($record[$key]);
break;
case 'DOUBLE':
@@ -224,7 +224,7 @@
}
/**
- * Get the key => value array of a form filed from a datasource definitiom
+ * Get the key => value array of a form filled from a datasource definitiom
*
* @param field = array with field definition
* @param record = Dataset as array
@@ -247,7 +247,6 @@
$table_idx = $this->formDef['db_table_idx'];
$tmp_recordid = (isset($record[$table_idx]))?$record[$table_idx]:0;
- //$tmp_recordid = intval($this->primary_id);
$querystring = str_replace("{RECORDID}",$tmp_recordid,$querystring);
unset($tmp_recordid);
@@ -276,6 +275,17 @@
} else {
$this->errorMessage .= "Custom datasource class or function is empty<br />\r\n";
}
+ }
+
+ if(isset($field['filters']) && is_array($field['filters'])) {
+ $new_values = array();
+ foreach($values as $index => $value) {
+ $new_index = $this->filterField($index, $index, $field['filters'], 'SHOW');
+ $new_values[$new_index] = $this->filterField($index, (isset($values[$index]))?$values[$index]:'', $field['filters'], 'SHOW');
+ }
+ $values = $new_values;
+ unset($new_values);
+ unset($new_index);
}
return $values;
@@ -400,7 +410,7 @@
$selected = ($k == $val)?' SELECTED':'';
if(!empty($this->wordbook[$v]))
$v = $this->wordbook[$v];
- $out .= "<option value='$k'$selected>$v</option>\r\n";
+ $out .= "<option value='$k'$selected>".$this->lng($v)."</option>\r\n";
}
}
$new_record[$key] = $out;
@@ -630,7 +640,6 @@
if(isset($field['filters']) && is_array($field['filters'])) {
$record[$key] = $this->filterField($key, (isset($record[$key]))?$record[$key]:'', $field['filters'], 'SAVE');
}
-
//* Validate record value
if(isset($field['validators']) && is_array($field['validators'])) {
$this->validateField($key, (isset($record[$key]))?$record[$key]:'', $field['validators']);
@@ -678,7 +687,7 @@
}
break;
case 'INTEGER':
- $new_record[$key] = (isset($record[$key]))?$record[$key]:0;
+ $new_record[$key] = (isset($record[$key]))?$app->functions->intval($record[$key]):0;
//if($new_record[$key] != $record[$key]) $new_record[$key] = $field['default'];
//if($key == 'refresh') die($record[$key]);
break;
@@ -739,24 +748,16 @@
if($filter['event'] == $filter_event) {
switch ($filter['type']) {
case 'TOLOWER':
- $returnval = strtolower($field_value);
+ $returnval = strtolower($returnval);
break;
case 'TOUPPER':
- $returnval = strtoupper($field_value);
+ $returnval = strtoupper($returnval);
break;
case 'IDNTOASCII':
- if(function_exists('idn_to_ascii')) {
- $returnval = idn_to_ascii($field_value);
- } else {
- $returnval = $field_value;
- }
+ $returnval = $app->functions->idn_encode($returnval);
break;
case 'IDNTOUTF8':
- if(function_exists('idn_to_utf8')) {
- $returnval = idn_to_utf8($field_value);
- } else {
- $returnval = $field_value;
- }
+ $returnval = $app->functions->idn_decode($returnval);
break;
default:
$this->errorMessage .= "Unknown Filter: ".$filter['type'];
@@ -764,8 +765,7 @@
}
}
}
-
- return $returnval;
+ return $returnval;
}
/**
@@ -863,7 +863,7 @@
}
}
} else {
- $tmpval = intval($field_value);
+ $tmpval = $app->functions->intval($field_value);
if($tmpval === 0 and !empty($field_value)) {
$errmsg = $validator['errmsg'];
if(isset($this->wordbook[$errmsg])) {
@@ -976,7 +976,7 @@
}
/**
- * Create the SQL staement.
+ * Create SQL statement
*
* @param record = Datensatz als Array
* @param action = INSERT oder UPDATE
@@ -1170,7 +1170,7 @@
$app->uses('tform_tpl_generator');
$app->tform_tpl_generator->buildHTML($this->formDef,$tab['name']);
}
-
+ $app->tpl->setVar('readonly_tab', (isset($tab['readonly']) && $tab['readonly'] == true));
$app->tpl->setInclude('content_tpl',$tab["template"]);
$tab["active"] = 1;
$_SESSION["s"]["form"]["tab"] = $tab['name'];
--
Gitblit v1.9.1