MDL-47909 mod_forum: Respect user autosubscribe setting on post

Re-appropriate the forum autosubscribe setting as a discussion
autosubscribe setting.

The setting was no longer used after the per-discussion changes. The
original plan had been to remove this setting, but there is some benefit to
respecting it for discussion subscriptions instead.
This commit is contained in:
Andrew Nicols 2014-10-28 07:51:10 +08:00
parent c5258dfa04
commit 02cf3958d2
2 changed files with 4 additions and 5 deletions

View File

@ -160,8 +160,8 @@ $string['authenticateduserdescription'] = 'All logged in users.';
$string['authentication'] = 'Authentication';
$string['authenticationplugins'] = 'Authentication plugins';
$string['autosubscribe'] = 'Forum auto-subscribe';
$string['autosubscribeno'] = 'No: don\'t automatically subscribe me to forums';
$string['autosubscribeyes'] = 'Yes: when I post, subscribe me to that forum';
$string['autosubscribeno'] = 'No: don\'t automatically subscribe me to forum discussions';
$string['autosubscribeyes'] = 'Yes: when I post, subscribe me to that forum discussion';
$string['availability'] = 'Availability';
$string['availablecourses'] = 'Available courses';
$string['back'] = 'Back';

View File

@ -616,9 +616,8 @@ $postid = empty($post->id) ? null : $post->id;
$draftid_editor = file_get_submitted_draft_itemid('message');
$currenttext = file_prepare_draft_area($draftid_editor, $modcontext->id, 'mod_forum', 'post', $postid, mod_forum_post_form::editor_options($modcontext, $postid), $post->message);
// Always suggest that the user be subscribed to a discussion that they're posting in unless they've already posted, in
// which case use their existing preference.
$discussionsubscribe = true;
// Respect the user's discussion autosubscribe preference unless they have already posted - in which case, use that preference.
$discussionsubscribe = $USER->autosubscribe;
if (isset($discussion) && forum_user_has_posted($forum->id, $discussion->id, $USER->id)) {
$discussionsubscribe = \mod_forum\subscriptions::is_subscribed($USER->id, $forum, $discussion->id, $cm);
}