From 5cdf3889f95e8158128c0993a3b157fed43eb175 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 2 Dec 2020 14:43:11 +0100 Subject: [PATCH] Add max length for user settings --- includes/model/User_model.php | 2 +- includes/pages/admin_user.php | 12 ++++++------ includes/pages/guest_login.php | 17 +++++++++-------- includes/sys_form.php | 6 ++++-- includes/view/User_view.php | 14 +++++++++----- resources/lang/de_DE/default.po | 4 ++-- 6 files changed, 31 insertions(+), 24 deletions(-) diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 18febf73..f22d0505 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -112,7 +112,7 @@ function User_validate_Nick($nick) { $nick = trim($nick); - if (strlen($nick) == 0 || strlen($nick) > 23) { + if (strlen($nick) == 0 || strlen($nick) > 24) { return new ValidationResult(false, $nick); } if (preg_match('/([^\p{L}\p{N}\-_. ]+)/ui', $nick)) { diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index 758ed8d9..e5ba9a2b 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -48,20 +48,20 @@ function admin_user() $html .= '' . "\n"; $html .= '' . "\n"; $html .= '' . "\n"; - $html .= ' ' . "\n"; + $html .= ' ' . "\n"; $html .= ' ' . "\n"; if (config('enable_user_name')) { - $html .= ' ' . "\n"; - $html .= ' ' . "\n"; + $html .= ' ' . "\n"; + $html .= ' ' . "\n"; } - $html .= ' ' . "\n"; + $html .= ' ' . "\n"; if (config('enable_dect')) { - $html .= ' ' . "\n"; + $html .= ' ' . "\n"; } if ($user_source->settings->email_human) { - $html .= " ' . "\n"; + $html .= " ' . "\n"; } $html .= '
Nick' . '
Nick' . '
Last login

' . ($user_source->last_login_at ? $user_source->last_login_at->format('Y-m-d H:i') : '-') . '

Name' . '
Vorname' . '
Name' . '
Vorname' . '
Handy' . '
Handy' . '
DECT' . '
DECT' . '
email" . '
email" . '
Size' . html_select_key( diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index f5c8e3a0..b4a8d0d4 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -78,7 +78,7 @@ function guest_register() if (!$nickValidation->isValid()) { $valid = false; - $msg .= error(sprintf(__('Please enter a valid nick.') . ' ' . __('Use up to 23 letters, numbers, connecting punctuations or spaces for your nickname.'), + $msg .= error(sprintf(__('Please enter a valid nick.') . ' ' . __('Use up to 24 letters, numbers, connecting punctuations or spaces for your nickname.'), $nick), true); } if (User::whereName($nick)->count() > 0) { @@ -323,11 +323,11 @@ function guest_register() __('Nick') . ' ' . entry_required(), $nick, false, - 23, + 24, 'nickname' ), form_info('', - __('Use up to 23 letters, numbers, connecting punctuations or spaces for your nickname.')) + __('Use up to 24 letters, numbers, connecting punctuations or spaces for your nickname.')) ]), div('col-sm-8', [ form_email( @@ -335,7 +335,8 @@ function guest_register() __('E-Mail') . ' ' . entry_required(), $email, false, - 'email' + 'email', + 254 ), form_checkbox( 'email_shiftinfo', @@ -395,18 +396,18 @@ function guest_register() form_text('dect', __('DECT'), $dect, false, 40, 'tel-local') ]) : '', div($enable_dect ? 'col-sm-4' : 'col-sm-12', [ - form_text('mobile', __('Mobile'), $mobile, false, null, 'tel-national') + form_text('mobile', __('Mobile'), $mobile, false, 40, 'tel-national') ]), $enable_pronoun ? div('col-sm-4', [ - form_text('pronoun', __('Pronoun'), $pronoun) + form_text('pronoun', __('Pronoun'), $pronoun, false, 15) ]) : '', ]), $enable_user_name ? div('row', [ div('col-sm-6', [ - form_text('prename', __('First name'), $preName, false, null, 'given-name') + form_text('prename', __('First name'), $preName, false, 64, 'given-name') ]), div('col-sm-6', [ - form_text('lastname', __('Last name'), $lastName, false, null, 'family-name') + form_text('lastname', __('Last name'), $lastName, false, 64, 'family-name') ]) ]) : '', form_info(entry_required() . ' = ' . __('Entry required!')) diff --git a/includes/sys_form.php b/includes/sys_form.php index ffc309cf..b4b7d3b1 100644 --- a/includes/sys_form.php +++ b/includes/sys_form.php @@ -276,17 +276,19 @@ function form_text_placeholder($name, $placeholder, $value, $disabled = false) * @param string $value * @param bool $disabled * @param string|null $autocomplete + * @param int|null $maxlength * * @return string */ -function form_email($name, $label, $value, $disabled = false, $autocomplete = null) +function form_email($name, $label, $value, $disabled = false, $autocomplete = null, $maxlength = null) { $disabled = $disabled ? ' disabled="disabled"' : ''; $autocomplete = $autocomplete ? ' autocomplete="' . $autocomplete . '"' : ''; + $maxlength = $maxlength ? ' maxlength=' . (int)$maxlength : ''; return form_element( $label, '', + . htmlspecialchars($value) . '" ' . $disabled . $autocomplete . $maxlength . '/>', 'form_' . $name ); } diff --git a/includes/view/User_view.php b/includes/view/User_view.php index bbd1adae..82aa8e0f 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -58,8 +58,12 @@ function User_settings_view( ? form_text('pronoun', __('Pronoun'), $personalData->pronoun, false, 15) . form_info('', __('Will be shown on your profile page and in angel lists.')) : '', - $enable_user_name ? form_text('lastname', __('Last name'), $personalData->last_name) : '', - $enable_user_name ? form_text('prename', __('First name'), $personalData->first_name) : '', + $enable_user_name + ? form_text('lastname', __('Last name'), $personalData->last_name, false, 64) + : '', + $enable_user_name + ? form_text('prename', __('First name'), $personalData->first_name, false, 64) + : '', $enable_planned_arrival ? form_date( 'planned_arrival_date', __('Planned date of arrival') . ' ' . entry_required(), @@ -78,9 +82,9 @@ function User_settings_view( $buildup_start_date, $teardown_end_date ) : '', - $enable_dect ? form_text('dect', __('DECT'), $user_source->contact->dect) : '', - form_text('mobile', __('Mobile'), $user_source->contact->mobile), - form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source->email), + $enable_dect ? form_text('dect', __('DECT'), $user_source->contact->dect, false, 40) : '', + form_text('mobile', __('Mobile'), $user_source->contact->mobile, false, 40), + form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source->email, false, 254), form_checkbox( 'email_shiftinfo', __( diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index ec3e3f66..d6dd2136 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -1547,10 +1547,10 @@ msgstr "Gib bitte einen erlaubten Nick an." #: includes/pages/guest_login.php:77 includes/pages/guest_login.php:277 #: includes/view/User_view.php:42 msgid "" -"Use up to 23 letters, numbers, connecting punctuations or spaces for your " +"Use up to 24 letters, numbers, connecting punctuations or spaces for your " "nickname." msgstr "" -"Verwende bis zu 23 Buchstaben, Zahlen, verbindende Schriftzeichen (.-_) oder " +"Verwende bis zu 24 Buchstaben, Zahlen, verbindende Schriftzeichen (.-_) oder " "Leerzeichen für deinen Nick." #: includes/pages/guest_login.php:82