Skip to content

Commit

Permalink
MDL-76970 mod_forum: Login prompt for guest users
Browse files Browse the repository at this point in the history
* When user submit to a forum as an anonymous user, the login prompt
should clearly explain the follow up actions.
  • Loading branch information
Laurent David committed Mar 8, 2023
1 parent 5562084 commit f5d0b19
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
3 changes: 2 additions & 1 deletion mod/forum/lang/en/forum.php
Expand Up @@ -466,7 +466,8 @@
$string['nodiscussions'] = 'There are no discussion topics yet in this forum';
$string['nodiscussionsstartedby'] = '{$a} has not started any discussions';
$string['nodiscussionsstartedbyyou'] = 'You haven\'t started any discussions yet';
$string['noguestpost'] = 'Sorry, guests are not allowed to post.';
$string['noguestpost'] = 'Only logged in users can post to this forum.';
$string['noguestpost:title'] = 'Log in to continue';
$string['noguestsubscribe'] = 'Sorry, guests are not allowed to subscribe.';
$string['noguesttracking'] = 'Sorry, guests are not allowed to set tracking options.';
$string['nomorepostscontaining'] = 'No more posts containing \'{$a}\' were found';
Expand Down
5 changes: 4 additions & 1 deletion mod/forum/post.php
Expand Up @@ -105,7 +105,10 @@
$referer = get_local_referer(false);

echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('noguestpost', 'forum').'<br /><br />'.get_string('liketologin'), get_login_url(), $referer);
echo $OUTPUT->confirm(get_string('noguestpost', 'forum'), get_login_url(), $referer, [
'confirmtitle' => get_string('noguestpost:title', 'forum'),
'continuestr' => get_string('login')
]);
echo $OUTPUT->footer();
exit;
}
Expand Down
16 changes: 8 additions & 8 deletions mod/forum/tests/behat/guest_users.feature
Expand Up @@ -83,14 +83,14 @@ Feature: Guest and not logged users could see the option to add new post or repl
And I am on the "Forum" "forum activity" page
Then I should see "Add discussion topic"
And I click on "Add discussion topic" "link"
And I should see "Sorry, guests are not allowed to post"
And I should see "Only logged in users can post to this forum"
And I click on "Cancel" "button"
And I should see "Forum discussion 1"
And I click on "Forum discussion 1" "link"
And I should see "Reply"
And I click on "Reply" "link"
And I should see "Sorry, guests are not allowed to post"
And I click on "Continue" "button"
And I should see "Only logged in users can post to this forum"
And I click on "Log in" "button"
And I should see "Log in"

Examples:
Expand All @@ -112,11 +112,11 @@ Feature: Guest and not logged users could see the option to add new post or repl
And I should see "Forum (single discussion)"
Then I should see "Reply"
And I click on "Reply" "link"
And I should see "Sorry, guests are not allowed to post"
And I should see "Only logged in users can post to this forum"
And I click on "Cancel" "button"
And I should see "Reply"
And I click on "Reply" "link"
And I click on "Continue" "button"
And I click on "Log in" "button"
And I should see "Log in"

Scenario: As an enrolled guest I see the option to reply in a blog type forum
Expand All @@ -134,10 +134,10 @@ Feature: Guest and not logged users could see the option to add new post or repl
And I am on the "Forum" "forum activity" page
Then I should see "Add discussion topic"
And I click on "Add discussion topic" "link"
And I should see "Sorry, guests are not allowed to post"
And I should see "Only logged in users can post to this forum"
And I click on "Cancel" "button"
And I should see "Forum discussion 1"
And I click on "Add discussion topic" "link"
And I should see "Sorry, guests are not allowed to post"
And I click on "Continue" "button"
And I should see "Only logged in users can post to this forum"
And I click on "Log in" "button"
And I should see "Log in"

0 comments on commit f5d0b19

Please sign in to comment.