NEW Add extrafield type "IP" to store IP addresses

This commit is contained in:
Laurent Destailleur 2022-07-09 12:56:38 +02:00
parent 71838216f5
commit 4fdcb43d9c

View File

@ -105,6 +105,7 @@ class ExtraFields
'phone'=>'ExtrafieldPhone',
'mail'=>'ExtrafieldMail',
'url'=>'ExtrafieldUrl',
'ip'=>'ExtrafieldIP',
'password' => 'ExtrafieldPassword',
'select' => 'ExtrafieldSelect',
'sellist' => 'ExtrafieldSelectList',
@ -243,7 +244,7 @@ class ExtraFields
} elseif ($type == 'phone') {
$typedb = 'varchar';
$lengthdb = '20';
} elseif ($type == 'mail') {
} elseif ($type == 'mail' || $type == 'ip') {
$typedb = 'varchar';
$lengthdb = '128';
} elseif ($type == 'url') {
@ -572,7 +573,7 @@ class ExtraFields
} elseif ($type == 'phone') {
$typedb = 'varchar';
$lengthdb = '20';
} elseif ($type == 'mail') {
} elseif ($type == 'mail' || $type == 'ip') {
$typedb = 'varchar';
$lengthdb = '128';
} elseif ($type == 'url') {
@ -1034,7 +1035,7 @@ class ExtraFields
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').'>';
} elseif (preg_match('/varchar/', $type)) {
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').'>';
} elseif (in_array($type, array('mail', 'phone', 'url'))) {
} elseif (in_array($type, array('mail', 'ip', 'phone', 'url'))) {
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>';
} elseif ($type == 'text') {
if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field
@ -1594,6 +1595,8 @@ class ExtraFields
$value = '<input type="checkbox" '.$checked.' '.($moreparam ? $moreparam : '').' readonly disabled>';
} elseif ($type == 'mail') {
$value = dol_print_email($value, 0, 0, 0, 64, 1, 1);
} elseif ($type == 'ip') {
$value = dol_print_ip($value, 0);
} elseif ($type == 'url') {
$value = dol_print_url($value, '_blank', 32, 1);
} elseif ($type == 'phone') {