This commit is contained in:
Huong Nguyen 2024-01-25 11:01:09 +07:00
commit ff96c6f05c

View File

@ -97,9 +97,6 @@ class admin_uploaduser_form2 extends moodleform {
$columns = $this->_customdata['columns']; $columns = $this->_customdata['columns'];
$data = $this->_customdata['data']; $data = $this->_customdata['data'];
// I am the template user, why should it be the administrator? we have roles now, other ppl may use this script ;-)
$templateuser = $USER;
// upload settings and file // upload settings and file
$mform->addElement('header', 'settingsheader', get_string('settings')); $mform->addElement('header', 'settingsheader', get_string('settings'));
@ -276,30 +273,19 @@ class admin_uploaduser_form2 extends moodleform {
$mform->setDefault('autosubscribe', core_user::get_property_default('autosubscribe')); $mform->setDefault('autosubscribe', core_user::get_property_default('autosubscribe'));
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="25"'); $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="25"');
$mform->setType('city', PARAM_TEXT); $mform->setType('city', core_user::get_property_type('city'));
if (empty($CFG->defaultcity)) { $mform->setDefault('city', core_user::get_property_default('city'));
$mform->setDefault('city', $templateuser->city);
} else {
$mform->setDefault('city', core_user::get_property_default('city'));
}
$choices = get_string_manager()->get_list_of_countries(); $mform->addElement('select', 'country', get_string('selectacountry'), core_user::get_property_choices('country'));
$choices = array(''=>get_string('selectacountry').'...') + $choices; $mform->setDefault('country', core_user::get_property_default('country') ?: '');
$mform->addElement('select', 'country', get_string('selectacountry'), $choices);
if (empty($CFG->country)) {
$mform->setDefault('country', $templateuser->country);
} else {
$mform->setDefault('country', core_user::get_property_default('country'));
}
$mform->setAdvanced('country'); $mform->setAdvanced('country');
$choices = core_date::get_list_of_timezones($templateuser->timezone, true); $mform->addElement('select', 'timezone', get_string('timezone'), core_date::get_list_of_timezones(null, true));
$mform->addElement('select', 'timezone', get_string('timezone'), $choices); $mform->setDefault('timezone', core_user::get_property_default('timezone'));
$mform->setDefault('timezone', $templateuser->timezone);
$mform->setAdvanced('timezone'); $mform->setAdvanced('timezone');
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations()); $mform->addElement('select', 'lang', get_string('preferredlanguage'), core_user::get_property_choices('lang'));
$mform->setDefault('lang', $templateuser->lang); $mform->setDefault('lang', core_user::get_property_default('lang'));
$mform->setAdvanced('lang'); $mform->setAdvanced('lang');
$editoroptions = array('maxfiles'=>0, 'maxbytes'=>0, 'trusttext'=>false, 'forcehttps'=>false); $editoroptions = array('maxfiles'=>0, 'maxbytes'=>0, 'trusttext'=>false, 'forcehttps'=>false);
@ -313,25 +299,23 @@ class admin_uploaduser_form2 extends moodleform {
$mform->setForceLtr('idnumber'); $mform->setForceLtr('idnumber');
$mform->addElement('text', 'institution', get_string('institution'), 'maxlength="255" size="25"'); $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="255" size="25"');
$mform->setType('institution', PARAM_TEXT); $mform->setType('institution', core_user::get_property_type('institution'));
$mform->setDefault('institution', $templateuser->institution);
$mform->addElement('text', 'department', get_string('department'), 'maxlength="255" size="25"'); $mform->addElement('text', 'department', get_string('department'), 'maxlength="255" size="25"');
$mform->setType('department', PARAM_TEXT); $mform->setType('department', core_user::get_property_type('department'));
$mform->setDefault('department', $templateuser->department);
$mform->addElement('text', 'phone1', get_string('phone1'), 'maxlength="20" size="25"'); $mform->addElement('text', 'phone1', get_string('phone1'), 'maxlength="20" size="25"');
$mform->setType('phone1', PARAM_NOTAGS); $mform->setType('phone1', core_user::get_property_type('phone1'));
$mform->setAdvanced('phone1'); $mform->setAdvanced('phone1');
$mform->setForceLtr('phone1'); $mform->setForceLtr('phone1');
$mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"'); $mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"');
$mform->setType('phone2', PARAM_NOTAGS); $mform->setType('phone2', core_user::get_property_type('phone2'));
$mform->setAdvanced('phone2'); $mform->setAdvanced('phone2');
$mform->setForceLtr('phone2'); $mform->setForceLtr('phone2');
$mform->addElement('text', 'address', get_string('address'), 'maxlength="255" size="25"'); $mform->addElement('text', 'address', get_string('address'), 'maxlength="255" size="25"');
$mform->setType('address', PARAM_TEXT); $mform->setType('address', core_user::get_property_type('address'));
$mform->setAdvanced('address'); $mform->setAdvanced('address');
// Next the profile defaults // Next the profile defaults