MDL-61967 core_user: Allow filtering by No groups on participants page
[moodle.git] / user / forum_form.php
blob17037522389191f4dd7a59dda062ccf41848b51c
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Form to edit a users forum preferences.
20 * These are stored as columns in the user table, which
21 * is why they are in /user and not /mod/forum.
23 * @copyright 1999 Martin Dougiamas http://dougiamas.com
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 * @package core_user
28 if (!defined('MOODLE_INTERNAL')) {
29 die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
32 require_once($CFG->dirroot.'/lib/formslib.php');
34 /**
35 * Class user_edit_forum_form.
37 * @copyright 1999 Martin Dougiamas http://dougiamas.com
38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40 class user_edit_forum_form extends moodleform {
42 /**
43 * Define the form.
45 public function definition () {
46 global $CFG, $COURSE;
48 $mform = $this->_form;
50 $choices = array();
51 $choices['0'] = get_string('emaildigestoff');
52 $choices['1'] = get_string('emaildigestcomplete');
53 $choices['2'] = get_string('emaildigestsubjects');
54 $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
55 $mform->setDefault('maildigest', core_user::get_property_default('maildigest'));
56 $mform->addHelpButton('maildigest', 'emaildigest');
58 $choices = array();
59 $choices['1'] = get_string('autosubscribeyes');
60 $choices['0'] = get_string('autosubscribeno');
61 $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
62 $mform->setDefault('autosubscribe', core_user::get_property_default('autosubscribe'));
64 if (!empty($CFG->forum_trackreadposts)) {
65 $mform->addElement('header', 'trackreadposts', get_string('trackreadposts_header', 'mod_forum'));
66 $choices = array();
67 $choices['0'] = get_string('trackforumsno');
68 $choices['1'] = get_string('trackforumsyes');
69 $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
70 $mform->setDefault('trackforums', core_user::get_property_default('trackforums'));
72 $choices = [
73 1 => get_string('markasreadonnotificationyes', 'mod_forum'),
74 0 => get_string('markasreadonnotificationno', 'mod_forum'),
76 $mform->addElement('select', 'markasreadonnotification', get_string('markasreadonnotification', 'mod_forum'), $choices);
77 $mform->addHelpButton('markasreadonnotification', 'markasreadonnotification', 'mod_forum');
78 $mform->disabledIf('markasreadonnotification', 'trackforums', 'eq', "0");
79 $mform->setDefault('markasreadonnotification', 1);
82 // Add some extra hidden fields.
83 $mform->addElement('hidden', 'id');
84 $mform->setType('id', PARAM_INT);
85 $mform->addElement('hidden', 'course', $COURSE->id);
86 $mform->setType('course', PARAM_INT);
88 $this->add_action_buttons(true, get_string('savechanges'));