From 2f0f2ae303b8d78f8c0b4c3891b6323320a53a94 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 24 Oct 2013 17:22:23 +0000 Subject: [PATCH] * All apps: new custom-field type IP-Address getting initially set with remote IP address, and allowing to set negativ length for text fields to make them readonly --- .../inc/class.customfields_widget.inc.php | 7 ++++++ etemplate/inc/class.etemplate_old.inc.php | 25 +++++++++++++------ etemplate/inc/class.historylog_widget.inc.php | 5 ++-- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/etemplate/inc/class.customfields_widget.inc.php b/etemplate/inc/class.customfields_widget.inc.php index bc4422e0ba..388bfdbb20 100644 --- a/etemplate/inc/class.customfields_widget.inc.php +++ b/etemplate/inc/class.customfields_widget.inc.php @@ -59,6 +59,7 @@ class customfields_widget 'url-email'=> 'EMail', 'url-phone'=> 'Phone number', 'htmlarea' => 'Formatted Text (HTML)', + 'client-ip'=> 'IP address', 'link-entry' => 'Select entry', // should be last type, as the individual apps get added behind ); @@ -339,6 +340,12 @@ class customfields_widget 'size' => implode(',',$options) )); break; + case 'client-ip': + if (empty($value[$this->prefix.$lname])) + { + $value[$this->prefix.$lname] = egw_session::getuser_ip(); + } + // fall through case 'text' : case 'textarea' : case '' : // not set diff --git a/etemplate/inc/class.etemplate_old.inc.php b/etemplate/inc/class.etemplate_old.inc.php index b1c1ff01b4..965839b864 100644 --- a/etemplate/inc/class.etemplate_old.inc.php +++ b/etemplate/inc/class.etemplate_old.inc.php @@ -5,7 +5,7 @@ * @link http://www.egroupware.org * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @author Ralf Becker -* @copyright 2002-11 by RalfBecker@outdoor-training.de +* @copyright 2002-13 by RalfBecker@outdoor-training.de * @package etemplate * @subpackage api * @version $Id$ @@ -365,7 +365,7 @@ class etemplate_old extends boetemplate * @param string $cname=null name-prefix, which need to be ignored, default self::$name_vars * @return boolean true if there are not ignored validation errors, false otherwise */ - function validation_errors($ignore_validation='',$cname=null) + static function validation_errors($ignore_validation='',$cname=null) { if (is_null($cname)) $cname = self::$name_vars; //echo "

uiself::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array(self::$validation_errors); @@ -1059,8 +1059,14 @@ class etemplate_old extends boetemplate } $form_name = self::form_name($cname,$name); - $value = $this->get_array($content,$name); - + if (!empty($name)) + { + $value = $this->get_array($content,$name); + } + else + { + $value =& $content; + } $options = ''; if ($readonly = $cell['readonly'] && $readonlys[$name] !== false || // allow to overwrite readonly settings of a cell @$readonlys[$name] && !is_array($readonlys[$name]) || $readonlys['__ALL__'] && (!is_string($name) || $readonlys[$name] !== false) || @@ -1279,8 +1285,6 @@ class etemplate_old extends boetemplate case 'passwd': case 'text': // size: [length][,maxLength[,preg[,html5type]]] case 'textbox': - $autocompletion_off=''; - if ($type == 'passwd') $autocompletion_off='autocomplete="off"'; $cell_opts = $c = self::csv_split($cell_options); // allows to enclose preg in quote to allow comma // fix preg, in case it contains a comma (html5type is only letters and always last option!) if (count($cell_opts) > 3 && ($cell_opts2 = explode(',',$cell_options)) && $cell_opts2[2][0] != '"') @@ -1300,9 +1304,14 @@ class etemplate_old extends boetemplate } else { - if ($cell_opts[0] < 0) $cell_opts[0] = abs($cell_opts[0]); + if ($cell_opts[0] < 0) + { + $cell_opts[0] = abs($cell_opts[0]); + $options .= ' readonly="readonly"'; + } $html .= html::input($form_name,$value,$type == 'passwd' ? 'password' : ($type == 'hidden' ? 'hidden' : $cell_opts[3]), - $options.html::formatOptions($cell_opts,'SIZE,MAXLENGTH').($cell['needed']?' required="required"':'').($autocompletion_off?' '.$autocompletion_off:'')); + $options.html::formatOptions($cell_opts,'SIZE,MAXLENGTH'). + ($cell['needed']?' required="required"':'').($type == 'passwd'?' autocomplete="off"':'')); if (!$readonly) { diff --git a/etemplate/inc/class.historylog_widget.inc.php b/etemplate/inc/class.historylog_widget.inc.php index 2e704df45d..b20781f26b 100644 --- a/etemplate/inc/class.historylog_widget.inc.php +++ b/etemplate/inc/class.historylog_widget.inc.php @@ -6,7 +6,7 @@ * @package etemplate * @link http://www.egroupware.org * @author RalfBecker-At-outdoor-training.de - * @copyright 2006-11 by RalfBecker-At-outdoor-training.de + * @copyright 2006-13 by RalfBecker-At-outdoor-training.de * @license GPL - GNU General Public License * @version $Id$ */ @@ -210,7 +210,8 @@ class historylog_widget } else { - self::$status_widgets['#'.$cf_name] = $cf_data['type'] != 'text' ? $cf_data['type'] : 'label'; + self::$status_widgets['#'.$cf_name] = !in_array($cf_data['type'], array('text', 'client-ip')) ? + $cf_data['type'] : 'label'; } } elseif($cf_data['values']['@'])