From 665e444e881ec2ca4378b346d45dbc488ac89a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Tue, 23 Apr 2019 12:42:01 +0200 Subject: [PATCH 1/2] Support disabling the DECT field It's a really chaos-event-specific feature and is confusing for many people on non-chaos events. --- config/config.default.php | 3 +++ includes/pages/admin_user.php | 4 +++- includes/pages/guest_login.php | 9 +++++---- includes/view/User_view.php | 5 +++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index 86320a4a..1830500e 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -99,6 +99,9 @@ return [ // The minimum length for passwords 'min_password_length' => 8, + // Whether the DECT field should be enabled + 'enable_dect' => true, + // Enables the T-Shirt configuration on signup and profile 'enable_tshirt_size' => true, diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index d42c3b39..773238ce 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -55,7 +55,9 @@ function admin_user() $html .= ' Name' . '' . "\n"; $html .= ' Vorname' . '' . "\n"; $html .= ' Handy' . '' . "\n"; - $html .= ' DECT' . '' . "\n"; + if (config('enable_dect')) { + $html .= ' DECT' . '' . "\n"; + } if ($user_source->settings->email_human) { $html .= " email" . '' . "\n"; } diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index c636a36c..2f206bcc 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -42,6 +42,7 @@ function guest_register() $authUser = auth()->user(); $tshirt_sizes = config('tshirt_sizes'); $enable_tshirt_size = config('enable_tshirt_size'); + $enable_dect = config('enable_dect'); $min_password_length = config('min_password_length'); $config = config(); $request = request(); @@ -167,7 +168,7 @@ function guest_register() if ($request->has('prename')) { $preName = strip_request_item('prename'); } - if ($request->has('dect')) { + if ($enable_dect && $request->has('dect')) { if (strlen(strip_request_item('dect')) <= 40) { $dect = strip_request_item('dect'); } else { @@ -339,10 +340,10 @@ function guest_register() ]), div('col-md-6', [ div('row', [ - div('col-sm-4', [ + $enable_dect ? div('col-sm-4', [ form_text('dect', __('DECT'), $dect) - ]), - div('col-sm-4', [ + ]) : '', + div($enable_dect ? 'col-sm-4' : 'col-sm-12', [ form_text('mobile', __('Mobile'), $mobile) ]), ]), diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 4768f4ac..cc2c3153 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_dect = config('enable_dect'); return page_with_title(settings_title(), [ msg(), div('row', [ @@ -49,7 +50,7 @@ function User_settings_view( $buildup_start_date, $teardown_end_date ), - form_text('dect', __('DECT'), $user_source->contact->dect), + $enable_dect ? form_text('dect', __('DECT'), $user_source->contact->dect) : '', form_text('mobile', __('Mobile'), $user_source->contact->mobile), form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source->email), form_checkbox( @@ -953,7 +954,7 @@ function render_user_tshirt_hint() function render_user_dect_hint() { $user = auth()->user(); - if ($user->state->arrived && !$user->contact->dect) { + 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 \'-\'.'); return render_profile_link($text, null, 'alert-link'); } From 79b30fa3a819f99c9611d3cbed851f73fe6cfe6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Tue, 23 Apr 2019 12:23:35 +0200 Subject: [PATCH 2/2] Support disabling the planned arrival We also use Engelsystem for single-day events, and the planned arrival/departure feature doesn't make sense for us. --- config/config.default.php | 3 +++ includes/pages/guest_login.php | 9 +++++---- includes/view/User_view.php | 14 ++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index 1830500e..66590ee4 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -102,6 +102,9 @@ return [ // Whether the DECT field should be enabled 'enable_dect' => true, + // Enables the planned arrival/leave date + 'enable_planned_arrival' => true, + // Enables the T-Shirt configuration on signup and profile 'enable_tshirt_size' => true, diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index 2f206bcc..5a760319 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -43,6 +43,7 @@ function guest_register() $tshirt_sizes = config('tshirt_sizes'); $enable_tshirt_size = config('enable_tshirt_size'); $enable_dect = config('enable_dect'); + $enable_planned_arrival = config('enable_planned_arrival'); $min_password_length = config('min_password_length'); $config = config(); $request = request(); @@ -141,7 +142,7 @@ function guest_register() ), true); } - if ($request->has('planned_arrival_date')) { + if ($request->has('planned_arrival_date') && $enable_planned_arrival) { $tmp = parse_date('Y-m-d H:i', $request->input('planned_arrival_date') . ' 00:00'); $result = User_validate_planned_arrival_date($tmp); $planned_arrival_date = $result->getValue(); @@ -149,7 +150,7 @@ function guest_register() $valid = false; error(__('Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date.')); } - } else { + } else if ($enable_planned_arrival) { $valid = false; error(__('Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date.')); } @@ -303,11 +304,11 @@ function guest_register() ]), div('row', [ div('col-sm-6', [ - form_date( + $enable_planned_arrival ? form_date( 'planned_arrival_date', __('Planned date of arrival') . ' ' . entry_required(), $planned_arrival_date, $buildup_start_date, $teardown_end_date - ) + ) : '' ]), div('col-sm-6', [ $enable_tshirt_size ? form_select('tshirt_size', diff --git a/includes/view/User_view.php b/includes/view/User_view.php index cc2c3153..1f3c1127 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -26,7 +26,9 @@ function User_settings_view( ) { $personalData = $user_source->personalData; $enable_dect = config('enable_dect'); - return page_with_title(settings_title(), [ + $enable_planned_arrival = config('enable_planned_arrival'); + + return page_with_title(settings_title(), [ msg(), div('row', [ div('col-md-6', [ @@ -36,20 +38,20 @@ function User_settings_view( form_text('nick', __('Nick'), $user_source->name, true), form_text('lastname', __('Last name'), $personalData->last_name), form_text('prename', __('First name'), $personalData->first_name), - form_date( + $enable_planned_arrival ? form_date( 'planned_arrival_date', __('Planned date of arrival') . ' ' . entry_required(), $personalData->planned_arrival_date ? $personalData->planned_arrival_date->getTimestamp() : '', $buildup_start_date, $teardown_end_date - ), - form_date( + ) : '', + $enable_planned_arrival ? form_date( 'planned_departure_date', __('Planned date of departure'), $personalData->planned_departure_date ? $personalData->planned_departure_date->getTimestamp() : '', $buildup_start_date, $teardown_end_date - ), + ) : '', $enable_dect ? form_text('dect', __('DECT'), $user_source->contact->dect) : '', form_text('mobile', __('Mobile'), $user_source->contact->mobile), form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source->email), @@ -894,7 +896,7 @@ function render_profile_link($text, $user_id = null, $class = '') */ function render_user_departure_date_hint() { - if (!auth()->user()->personalData->planned_departure_date) { + if (config('enable_planned_arrival') && !auth()->user()->personalData->planned_departure_date) { $text = __('Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.'); return render_profile_link($text, null, 'alert-link'); }