Merge branch 'MDL-49823-master' of git://github.com/jleyva/moodle
[moodle.git] / user / editor_form.php
blobb0c24cfe5e7644ad8c4fcf4c04a0b0505b3de518
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 editor preferences.
20 * @copyright 1999 Martin Dougiamas http://dougiamas.com
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22 * @package core_user
25 if (!defined('MOODLE_INTERNAL')) {
26 die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
29 require_once($CFG->dirroot.'/lib/formslib.php');
31 /**
32 * Class user_edit_editor_form.
34 * @copyright 1999 Martin Dougiamas http://dougiamas.com
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 class user_edit_editor_form extends moodleform {
39 /**
40 * Define the form.
42 public function definition () {
43 global $CFG, $COURSE;
45 $mform = $this->_form;
47 $editors = editors_get_enabled();
48 if (count($editors) > 1) {
49 $choices = array('' => get_string('defaulteditor'));
50 $firsteditor = '';
51 foreach (array_keys($editors) as $editor) {
52 if (!$firsteditor) {
53 $firsteditor = $editor;
55 $choices[$editor] = get_string('pluginname', 'editor_' . $editor);
57 $mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
58 $mform->setDefault('preference_htmleditor', '');
59 } else {
60 // Empty string means use the first chosen text editor.
61 $mform->addElement('hidden', 'preference_htmleditor');
62 $mform->setDefault('preference_htmleditor', '');
63 $mform->setType('preference_htmleditor', PARAM_PLUGIN);
66 $this->add_action_buttons(true, get_string('savechanges'));