mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-37669 mod_forum: Mark posts as read on notify to user pref
Some people prefer to have posts marked as read when they receive them, and some prefer not to. Let us allow them to choose.
This commit is contained in:
parent
5c33a0db21
commit
64ebf3955b
@ -280,6 +280,10 @@ $string['mailnow'] = 'Send forum post notifications with no editing-time delay';
|
||||
$string['manydiscussions'] = 'Discussions per page';
|
||||
$string['markalldread'] = 'Mark all posts in this discussion read.';
|
||||
$string['markallread'] = 'Mark all posts in this forum read.';
|
||||
$string['markasreadonnotification'] = 'When sending forum post notifications';
|
||||
$string['markasreadonnotificationno'] = 'Do not mark the post as read';
|
||||
$string['markasreadonnotificationyes'] = 'Mark the post as read';
|
||||
$string['markasreadonnotification_help'] = 'When you are notified of a forum post, you can choose whether this should mark the post as read for the purpose of forum tracking.';
|
||||
$string['markread'] = 'Mark read';
|
||||
$string['markreadbutton'] = 'Mark<br />read';
|
||||
$string['markunread'] = 'Mark unread';
|
||||
@ -495,6 +499,7 @@ $string['timedposts'] = 'Timed posts';
|
||||
$string['timedvisible'] = 'Timed status: Visible to all users';
|
||||
$string['timestartenderror'] = 'Display end date cannot be earlier than the start date';
|
||||
$string['trackforum'] = 'Track unread posts';
|
||||
$string['trackreadposts_header'] = 'Forum tracking';
|
||||
$string['tracking'] = 'Track';
|
||||
$string['trackingoff'] = 'Off';
|
||||
$string['trackingon'] = 'Forced';
|
||||
|
@ -888,7 +888,10 @@ function forum_cron() {
|
||||
}
|
||||
|
||||
// Mark processed posts as read.
|
||||
forum_tp_mark_posts_read($userto, $userto->markposts);
|
||||
if (get_user_preferences('forum_markasreadonnotification', 1, $userto->id) == 1) {
|
||||
forum_tp_mark_posts_read($userto, $userto->markposts);
|
||||
}
|
||||
|
||||
unset($userto);
|
||||
}
|
||||
}
|
||||
@ -1202,7 +1205,9 @@ function forum_cron() {
|
||||
$usermailcount++;
|
||||
|
||||
// Mark post as read if forum_usermarksread is set off
|
||||
forum_tp_mark_posts_read($userto, $userto->markposts);
|
||||
if (get_user_preferences('forum_markasreadonnotification', 1, $userto->id) == 1) {
|
||||
forum_tp_mark_posts_read($userto, $userto->markposts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ list($user, $course) = useredit_setup_preference_page($userid, $courseid);
|
||||
// Create form.
|
||||
$forumform = new user_edit_forum_form(null, array('userid' => $user->id));
|
||||
|
||||
$user->markasreadonnotification = get_user_preferences('forum_markasreadonnotification', 1, $user->id);
|
||||
$forumform->set_data($user);
|
||||
|
||||
$redirect = new moodle_url("/user/preferences.php", array('userid' => $user->id));
|
||||
@ -49,8 +50,13 @@ if ($forumform->is_cancelled()) {
|
||||
$user->autosubscribe = $data->autosubscribe;
|
||||
if (!empty($CFG->forum_trackreadposts)) {
|
||||
$user->trackforums = $data->trackforums;
|
||||
if (property_exists($data, 'markasreadonnotification')) {
|
||||
$user->preference_forum_markasreadonnotification = $data->markasreadonnotification;
|
||||
}
|
||||
}
|
||||
unset($user->markasreadonnotification);
|
||||
|
||||
useredit_update_user_preference($user);
|
||||
user_update_user($user, false, false);
|
||||
|
||||
// Trigger event.
|
||||
|
@ -62,11 +62,21 @@ class user_edit_forum_form extends moodleform {
|
||||
$mform->setDefault('autosubscribe', core_user::get_property_default('autosubscribe'));
|
||||
|
||||
if (!empty($CFG->forum_trackreadposts)) {
|
||||
$mform->addElement('header', 'trackreadposts', get_string('trackreadposts_header', 'mod_forum'));
|
||||
$choices = array();
|
||||
$choices['0'] = get_string('trackforumsno');
|
||||
$choices['1'] = get_string('trackforumsyes');
|
||||
$mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
|
||||
$mform->setDefault('trackforums', core_user::get_property_default('trackforums'));
|
||||
|
||||
$choices = [
|
||||
1 => get_string('markasreadonnotificationyes', 'mod_forum'),
|
||||
0 => get_string('markasreadonnotificationno', 'mod_forum'),
|
||||
];
|
||||
$mform->addElement('select', 'markasreadonnotification', get_string('markasreadonnotification', 'mod_forum'), $choices);
|
||||
$mform->addHelpButton('markasreadonnotification', 'markasreadonnotification', 'mod_forum');
|
||||
$mform->disabledIf('markasreadonnotification', 'trackforums', 'eq', "0");
|
||||
$mform->setDefault('markasreadonnotification', 1);
|
||||
}
|
||||
|
||||
// Add some extra hidden fields.
|
||||
|
Loading…
x
Reference in New Issue
Block a user