From 6022d792dc1b08eab0ee73140cb0296db588c29f Mon Sep 17 00:00:00 2001 From: Xu Date: Sun, 12 Nov 2023 18:07:40 +0100 Subject: [PATCH] add hints for required profile settings --- includes/sys_menu.php | 4 +++ includes/view/User_view.php | 62 +++++++++++++++++++++++++++++++-- resources/lang/de_DE/default.po | 24 +++++++++---- resources/lang/en_US/default.po | 20 +++++++++++ 4 files changed, 100 insertions(+), 10 deletions(-) diff --git a/includes/sys_menu.php b/includes/sys_menu.php index 9e5a0fbd..17c5f611 100644 --- a/includes/sys_menu.php +++ b/includes/sys_menu.php @@ -36,8 +36,12 @@ function header_render_hints() // Important hints: $hints_renderer->addHint(render_user_freeloader_hint(), true); $hints_renderer->addHint(render_user_arrived_hint(), true); + $hints_renderer->addHint(render_user_pronoun_hint(), true); + $hints_renderer->addHint(render_user_firstname_hint(), true); + $hints_renderer->addHint(render_user_lastname_hint(), true); $hints_renderer->addHint(render_user_tshirt_hint(), true); $hints_renderer->addHint(render_user_dect_hint(), true); + $hints_renderer->addHint(render_user_mobile_hint(), true); return $hints_renderer->render(); } diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 093f6e22..4d7f53c9 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -957,7 +957,7 @@ function render_user_tshirt_hint() && config('required_user_fields')['tshirt_size'] && !auth()->user()->personalData->shirt_size ) { - $text = __('You need to specify a tshirt size in your settings!'); + $text = __('tshirt.required.hint'); return render_profile_link($text); } @@ -970,8 +970,64 @@ function render_user_tshirt_hint() function render_user_dect_hint() { $user = auth()->user(); - if ($user->state->arrived && config('enable_dect') && !$user->contact->dect) { - $text = __('You need to specify a DECT phone number in your settings! If you don\'t have a DECT phone, just enter \'-\'.'); + if ((config('required_user_fields')['dect'] || $user->state->arrived) && config('enable_dect') && !$user->contact->dect) { + $text = __('dect.required.hint'); + return render_profile_link($text); + } + + return null; +} + +/** + * @return string|null + */ +function render_user_pronoun_hint() +{ + $user = auth()->user(); + if (config('required_user_fields')['pronoun'] && config('enable_pronoun') && !$user->personalData->pronoun) { + $text = __('pronoun.required.hint'); + return render_profile_link($text); + } + + return null; +} + +/** + * @return string|null + */ +function render_user_firstname_hint() +{ + $user = auth()->user(); + if (config('required_user_fields')['firstname'] && config('enable_user_name') && !$user->personalData->first_name) { + $text = __('firstname.required.hint'); + return render_profile_link($text); + } + + return null; +} + +/** + * @return string|null + */ +function render_user_lastname_hint() +{ + $user = auth()->user(); + if (config('required_user_fields')['lastname'] && config('enable_user_name') && !$user->personalData->last_name) { + $text = __('lastname.required.hint'); + return render_profile_link($text); + } + + return null; +} + +/** + * @return string|null + */ +function render_user_mobile_hint() +{ + $user = auth()->user(); + if (config('required_user_fields')['mobile'] && !$user->contact->mobile) { + $text = __('mobile.required.hint'); return render_profile_link($text); } diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index 5aff6ded..4ce71229 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -1403,15 +1403,25 @@ msgstr "" "Du hast mindestens %s Schichten geschwänzt. Schicht-Registrierung ist " "gesperrt. Bitte gehe zum Himmelsschreibtisch um wieder entsperrt zu werden." -msgid "You need to specify a tshirt size in your settings!" -msgstr "Bitte eine T-Shirt-Größe auswählen" +msgid "tshirt.required.hint" +msgstr "Bitte gib eine T-Shirt-Größe in deinen Einstellungen an." -msgid "" -"You need to specify a DECT phone number in your settings! If you don't have " -"a DECT phone, just enter '-'." +msgid "dect.required.hint" msgstr "" -"Bitte eine DECT-Telefonnummer in den Einstellungen eingeben. Wenn du noch " -"keine Nummer hast, bitte einfach \"-\" angeben." +"Bitte gib eine DECT-Telefonnummer in deinen Einstellungen an. Wenn du " +"keine Nummer hast, trage einfach '-' ein." + +msgid "pronoun.required.hint" +msgstr "Bitte gib ein Pronomen in deinen Einstellungen an." + +msgid "firstname.required.hint" +msgstr "Bitte gib einen Vornamen in deinen Einstellungen an." + +msgid "lastname.required.hint" +msgstr "Bitte gib einen Nachnamen in deinen Einstellungen an." + +msgid "mobile.required.hint" +msgstr "Bitte gib eine Handynummer in deinen Einstellungen an." msgid "" "Here you can change the user entry. Under the item 'Arrived' the angel is marked as present, " diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po index 50220dc4..eb3e3739 100644 --- a/resources/lang/en_US/default.po +++ b/resources/lang/en_US/default.po @@ -590,3 +590,23 @@ msgstr "What do you want to do?" msgid "registration.register" msgstr "Register" + +msgid "tshirt.required.hint" +msgstr "Please specify a tshirt size in your settings!" + +msgid "dect.required.hint" +msgstr "" +"Please specify a DECT phone number in your settings! " +"If you don't have a DECT phone, just enter '-'." + +msgid "pronoun.required.hint" +msgstr "Please enter a pronoun in your settings!" + +msgid "firstname.required.hint" +msgstr "Please enter a firstname in your settings!" + +msgid "lastname.required.hint" +msgstr "Please enter a lastname in your settings!" + +msgid "mobile.required.hint" +msgstr "Please enter a mobile number in your settings!"