* 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

This commit is contained in:
Ralf Becker 2013-10-24 17:22:23 +00:00
parent 9bdaf0f338
commit 2f0f2ae303
3 changed files with 27 additions and 10 deletions

View File

@ -59,6 +59,7 @@ class customfields_widget
'url-email'=> 'EMail', 'url-email'=> 'EMail',
'url-phone'=> 'Phone number', 'url-phone'=> 'Phone number',
'htmlarea' => 'Formatted Text (HTML)', 'htmlarea' => 'Formatted Text (HTML)',
'client-ip'=> 'IP address',
'link-entry' => 'Select entry', // should be last type, as the individual apps get added behind '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) 'size' => implode(',',$options)
)); ));
break; break;
case 'client-ip':
if (empty($value[$this->prefix.$lname]))
{
$value[$this->prefix.$lname] = egw_session::getuser_ip();
}
// fall through
case 'text' : case 'text' :
case 'textarea' : case 'textarea' :
case '' : // not set case '' : // not set

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @author Ralf Becker <RalfBecker@outdoor-training.de> * @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright 2002-11 by RalfBecker@outdoor-training.de * @copyright 2002-13 by RalfBecker@outdoor-training.de
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @version $Id$ * @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 * @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 * @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; if (is_null($cname)) $cname = self::$name_vars;
//echo "<p>uiself::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array(self::$validation_errors); //echo "<p>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); $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 = ''; $options = '';
if ($readonly = $cell['readonly'] && $readonlys[$name] !== false || // allow to overwrite readonly settings of a cell 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) || @$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 'passwd':
case 'text': // size: [length][,maxLength[,preg[,html5type]]] case 'text': // size: [length][,maxLength[,preg[,html5type]]]
case 'textbox': 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 $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!) // 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] != '"') if (count($cell_opts) > 3 && ($cell_opts2 = explode(',',$cell_options)) && $cell_opts2[2][0] != '"')
@ -1300,9 +1304,14 @@ class etemplate_old extends boetemplate
} }
else 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]), $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) if (!$readonly)
{ {

View File

@ -6,7 +6,7 @@
* @package etemplate * @package etemplate
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author RalfBecker-At-outdoor-training.de * @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 * @license GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
@ -210,7 +210,8 @@ class historylog_widget
} }
else 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']['@']) elseif($cf_data['values']['@'])