From 6384eca1cefd9cc3aa1b38cbc037751c5f2fd5d8 Mon Sep 17 00:00:00 2001 From: msquare Date: Wed, 28 Sep 2016 07:28:51 +0200 Subject: [PATCH] display user welcome message --- includes/pages/guest_login.php | 81 ++++++++++++++++++++-------------- includes/view/User_view.php | 28 +++++++++++- 2 files changed, 74 insertions(+), 35 deletions(-) diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index 8f4d24a4..d3eb1916 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -14,10 +14,11 @@ function logout_title() { // Engel registrieren function guest_register() { - global $tshirt_sizes, $enable_tshirt_size, $default_theme; + global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user; $event_config = EventConfig(); - return User_registration_success_view($event_config['event_welcome_msg']); + if ($event_config === false) + engelsystem_error("Unable to load event config."); $msg = ""; $nick = ""; @@ -168,6 +169,16 @@ function guest_register() { engelsystem_log("User " . User_Nick_render(User($user_id)) . " signed up as: " . join(", ", $user_angel_types_info)); success(_("Angel registration successful!")); + // User is already logged in - that means a coordinator has registered an angel. Return to register page. + if (isset($user)) { + redirect(page_link_to('register')); + } + + // If a welcome message is present, display registration success page. + if ($event_config != null && $event_config['event_welcome_msg'] != null) { + return User_registration_success_view($event_config['event_welcome_msg']); + } + redirect('?'); } } @@ -295,41 +306,45 @@ function guest_login() { } } + return page_with_title(login_title(), [ + msg(), + div('row', [ + div('col-md-6', [ + form([ + form_text('nick', _("Nick"), $nick), + form_password('password', _("Password")), + form_submit('submit', _("Login")), + buttons([ + button(page_link_to('user_password_recovery'), _("I forgot my password")) + ]), + info(_("Please note: You have to activate cookies!"), true) + ]) + ]), + div('col-md-6', [ + '

' . register_title() . '

', + get_register_hint(), + '

' . _("What can I do?") . '

', + '

' . _("Please read about the jobs you can do to help us.") . '

', + buttons([ + button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' »') + ]) + ]) + ]) + ]); +} + +function get_register_hint() { + global $privileges; + if (in_array('register', $privileges)) { - $register_hint = join('', array( + return join('', [ '

' . _("Please sign up, if you want to help us!") . '

', - buttons(array( + buttons([ button(page_link_to('register'), register_title() . ' »') - )) - )); - } else { - $register_hint = join('', array( - error(_('Registration is disabled.'), true) - )); + ]) + ]); } - return page_with_title(login_title(), array( - msg(), - '
', - form(array( - form_text('nick', _("Nick"), $nick), - form_password('password', _("Password")), - form_submit('submit', _("Login")), - buttons(array( - button(page_link_to('user_password_recovery'), _("I forgot my password")) - )), - info(_("Please note: You have to activate cookies!"), true) - )), - '
', - '
', - '

' . register_title() . '

', - $register_hint, - '

' . _("What can I do?") . '

', - '

' . _("Please read about the jobs you can do to help us.") . '

', - buttons(array( - button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' »') - )), - '
' - )); + return error(_("Registration is disabled."), true); } ?> diff --git a/includes/view/User_view.php b/includes/view/User_view.php index bec9879c..4f61006e 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -25,8 +25,32 @@ $tshirt_sizes = array( function User_registration_success_view($event_welcome_message) { $parsedown = new Parsedown(); $event_welcome_message = $parsedown->text($event_welcome_message); - return page_with_title(_("Welcome to the engelsystem!"), [ - $event_welcome_message + return page_with_title(_("Registration successful"), [ + msg(), + div('row', [ + div('col-md-4', [ + $event_welcome_message + ]), + div('col-md-4', [ + '

' . _("Login") . '

', + form([ + form_text('nick', _("Nick"), ""), + form_password('password', _("Password")), + form_submit('submit', _("Login")), + buttons([ + button(page_link_to('user_password_recovery'), _("I forgot my password")) + ]), + info(_("Please note: You have to activate cookies!"), true) + ], page_link_to('login')) + ]), + div('col-md-4', [ + '

' . _("What can I do?") . '

', + '

' . _("Please read about the jobs you can do to help us.") . '

', + buttons([ + button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' »') + ]) + ]) + ]) ]); }