From 48ea35562e8c808dc8175126f4b31629a7a9d59a Mon Sep 17 00:00:00 2001
From: xuwhite <73076134+xuwhite@users.noreply.github.com>
Date: Thu, 14 Dec 2023 22:15:17 +0100
Subject: [PATCH] show user-info icon with admin_arrive permission
---
includes/pages/admin_arrive.php | 6 +++++-
includes/pages/admin_free.php | 6 +++++-
includes/pages/user_shifts.php | 2 +-
includes/view/Locations_view.php | 2 +-
includes/view/User_view.php | 24 +++++++++++++++++-------
resources/lang/de_DE/default.po | 14 ++++++++++----
resources/lang/en_US/default.po | 7 ++++++-
7 files changed, 45 insertions(+), 16 deletions(-)
diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php
index b56726a6..2e4bce1a 100644
--- a/includes/pages/admin_arrive.php
+++ b/includes/pages/admin_arrive.php
@@ -98,7 +98,11 @@ function admin_arrive()
}
}
- $usr->name = User_Nick_render($usr) . User_Pronoun_render($usr);
+ $usr->name = User_Nick_render($usr)
+ . User_Pronoun_render($usr)
+ . ($usr->state->user_info
+ ? ' '
+ : '');
$plannedDepartureDate = $usr->personalData->planned_departure_date;
$arrivalDate = $usr->state->arrival_date;
$plannedArrivalDate = $usr->personalData->planned_arrival_date;
diff --git a/includes/pages/admin_free.php b/includes/pages/admin_free.php
index 72769a92..19f13133 100644
--- a/includes/pages/admin_free.php
+++ b/includes/pages/admin_free.php
@@ -97,7 +97,11 @@ function admin_free()
$email = $usr->contact->email ?: $usr->email;
$free_users_table[] = [
- 'name' => User_Nick_render($usr) . User_Pronoun_render($usr),
+ 'name' => User_Nick_render($usr)
+ . User_Pronoun_render($usr)
+ . ($usr->state->user_info
+ ? ' '
+ : ''),
'shift_state' => User_shift_state_render($usr),
'last_shift' => User_last_shift_render($usr),
'dect' => sprintf('%1$s', htmlspecialchars((string) $usr->contact->dect)),
diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php
index c5a01bce..3b9d3123 100644
--- a/includes/pages/user_shifts.php
+++ b/includes/pages/user_shifts.php
@@ -282,7 +282,7 @@ function view_user_shifts()
$end_time = $shiftsFilter->getEnd()->format('H:i');
if (config('signup_requires_arrival') && !$user->state->arrived) {
- info(render_user_arrived_hint());
+ info(render_user_arrived_hint((bool) $user->state->user_info));
}
$formattedDays = collect($days)->map(function ($value) {
diff --git a/includes/view/Locations_view.php b/includes/view/Locations_view.php
index ef402d03..2461c5a8 100644
--- a/includes/view/Locations_view.php
+++ b/includes/view/Locations_view.php
@@ -17,7 +17,7 @@ function location_view(Location $location, ShiftsFilterRenderer $shiftsFilterRen
$assignNotice = '';
if (config('signup_requires_arrival') && !$user->state->arrived) {
- $assignNotice = info(render_user_arrived_hint(), true);
+ $assignNotice = info(render_user_arrived_hint((bool) $user->state->user_info), true);
}
$description = '';
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index bab365f6..ea8f4c6d 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -92,7 +92,11 @@ function Users_view(
$usersList = [];
foreach ($users as $user) {
$u = [];
- $u['name'] = User_Nick_render($user) . User_Pronoun_render($user);
+ $u['name'] = User_Nick_render($user)
+ . User_Pronoun_render($user)
+ . ($user->state->user_info
+ ? ' '
+ : '');
$u['first_name'] = htmlspecialchars((string) $user->personalData->first_name);
$u['last_name'] = htmlspecialchars((string) $user->personalData->last_name);
$u['dect'] = sprintf('%1$s', htmlspecialchars((string) $user->contact->dect));
@@ -519,6 +523,7 @@ function User_view(
$nightShiftsConfig = config('night_shifts');
$user_name = htmlspecialchars((string) $user_source->personalData->first_name) . ' '
. htmlspecialchars((string) $user_source->personalData->last_name);
+ $user_info_show = auth()->can('user.info.show');
$myshifts_table = '';
if ($its_me || $admin_user_privilege || $tshirt_admin) {
$my_shifts = User_view_myshifts(
@@ -564,10 +569,12 @@ function User_view(
. htmlspecialchars($user_source->name)
. (config('enable_user_name') ? ' ' . $user_name . '' : '')
. (
- (auth()->can('user.info.show') && $user_source->state->user_info)
+ (($user_info_show || auth()->can('admin_arrive')) && $user_source->state->user_info)
? (
- ' '
)
: ''
@@ -952,17 +959,20 @@ function render_user_freeloader_hint()
}
/**
- * Hinweis für Engel, die noch nicht angekommen sind
+ * hint for angels, which are not arrived yet
*
* @return string|null
*/
-function render_user_arrived_hint()
+function render_user_arrived_hint(bool $is_user_shifts = false)
{
+ $user_info = auth()->user()->state->user_info;
if (config('signup_requires_arrival') && !auth()->user()->state->arrived) {
/** @var Carbon $buildup */
$buildup = config('buildup_start');
if (!empty($buildup) && $buildup->lessThan(new Carbon())) {
- return __('You are not marked as arrived. Please go to heaven\'s desk, get your angel badge and/or tell them that you arrived already.');
+ return !$user_info
+ ? __('You are not marked as arrived. Please go to heaven, get your angel badge and/or tell them that you arrived already.')
+ : ($is_user_shifts ? __('user_info.not_arrived_hint') : null);
}
}
diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po
index cb9b5f5e..8168951a 100644
--- a/resources/lang/de_DE/default.po
+++ b/resources/lang/de_DE/default.po
@@ -1267,11 +1267,11 @@ msgid "Rights"
msgstr "Berechtigungen"
msgid ""
-"You are not marked as arrived. Please go to heaven's desk, get your angel "
+"You are not marked as arrived. Please go to heaven, get your angel "
"badge and/or tell them that you arrived already."
msgstr ""
-"Du bist nicht als angekommen markiert. Bitte gehe zur Himmelsverwaltung, "
-"hole Dein Badge ab und/oder erkläre ihnen, dass Du bereits angekommen bist."
+"Du bist nicht als angekommen markiert. Geh bitte zum Himmel, "
+"hole Dein Badge ab und/oder melde dich als angekommen."
msgid ""
"Please enter your planned date of departure on your settings page to give us "
@@ -1995,7 +1995,13 @@ msgid "user.info"
msgstr "Benutzer Info"
msgid "user.info.hint"
-msgstr "Wird auf der Benutzer Seite für Schichtkoordinatoren und Admins angezeigt."
+msgstr ""
+"Wird auf der Benutzer Seite für Schichtkoordinatoren und Admins angezeigt. "
+"Wenn ein Engel nicht als angekommen markiert ist, "
+"entfernt eine Benutzer Info die nicht-angekommen Nachricht im Systemmenü des Engels."
+
+msgid "user_info.not_arrived_hint"
+msgstr "Wenn du dich für Schichten eintragen willst, komm gerne im Himmel vorbei."
msgid "design.title"
msgstr "Design"
diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po
index 6d9a5934..d2d4763d 100644
--- a/resources/lang/en_US/default.po
+++ b/resources/lang/en_US/default.po
@@ -733,7 +733,12 @@ msgid "user.info"
msgstr "User info"
msgid "user.info.hint"
-msgstr "Is displayed for shift coordinators and admins in the user view."
+msgstr ""
+"Is displayed for shift coordinators and admins in the user view. "
+"If an angel is not marked as arrived a user-info removes the not-arrived notification in the angels sysmenu."
+
+msgid "user_info.not_arrived_hint"
+msgstr "If you want to sign up for shifts, feel free to drop by heaven."
msgid "email.greeting"
msgstr "Hi %s,"