diff options
-rw-r--r-- | config/config.default.php | 3 | ||||
-rw-r--r-- | includes/pages/guest_login.php | 12 | ||||
-rw-r--r-- | includes/sys_menu.php | 2 | ||||
-rw-r--r-- | includes/view/AngelTypes_view.php | 26 |
4 files changed, 34 insertions, 9 deletions
diff --git a/config/config.default.php b/config/config.default.php index 419b02d1..c2d742ef 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -44,6 +44,9 @@ return [ // Number of News shown on one site 'display_news' => 6, + // Users are able to sign up + 'registration_enabled' => true, + // Only arrived angels can sign up for shifts 'signup_requires_arrival' => false, diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index 9179c6c4..0577951f 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -33,7 +33,7 @@ function logout_title() */ function guest_register() { - global $user; + global $user, $privileges; $tshirt_sizes = config('tshirt_sizes'); $enable_tshirt_size = config('enable_tshirt_size'); $min_password_length = config('min_password_length'); @@ -75,6 +75,14 @@ function guest_register() } } + if (!in_array('register', $privileges) || (!isset($user) && !config('registration_enabled'))) { + error(_('Registration is disabled.')); + + return page_with_title(register_title(), [ + msg(), + ]); + } + if ($request->has('submit')) { $valid = true; @@ -496,7 +504,7 @@ function get_register_hint() { global $privileges; - if (in_array('register', $privileges)) { + if (in_array('register', $privileges) && config('registration_enabled')) { return join('', [ '<p>' . _('Please sign up, if you want to help us!') . '</p>', buttons([ diff --git a/includes/sys_menu.php b/includes/sys_menu.php index 2eaa1234..385a6948 100644 --- a/includes/sys_menu.php +++ b/includes/sys_menu.php @@ -59,7 +59,7 @@ function header_toolbar() ); } - if (!isset($user) && in_array('register', $privileges)) { + if (!isset($user) && in_array('register', $privileges) && config('registration_enabled')) { $toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $page == 'register'); } diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index f75cc616..baf0e04a 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -475,13 +475,27 @@ function AngelTypes_about_view_angeltype($angeltype) */ function AngelTypes_about_view($angeltypes, $user_logged_in) { + global $privileges; + + $buttons = []; + + if ($user_logged_in) { + $buttons[] = button(page_link_to('angeltypes'), angeltypes_title(), 'back'); + } else { + if (in_array('register', $privileges) && config('registration_enabled')) { + $buttons[] = button(page_link_to('register'), register_title()); + } + + $buttons[] = button(page_link_to('login'), login_title()); + } + + $faqUrl = config('faq_url'); + if (!empty($faqUrl)) { + $buttons[] = button($faqUrl, _('FAQ'), 'btn-primary'); + } + $content = [ - buttons([ - !$user_logged_in ? button(page_link_to('register'), register_title()) : '', - !$user_logged_in ? button(page_link_to('login'), login_title()) : '', - $user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '', - button(config('faq_url'), _('FAQ'), 'btn-primary') - ]), + buttons($buttons), '<p>' . _('Here is the list of teams and their tasks. If you have questions, read the FAQ.') . '</p>', '<hr />' ]; |