diff --git a/config/config.default.php b/config/config.default.php index ba343cf4..161b6626 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -110,6 +110,9 @@ return [ // Whether the DECT field should be enabled 'enable_dect' => true, + // Enables prename and lastname + 'enable_user_name' => false, + // Enables the planned arrival/leave date 'enable_planned_arrival' => true, diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index c71d5386..b708b38b 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -52,8 +52,10 @@ function admin_user() $html .= ' Last login

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

' . "\n"; - $html .= ' Name' . '' . "\n"; - $html .= ' Vorname' . '' . "\n"; + if (config('enable_user_name')) { + $html .= ' Name' . '' . "\n"; + $html .= ' Vorname' . '' . "\n"; + } $html .= ' Handy' . '' . "\n"; if (config('enable_dect')) { $html .= ' DECT' . '' . "\n"; diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index 3bc10fc3..280743e5 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -26,6 +26,7 @@ function guest_register() $authUser = auth()->user(); $tshirt_sizes = config('tshirt_sizes'); $enable_tshirt_size = config('enable_tshirt_size'); + $enable_user_name = config('enable_user_name'); $enable_dect = config('enable_dect'); $enable_planned_arrival = config('enable_planned_arrival'); $min_password_length = config('min_password_length'); @@ -151,10 +152,10 @@ function guest_register() } // Trivia - if ($request->has('lastname')) { + if ($enable_user_name && $request->has('lastname')) { $lastName = strip_request_item('lastname'); } - if ($request->has('prename')) { + if ($enable_user_name && $request->has('prename')) { $preName = strip_request_item('prename'); } if ($enable_dect && $request->has('dect')) { @@ -338,14 +339,14 @@ function guest_register() form_text('mobile', __('Mobile'), $mobile) ]), ]), - div('row', [ + $enable_user_name ? div('row', [ div('col-sm-6', [ form_text('prename', __('First name'), $preName) ]), div('col-sm-6', [ form_text('lastname', __('Last name'), $lastName) ]) - ]), + ]) : '', form_info(entry_required() . ' = ' . __('Entry required!')) ]) ]), diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php index f6853191..e398e3a8 100644 --- a/includes/pages/user_settings.php +++ b/includes/pages/user_settings.php @@ -70,13 +70,17 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) } // Trivia - $user_source->personalData->last_name = strip_request_item('lastname', $user_source->personalData->last_name); - $user_source->personalData->first_name = strip_request_item('prename', $user_source->personalData->first_name); - if (strlen(strip_request_item('dect')) <= 40) { - $user_source->contact->dect = strip_request_item('dect', $user_source->contact->dect); - } else { - $valid = false; - error(__('For dect numbers are only 40 digits allowed.')); + if(config('enable_user_name')) { + $user_source->personalData->last_name = strip_request_item('lastname', $user_source->personalData->last_name); + $user_source->personalData->first_name = strip_request_item('prename', $user_source->personalData->first_name); + } + if (config('enable_dect')) { + if (strlen(strip_request_item('dect')) <= 40) { + $user_source->contact->dect = strip_request_item('dect', $user_source->contact->dect); + } else { + $valid = false; + error(__('For dect numbers are only 40 digits allowed.')); + } } $user_source->contact->mobile = strip_request_item('mobile', $user_source->contact->mobile); diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 9f5264ef..f44f47ca 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -25,6 +25,7 @@ function User_settings_view( $tshirt_sizes ) { $personalData = $user_source->personalData; + $enable_user_name = config('enable_user_name'); $enable_dect = config('enable_dect'); $enable_planned_arrival = config('enable_planned_arrival'); @@ -40,8 +41,8 @@ function User_settings_view( '', __('Use up to 23 letters, numbers, connecting punctuations or spaces for your nickname.') ), - form_text('lastname', __('Last name'), $personalData->last_name), - form_text('prename', __('First name'), $personalData->first_name), + $enable_user_name ? form_text('lastname', __('Last name'), $personalData->last_name) : '', + $enable_user_name ? form_text('prename', __('First name'), $personalData->first_name) : '', $enable_planned_arrival ? form_date( 'planned_arrival_date', __('Planned date of arrival') . ' ' . entry_required(), @@ -253,28 +254,34 @@ function Users_view( 'actions' => '' . count($usersList) . '' ]; + $user_table_headers = [ + 'name' => Users_table_header_link('name', __('Nick'), $order_by) + ]; + if(config('enable_user_name')) { + $user_table_headers['first_name'] = Users_table_header_link('first_name', __('Prename'), $order_by); + $user_table_headers['last_name'] = Users_table_header_link('last_name', __('Name'), $order_by); + } + if(config('enable_dect')) { + $user_table_headers['dect'] = Users_table_header_link('dect', __('DECT'), $order_by); + } + $user_table_headers['arrived'] = Users_table_header_link('arrived', __('Arrived'), $order_by); + $user_table_headers['got_voucher'] = Users_table_header_link('got_voucher', __('Voucher'), $order_by); + $user_table_headers['freeloads'] = __('Freeloads'); + $user_table_headers['active'] = Users_table_header_link('active', __('Active'), $order_by); + $user_table_headers['force_active'] = Users_table_header_link('force_active', __('Forced'), $order_by); + $user_table_headers['got_shirt'] = Users_table_header_link('got_shirt', __('T-Shirt'), $order_by); + $user_table_headers['shirt_size'] = Users_table_header_link('shirt_size', __('Size'), $order_by); + $user_table_headers['arrival_date'] = Users_table_header_link('planned_arrival_date', __('Planned arrival'), $order_by); + $user_table_headers['departure_date'] = Users_table_header_link('planned_departure_date', __('Planned departure'), $order_by); + $user_table_headers['last_login_at'] = Users_table_header_link('last_login_at', __('Last login'), $order_by); + $user_table_headers['actions'] = ''; + return page_with_title(__('All users'), [ msg(), buttons([ button(page_link_to('register'), glyph('plus') . __('New user')) ]), - table([ - 'name' => Users_table_header_link('name', __('Nick'), $order_by), - 'first_name' => Users_table_header_link('first_name', __('Prename'), $order_by), - 'last_name' => Users_table_header_link('last_name', __('Name'), $order_by), - 'dect' => Users_table_header_link('dect', __('DECT'), $order_by), - 'arrived' => Users_table_header_link('arrived', __('Arrived'), $order_by), - 'got_voucher' => Users_table_header_link('got_voucher', __('Voucher'), $order_by), - 'freeloads' => __('Freeloads'), - 'active' => Users_table_header_link('active', __('Active'), $order_by), - 'force_active' => Users_table_header_link('force_active', __('Forced'), $order_by), - 'got_shirt' => Users_table_header_link('got_shirt', __('T-Shirt'), $order_by), - 'shirt_size' => Users_table_header_link('shirt_size', __('Size'), $order_by), - 'arrival_date' => Users_table_header_link('planned_arrival_date', __('Planned arrival'), $order_by), - 'departure_date' => Users_table_header_link('planned_departure_date', __('Planned departure'), $order_by), - 'last_login_at' => Users_table_header_link('last_login_at', __('Last login'), $order_by), - 'actions' => '' - ], $usersList) + table($user_table_headers, $usersList) ]); } @@ -609,7 +616,7 @@ function User_view( return page_with_title( ' ' . htmlspecialchars($user_source->name) - . ' ' . $user_name . '', + . (config('enable_user_name') ? ' ' . $user_name . '' : ''), [ msg(), div('row space-top', [