From d89fe01ddd80824582bac64c747f8df88ed08359 Mon Sep 17 00:00:00 2001 From: Xu Date: Thu, 7 Dec 2023 15:47:49 +0100 Subject: [PATCH] shirt edit in edit user requires bureaucrat --- includes/pages/admin_user.php | 44 ++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index 652d4ff5..4f304479 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -28,6 +28,7 @@ function admin_user() $goodie_enabled = $goodie !== GoodieType::None; $goodie_tshirt = $goodie === GoodieType::Tshirt; $user_info_edit = auth()->can('user.info.edit'); + $user_edit_shirt = auth()->can('user.edit.shirt'); if (!$request->has('id')) { throw_redirect(users_link()); @@ -42,7 +43,7 @@ function admin_user() } $html .= __('Here you can change the user entry. Under the item \'Arrived\' the angel is marked as present, a yes at Active means that the angel was active.'); - if ($goodie_enabled) { + if ($goodie_enabled && $user_edit_shirt) { if ($goodie_tshirt) { $html .= ' ' . __('If the angel is active, it can claim a T-shirt. If T-shirt is set to \'Yes\', the angel already got their T-shirt.'); } else { @@ -85,7 +86,7 @@ function admin_user() . '' . '' . "\n"; } - if ($goodie_tshirt) { + if ($goodie_tshirt && $user_edit_shirt) { $html .= ' ' . __('user.shirt_size') . '' . html_select_key( 'size', @@ -118,16 +119,18 @@ function admin_user() // Arrived? $html .= ' ' . __('user.arrived') . '' . "\n"; - if ($user_source->state->arrived) { - $html .= __('Yes'); - } else { - $html .= __('No'); - } + $html .= ($user_source->state->arrived ? __('Yes') : __('No')); $html .= '' . "\n"; // Active? - $html .= ' ' . __('user.active') . '' . "\n"; - $html .= html_options('eAktiv', $options, $user_source->state->active) . '' . "\n"; + if ($user_edit_shirt) { + $html .= ' ' . __('user.active') . '' . "\n"; + $html .= html_options('eAktiv', $options, $user_source->state->active) . '' . "\n"; + } else { + $html .= ' ' . __('user.active') . '' . "\n"; + $html .= ($user_source->state->active ? __('Yes') : __('No')); + $html .= '' . "\n"; + } // Forced active? if (auth()->can('admin_active')) { @@ -135,7 +138,7 @@ function admin_user() $html .= html_options('force_active', $options, $user_source->state->force_active) . '' . "\n"; } - if ($goodie_enabled) { + if ($goodie_enabled && $user_edit_shirt) { // T-Shirt bekommen? if ($goodie_tshirt) { $html .= ' ' . __('T-shirt') . '' . "\n"; @@ -273,11 +276,8 @@ function admin_user() break; case 'save': - $force_active = $user->state->force_active; $user_source = User::find($user_id); - if (auth()->can('admin_active')) { - $force_active = $request->input('force_active'); - } + if ($user_source->settings->email_human) { $user_source->email = $request->postData('eemail'); } @@ -294,24 +294,30 @@ function admin_user() $user_source->personalData->first_name = $request->postData('eVorname'); $user_source->personalData->last_name = $request->postData('eName'); } - if ($goodie_tshirt) { + if ($goodie_tshirt && $user_edit_shirt) { $user_source->personalData->shirt_size = $request->postData('eSize'); } $user_source->personalData->save(); $user_source->contact->mobile = $request->postData('eHandy'); - $user_source->contact->dect = $request->postData('eDECT'); + if (config('enable_dect')) { + $user_source->contact->dect = $request->postData('eDECT'); + } $user_source->contact->save(); - if ($goodie_enabled) { + if ($goodie_enabled && $user_edit_shirt) { $user_source->state->got_shirt = $request->postData('eTshirt'); } if ($user_info_edit) { $user_source->state->user_info = $request->postData('userInfo'); } - $user_source->state->active = $request->postData('eAktiv'); - $user_source->state->force_active = $force_active; + if ($user_edit_shirt) { + $user_source->state->active = $request->postData('eAktiv'); + } + if (auth()->can('admin_active')) { + $user_source->state->force_active = $request->input('force_active'); + } $user_source->state->save(); engelsystem_log(