From 69ac1b2d2115a41afe2bd4527abadda70063019a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Wed, 6 Mar 2019 19:28:07 +0100 Subject: [PATCH] Support disabling the arrival feature Setting `autoarrive` to true will now cause all newly registered angels to be automatically confirmed as arrived. --- config/config.default.php | 3 +++ includes/pages/guest_login.php | 7 ++++++- includes/sys_menu.php | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config/config.default.php b/config/config.default.php index 8840a00c..d1692590 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -82,6 +82,9 @@ return [ // Only arrived angels can sign up for shifts 'signup_requires_arrival' => false, + // Whether newly-registered user should automatically be marked as arrived + 'autoarrive' => false, + // Number of hours that an angel has to sign out own shifts 'last_unsubscribe' => 3, diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index f507548b..c636a36c 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -217,7 +217,12 @@ function guest_register() ->associate($user) ->save(); - (new State())->user() + $state = new State([]); + if (config('autoarrive')) { + $state->arrived = true; + $state->arrival_date = new Carbon(); + } + $state->user() ->associate($user) ->save(); diff --git a/includes/sys_menu.php b/includes/sys_menu.php index b4c04a98..4dabc857 100644 --- a/includes/sys_menu.php +++ b/includes/sys_menu.php @@ -114,6 +114,10 @@ function make_navigation() 'admin_event_config' => __('Event config'), ]; + if (config('autoarrive')) { + unset($admin_pages['admin_arrive']); + } + foreach ($admin_pages as $menu_page => $title) { if (auth()->can($menu_page)) { $admin_menu[] = toolbar_item_link(