[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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. 13 // 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/>. 16 17 /** 18 * Form to edit a users preferred language 19 * 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 23 */ 24 25 if (!defined('MOODLE_INTERNAL')) { 26 die('Direct access to this script is forbidden.'); // It must be included from a Moodle page. 27 } 28 29 require_once($CFG->dirroot.'/lib/formslib.php'); 30 31 /** 32 * Class user_edit_form. 33 * 34 * @copyright 1999 Martin Dougiamas http://dougiamas.com 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class user_edit_language_form extends moodleform { 38 39 /** 40 * Define the form. 41 */ 42 public function definition () { 43 global $CFG, $COURSE, $USER; 44 45 $mform = $this->_form; 46 $userid = $USER->id; 47 48 if (is_array($this->_customdata)) { 49 if (array_key_exists('userid', $this->_customdata)) { 50 $userid = $this->_customdata['userid']; 51 } 52 } 53 54 // Add some extra hidden fields. 55 $mform->addElement('hidden', 'id'); 56 $mform->setType('id', PARAM_INT); 57 $mform->addElement('hidden', 'course', $COURSE->id); 58 $mform->setType('course', PARAM_INT); 59 60 $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations()); 61 $mform->setDefault('lang', core_user::get_property_default('lang')); 62 63 $this->add_action_buttons(true, get_string('savechanges')); 64 } 65 66 /** 67 * Extend the form definition after the data has been parsed. 68 */ 69 public function definition_after_data() { 70 global $CFG, $DB, $OUTPUT; 71 72 $mform = $this->_form; 73 74 // If language does not exist, use site default lang. 75 if ($langsel = $mform->getElementValue('lang')) { 76 $lang = reset($langsel); 77 // Check lang exists. 78 if (!get_string_manager()->translation_exists($lang, false)) { 79 $langel =& $mform->getElement('lang'); 80 $langel->setValue(core_user::get_property_default('lang')); 81 } 82 } 83 84 } 85 86 } 87 88
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |