MDL-6236 user editing - Default language not used instead of nonexisting one in user lang field - first lang chosen instead; merged from MODOLE_18_STABLE

This commit is contained in:
skodak 2007-04-16 18:30:52 +00:00
parent 59465949fa
commit 1545d7f0d4
2 changed files with 20 additions and 0 deletions

View File

@ -42,6 +42,16 @@ class user_edit_form extends moodleform {
$mform =& $this->_form;
$userid = $mform->getElementValue('id');
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
if (!file_exists($CFG->dataroot.'/lang/'.$lang) and
!file_exists($CFG->dirroot .'/lang/'.$lang)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
if ($user = get_record('user', 'id', $userid)) {
// print picture

View File

@ -55,6 +55,16 @@ class user_editadvanced_form extends moodleform {
$userid = $mform->getElementValue('id');
$user = get_record('user', 'id', $userid);
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
if (!file_exists($CFG->dataroot.'/lang/'.$lang) and
!file_exists($CFG->dirroot .'/lang/'.$lang)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
// user can not change own auth method
if ($userid == $USER->id) {
$mform->hardFreeze('auth');