feature: disable lastname+prename in config

main
msquare 5 years ago
parent 1604d2bce0
commit 3ce3129b6e

@ -110,6 +110,9 @@ return [
// Whether the DECT field should be enabled // Whether the DECT field should be enabled
'enable_dect' => true, 'enable_dect' => true,
// Enables prename and lastname
'enable_user_name' => false,
// Enables the planned arrival/leave date // Enables the planned arrival/leave date
'enable_planned_arrival' => true, 'enable_planned_arrival' => true,

@ -52,8 +52,10 @@ function admin_user()
$html .= ' <tr><td>Last login</td><td><p class="help-block">' $html .= ' <tr><td>Last login</td><td><p class="help-block">'
. ($user_source->last_login_at ? $user_source->last_login_at->format('Y-m-d H:i') : '-') . ($user_source->last_login_at ? $user_source->last_login_at->format('Y-m-d H:i') : '-')
. '</p></td></tr>' . "\n"; . '</p></td></tr>' . "\n";
if (config('enable_user_name')) {
$html .= ' <tr><td>Name</td><td>' . '<input size="40" name="eName" value="' . $user_source->personalData->last_name . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Name</td><td>' . '<input size="40" name="eName" value="' . $user_source->personalData->last_name . '" class="form-control"></td></tr>' . "\n";
$html .= ' <tr><td>Vorname</td><td>' . '<input size="40" name="eVorname" value="' . $user_source->personalData->first_name . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Vorname</td><td>' . '<input size="40" name="eVorname" value="' . $user_source->personalData->first_name . '" class="form-control"></td></tr>' . "\n";
}
$html .= ' <tr><td>Handy</td><td>' . '<input type= "tel" size="40" name="eHandy" value="' . $user_source->contact->mobile . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Handy</td><td>' . '<input type= "tel" size="40" name="eHandy" value="' . $user_source->contact->mobile . '" class="form-control"></td></tr>' . "\n";
if (config('enable_dect')) { if (config('enable_dect')) {
$html .= ' <tr><td>DECT</td><td>' . '<input size="40" name="eDECT" value="' . $user_source->contact->dect . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>DECT</td><td>' . '<input size="40" name="eDECT" value="' . $user_source->contact->dect . '" class="form-control"></td></tr>' . "\n";

@ -26,6 +26,7 @@ function guest_register()
$authUser = auth()->user(); $authUser = auth()->user();
$tshirt_sizes = config('tshirt_sizes'); $tshirt_sizes = config('tshirt_sizes');
$enable_tshirt_size = config('enable_tshirt_size'); $enable_tshirt_size = config('enable_tshirt_size');
$enable_user_name = config('enable_user_name');
$enable_dect = config('enable_dect'); $enable_dect = config('enable_dect');
$enable_planned_arrival = config('enable_planned_arrival'); $enable_planned_arrival = config('enable_planned_arrival');
$min_password_length = config('min_password_length'); $min_password_length = config('min_password_length');
@ -151,10 +152,10 @@ function guest_register()
} }
// Trivia // Trivia
if ($request->has('lastname')) { if ($enable_user_name && $request->has('lastname')) {
$lastName = strip_request_item('lastname'); $lastName = strip_request_item('lastname');
} }
if ($request->has('prename')) { if ($enable_user_name && $request->has('prename')) {
$preName = strip_request_item('prename'); $preName = strip_request_item('prename');
} }
if ($enable_dect && $request->has('dect')) { if ($enable_dect && $request->has('dect')) {
@ -338,14 +339,14 @@ function guest_register()
form_text('mobile', __('Mobile'), $mobile) form_text('mobile', __('Mobile'), $mobile)
]), ]),
]), ]),
div('row', [ $enable_user_name ? div('row', [
div('col-sm-6', [ div('col-sm-6', [
form_text('prename', __('First name'), $preName) form_text('prename', __('First name'), $preName)
]), ]),
div('col-sm-6', [ div('col-sm-6', [
form_text('lastname', __('Last name'), $lastName) form_text('lastname', __('Last name'), $lastName)
]) ])
]), ]) : '',
form_info(entry_required() . ' = ' . __('Entry required!')) form_info(entry_required() . ' = ' . __('Entry required!'))
]) ])
]), ]),

@ -70,14 +70,18 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
} }
// Trivia // Trivia
if(config('enable_user_name')) {
$user_source->personalData->last_name = strip_request_item('lastname', $user_source->personalData->last_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); $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) { if (strlen(strip_request_item('dect')) <= 40) {
$user_source->contact->dect = strip_request_item('dect', $user_source->contact->dect); $user_source->contact->dect = strip_request_item('dect', $user_source->contact->dect);
} else { } else {
$valid = false; $valid = false;
error(__('For dect numbers are only 40 digits allowed.')); error(__('For dect numbers are only 40 digits allowed.'));
} }
}
$user_source->contact->mobile = strip_request_item('mobile', $user_source->contact->mobile); $user_source->contact->mobile = strip_request_item('mobile', $user_source->contact->mobile);
if ($valid) { if ($valid) {

@ -25,6 +25,7 @@ function User_settings_view(
$tshirt_sizes $tshirt_sizes
) { ) {
$personalData = $user_source->personalData; $personalData = $user_source->personalData;
$enable_user_name = config('enable_user_name');
$enable_dect = config('enable_dect'); $enable_dect = config('enable_dect');
$enable_planned_arrival = config('enable_planned_arrival'); $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.') __('Use up to 23 letters, numbers, connecting punctuations or spaces for your nickname.')
), ),
form_text('lastname', __('Last name'), $personalData->last_name), $enable_user_name ? form_text('lastname', __('Last name'), $personalData->last_name) : '',
form_text('prename', __('First name'), $personalData->first_name), $enable_user_name ? form_text('prename', __('First name'), $personalData->first_name) : '',
$enable_planned_arrival ? form_date( $enable_planned_arrival ? form_date(
'planned_arrival_date', 'planned_arrival_date',
__('Planned date of arrival') . ' ' . entry_required(), __('Planned date of arrival') . ' ' . entry_required(),
@ -253,28 +254,34 @@ function Users_view(
'actions' => '<strong>' . count($usersList) . '</strong>' 'actions' => '<strong>' . count($usersList) . '</strong>'
]; ];
$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'), [ return page_with_title(__('All users'), [
msg(), msg(),
buttons([ buttons([
button(page_link_to('register'), glyph('plus') . __('New user')) button(page_link_to('register'), glyph('plus') . __('New user'))
]), ]),
table([ table($user_table_headers, $usersList)
'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)
]); ]);
} }
@ -609,7 +616,7 @@ function User_view(
return page_with_title( return page_with_title(
'<span class="icon-icon_angel"></span> ' '<span class="icon-icon_angel"></span> '
. htmlspecialchars($user_source->name) . htmlspecialchars($user_source->name)
. ' <small>' . $user_name . '</small>', . (config('enable_user_name') ? ' <small>' . $user_name . '</small>' : ''),
[ [
msg(), msg(),
div('row space-top', [ div('row space-top', [

Loading…
Cancel
Save