Merge branch 'install_master' of https://git.in.moodle.com/amosbot/moodle-install
[moodle.git] / user / forum_form.php
blob4809a6127d21aa2eb9ab74ea5045d040e98f391a
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', $CFG->defaultpreference_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', $CFG->defaultpreference_autosubscribe);
64 if (!empty($CFG->forum_trackreadposts)) {
65 $choices = array();
66 $choices['0'] = get_string('trackforumsno');
67 $choices['1'] = get_string('trackforumsyes');
68 $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
69 $mform->setDefault('trackforums', $CFG->defaultpreference_trackforums);
72 // Add some extra hidden fields.
73 $mform->addElement('hidden', 'id');
74 $mform->setType('id', PARAM_INT);
75 $mform->addElement('hidden', 'course', $COURSE->id);
76 $mform->setType('course', PARAM_INT);
78 $this->add_action_buttons(true, get_string('savechanges'));