mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-48029 mod_forum: Check for subscription before enrolling
This commit is contained in:
parent
dc3fab74ae
commit
ddb4a31d54
4 changed files with 14 additions and 3 deletions
|
@ -238,7 +238,9 @@
|
||||||
echo $OUTPUT->heading(format_string($forum->name), 2);
|
echo $OUTPUT->heading(format_string($forum->name), 2);
|
||||||
echo $OUTPUT->heading(format_string($discussion->name), 3, 'discussionname');
|
echo $OUTPUT->heading(format_string($discussion->name), 3, 'discussionname');
|
||||||
|
|
||||||
if ((!isguestuser() && isloggedin()) && has_capability('mod/forum:viewdiscussion', $modcontext)) {
|
// is_guest should be used here as this also checks whether the user is a guest in the current course.
|
||||||
|
// Guests and visitors cannot subscribe - only enrolled users.
|
||||||
|
if ((!is_guest($modcontext, $USER) && isloggedin()) && has_capability('mod/forum:viewdiscussion', $modcontext)) {
|
||||||
// Discussion subscription.
|
// Discussion subscription.
|
||||||
if (\mod_forum\subscriptions::is_subscribable($forum)) {
|
if (\mod_forum\subscriptions::is_subscribable($forum)) {
|
||||||
echo html_writer::div(
|
echo html_writer::div(
|
||||||
|
|
|
@ -332,6 +332,7 @@ $string['nodiscussions'] = 'There are no discussion topics yet in this forum';
|
||||||
$string['nodiscussionsstartedby'] = '{$a} has not started any discussions';
|
$string['nodiscussionsstartedby'] = '{$a} has not started any discussions';
|
||||||
$string['nodiscussionsstartedbyyou'] = 'You haven\'t started any discussions yet';
|
$string['nodiscussionsstartedbyyou'] = 'You haven\'t started any discussions yet';
|
||||||
$string['noguestpost'] = 'Sorry, guests are not allowed to post.';
|
$string['noguestpost'] = 'Sorry, guests are not allowed to post.';
|
||||||
|
$string['noguestsubscribe'] = 'Sorry, guests are not allowed to subscribe.';
|
||||||
$string['noguesttracking'] = 'Sorry, guests are not allowed to set tracking options.';
|
$string['noguesttracking'] = 'Sorry, guests are not allowed to set tracking options.';
|
||||||
$string['nomorepostscontaining'] = 'No more posts containing \'{$a}\' were found';
|
$string['nomorepostscontaining'] = 'No more posts containing \'{$a}\' were found';
|
||||||
$string['nonews'] = 'No news has been posted yet';
|
$string['nonews'] = 'No news has been posted yet';
|
||||||
|
|
|
@ -3781,7 +3781,9 @@ function forum_print_discussion_header(&$post, $forum, $group=-1, $datestring=""
|
||||||
userdate($usedate, $datestring).'</a>';
|
userdate($usedate, $datestring).'</a>';
|
||||||
echo "</td>\n";
|
echo "</td>\n";
|
||||||
|
|
||||||
if ((!isguestuser() && isloggedin()) && has_capability('mod/forum:viewdiscussion', $modcontext)) {
|
// is_guest should be used here as this also checks whether the user is a guest in the current course.
|
||||||
|
// Guests and visitors cannot subscribe - only enrolled users.
|
||||||
|
if ((!is_guest($modcontext, $USER) && isloggedin()) && has_capability('mod/forum:viewdiscussion', $modcontext)) {
|
||||||
// Discussion subscription.
|
// Discussion subscription.
|
||||||
if (\mod_forum\subscriptions::is_subscribable($forum)) {
|
if (\mod_forum\subscriptions::is_subscribable($forum)) {
|
||||||
echo '<td class="discussionsubscription">';
|
echo '<td class="discussionsubscription">';
|
||||||
|
@ -5425,7 +5427,7 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions = -1, $
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo '<th class="header lastpost" scope="col">'.get_string('lastpost', 'forum').'</th>';
|
echo '<th class="header lastpost" scope="col">'.get_string('lastpost', 'forum').'</th>';
|
||||||
if (has_capability('mod/forum:viewdiscussion', $context)) {
|
if ((!is_guest($context, $USER) && isloggedin()) && has_capability('mod/forum:viewdiscussion', $context)) {
|
||||||
if (\mod_forum\subscriptions::is_subscribable($forum)) {
|
if (\mod_forum\subscriptions::is_subscribable($forum)) {
|
||||||
echo '<th class="header discussionsubscription" scope="col">';
|
echo '<th class="header discussionsubscription" scope="col">';
|
||||||
echo forum_get_discussion_subscription_icon_preloaders();
|
echo forum_get_discussion_subscription_icon_preloaders();
|
||||||
|
|
|
@ -42,6 +42,12 @@ require_capability('mod/forum:viewdiscussion', $context);
|
||||||
|
|
||||||
$return = new stdClass();
|
$return = new stdClass();
|
||||||
|
|
||||||
|
if (is_guest($context, $USER)) {
|
||||||
|
// is_guest should be used here as this also checks whether the user is a guest in the current course.
|
||||||
|
// Guests and visitors cannot subscribe - only enrolled users.
|
||||||
|
throw new moodle_exception('noguestsubscribe', 'mod_forum');
|
||||||
|
}
|
||||||
|
|
||||||
if (!\mod_forum\subscriptions::is_subscribable($forum)) {
|
if (!\mod_forum\subscriptions::is_subscribable($forum)) {
|
||||||
// Nothing to do. We won't actually output any content here though.
|
// Nothing to do. We won't actually output any content here though.
|
||||||
echo json_encode($return);
|
echo json_encode($return);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue