Merge branch 'MDL-67641-37' of git://github.com/dpalou/moodle into MOODLE_37_STABLE
[moodle.git] / user / classes / course_form.php
blob17a77302497ef61097258386f3dcfff7e903d8ef
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 course preferences.
20 * These are stored as columns in the user table, which
21 * is why they are in /user and not /course or /admin.
23 * @copyright 2016 Joey Andres <jandres@ualberta.ca>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 * @package core_user
28 namespace core_user;
30 if (!defined('MOODLE_INTERNAL')) {
31 die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
34 require_once($CFG->dirroot.'/lib/formslib.php');
36 /**
37 * Class user_course_form.
39 * @copyright 2016 Joey Andres <jandres@ualberta.ca>
40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
42 class course_form extends \moodleform {
44 /**
45 * Define the form.
47 public function definition () {
48 global $COURSE;
50 $mform = $this->_form;
52 $mform->addElement('advcheckbox',
53 'enableactivitychooser',
54 get_string('enableactivitychooser', 'admin'),
55 get_string('configenableactivitychooser', 'admin'));
56 $mform->setDefault('enableactivitychooser',
57 get_user_preferences('usemodchooser', true, $this->_customdata['userid']));
59 // Add some extra hidden fields.
60 $mform->addElement('hidden', 'id');
61 $mform->setType('id', PARAM_INT);
62 $mform->addElement('hidden', 'course', $COURSE->id);
63 $mform->setType('course', PARAM_INT);
65 $this->add_action_buttons(true, get_string('savechanges'));