add config option and permission for food voucher

This commit is contained in:
Xu 2022-06-10 23:03:25 +02:00 committed by Igor Scheller
parent 53009c21a4
commit 05e94bbfee
4 changed files with 18 additions and 10 deletions

View File

@ -271,9 +271,12 @@ return [
// Enables the T-Shirt configuration on signup and profile
'enable_tshirt_size' => (bool)env('ENABLE_TSHIRT_SIZE', true),
// Enables the goody/voucher configuration on signup and profile
// Enables the goody configuration on signup and profile
'enable_goody' => (bool)env('ENABLE_GOODY', false),
// Enables the food voucher in the user profile
'enable_voucher' => (bool)env('ENABLE_VOUCHER', true),
// Number of shifts to freeload until angel is locked for shift signup.
'max_freeloadable_shifts' => env('MAX_FREELOADABLE_SHIFTS', 2),

View File

@ -146,7 +146,10 @@ function user_edit_vouchers_controller()
$user_source = $user;
}
if (!auth()->can('admin_user') && !auth()->can('voucher.edit')) {
if (
(!auth()->can('admin_user') && !auth()->can('voucher.edit'))
|| !config('enable_voucher')
) {
throw_redirect(page_link_to(''));
}

View File

@ -634,13 +634,15 @@ function User_view(
form_hidden('user', $user_source->id),
form_submit('submit', __('arrived'), '', false, 'primary')
], page_link_to('admin_arrive'), true) : '',
$admin_user_privilege || $auth->can('voucher.edit') ? button(
($admin_user_privilege || $auth->can('voucher.edit')) && config('enable_voucher') ?
button(
page_link_to(
'users',
['action' => 'edit_vouchers', 'user_id' => $user_source->id]
),
icon('file-binary-fill') . __('Edit vouchers')
) : '',
)
: '',
$admin_user_worklog_privilege ? button(
user_worklog_add_link($user_source),
icon('list') . __('Add work log')

View File

@ -201,7 +201,7 @@ class LegacyMiddleware implements MiddlewareInterface
return response($content, (int)$page);
}
if (strpos($content, '<html') !== false) {
if (strpos((string)$content, '<html') !== false) {
return response($content);
}