diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php index 595c0c08..2b4aacd1 100644 --- a/includes/pages/admin_active.php +++ b/includes/pages/admin_active.php @@ -226,15 +226,7 @@ function admin_active() $shirtSize = $usr->personalData->shirt_size; $userData = []; $userData['no'] = count($matched_users) + 1; - $userData['nick'] = User_Nick_render($usr) . User_Pronoun_render($usr); - if ($usr->state->user_info) { - $userData['nick'] .= - ' can('user.info.show') - ? (' data-bs-toggle="tooltip" title="' . htmlspecialchars($usr->state->user_info) . '"') - : '') - . '>'; - } + $userData['nick'] = User_Nick_render($usr) . User_Pronoun_render($usr) . user_info_icon($usr); if ($goodie_tshirt) { $userData['shirt_size'] = (isset($tshirt_sizes[$shirtSize]) ? $tshirt_sizes[$shirtSize] : ''); } diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php index fa590980..51a78d78 100644 --- a/includes/pages/admin_arrive.php +++ b/includes/pages/admin_arrive.php @@ -100,9 +100,7 @@ function admin_arrive() $usr->name = User_Nick_render($usr) . User_Pronoun_render($usr) - . ($usr->state->user_info - ? ' ' - : ''); + . user_info_icon($usr); $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 b40d9782..d5b5db66 100644 --- a/includes/pages/admin_free.php +++ b/includes/pages/admin_free.php @@ -99,9 +99,7 @@ function admin_free() $free_users_table[] = [ 'name' => User_Nick_render($usr) . User_Pronoun_render($usr) - . ($usr->state->user_info - ? ' ' - : ''), + . user_info_icon($usr), '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/sys_template.php b/includes/sys_template.php index f269baef..362824ad 100644 --- a/includes/sys_template.php +++ b/includes/sys_template.php @@ -1,5 +1,6 @@ ' . join('', $buttons) . ''; } + +function user_info_icon(User $user): string +{ + if (!auth()->can('admin_arrive') || !$user->state->user_info) { + return ''; + } + $infoIcon = ' can('user.info.show')) { + $infoIcon .= 'data-bs-toggle="tooltip" title="' . htmlspecialchars($user->state->user_info) . '"'; + } + $infoIcon .= '>'; + return $infoIcon; +} diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 8d828e32..c6422187 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -92,9 +92,7 @@ function Users_view( $u = []; $u['name'] = User_Nick_render($user) . User_Pronoun_render($user) - . ($user->state->user_info - ? ' ' - : ''); + . user_info_icon($user); $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)); @@ -542,7 +540,6 @@ 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( @@ -590,17 +587,7 @@ function User_view( ) . htmlspecialchars($user_source->name) . (config('enable_user_name') ? ' ' . $user_name . '' : '') - . ( - (($user_info_show || auth()->can('admin_arrive')) && $user_source->state->user_info) - ? ( - ' ' - ) - : '' - ), + . user_info_icon($user_source), [ msg(), div('row', [