From c8706d527ef08307ef357441061a7885550de6ef Mon Sep 17 00:00:00 2001 From: Luca Date: Wed, 30 Mar 2022 12:17:32 +0200 Subject: [PATCH] Add option to hide iCal/JSON export --- config/config.default.php | 3 +++ includes/view/User_view.php | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index c7e2844d..9631a62b 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -273,6 +273,9 @@ return [ // Enables the goody/voucher configuration on signup and profile 'enable_goody' => (bool)env('ENABLE_GOODY', false), + // Enables shifts export as iCal/JSON (if disabled, buttons/links will not be shown, but endpoints will still work) + 'enable_shifts_export' => (bool)env('ENABLE_SHIFTS_EXPORT', false), + // Number of shifts to freeload until angel is locked for shift signup. 'max_freeloadable_shifts' => env('MAX_FREELOADABLE_SHIFTS', 1), diff --git a/includes/view/User_view.php b/includes/view/User_view.php index d4d4a031..f0de41d1 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -609,6 +609,7 @@ function User_view( } } + $enable_export = config('enable_shifts_export'); return page_with_title( ' ' . ( @@ -656,15 +657,15 @@ function User_view( page_link_to('user_settings'), icon('gear') . __('Settings') ) : '', - ($its_me && $auth->can('ical')) ? button( + ($its_me && $enable_export && $auth->can('ical')) ? button( page_link_to('ical', ['key' => $user_source->api_key]), icon('calendar3') . __('iCal Export') ) : '', - ($its_me && $auth->can('shifts_json_export')) ? button( + ($its_me && $enable_export && $auth->can('shifts_json_export')) ? button( page_link_to('shifts_json_export', ['key' => $user_source->api_key]), icon('box-arrow-up-right') . __('JSON Export') ) : '', - ($its_me && ( + ($its_me && $enable_export && ( $auth->can('shifts_json_export') || $auth->can('ical') || $auth->can('atom') @@ -703,7 +704,7 @@ function User_view( page_link_to('user_shifts') ), true) : '', - $its_me ? ical_hint() : '' + $its_me && $enable_export ? ical_hint() : '' ] ); }