some minor user edit fixes MDL-8096

This commit is contained in:
skodak
2007-01-16 09:56:15 +00:00
parent 6647e04ac9
commit 91866a2631
2 changed files with 15 additions and 9 deletions
+8 -5
View File
@@ -79,8 +79,14 @@
$userform = new user_edit_form(null, compact('user','course','authplugin'));
$userform->set_upload_manager(new upload_manager('imagefile',false,false,null,false,0,true,true));
$userform->set_data($user);
if ($user->username == 'changeme') {
$changeme = new object();
$changeme->id = $user->id;
$changeme->auth = $user->auth;
$userform->set_data($changeme);
} else {
$userform->set_data($user);
}
/// If data submitted, then process and store.
if ($usernew = $userform->get_data()) {
@@ -117,9 +123,6 @@
$usernew->$key = addslashes(clean_text(stripslashes(trim($usernew->$key)), FORMAT_MOODLE));
}
$usernew->firstname = strip_tags($usernew->firstname);
$usernew->lastname = strip_tags($usernew->lastname);
if (isset($usernew->username)) {
$usernew->username = moodle_strtolower($usernew->username);
}
+7 -4
View File
@@ -19,6 +19,7 @@ class user_edit_form extends moodleform {
$userupdate = has_capability('moodle/user:update', $systemcontext);
$strrequired = get_string('required');
$this->set_upload_manager(new upload_manager('imagefile',false,false,null,false,0,true,true));
/// Add some extra hidden fields
$mform->addElement('hidden', 'id');
@@ -59,7 +60,7 @@ class user_edit_form extends moodleform {
$newpasswordgrp[] = &MoodleQuickForm::createElement('text', 'newpassword', '', 'size="20"');
$newpasswordgrp[] = &MoodleQuickForm::createElement('static', 'newpasswordtext', '', '('.get_string('leavetokeep').')');
$mform->addGroup($newpasswordgrp, 'newpasswordgrp', get_string('newpassword'),' ',false);
$mform->setType('newpassword', PARAM_MULTILANG);
$mform->setType('newpassword', PARAM_RAW);
if (!$adminself and $userauth->can_change_password()) {
if (get_user_preferences('auth_forcepasswordchange', NULL, $user->id)) {
@@ -80,11 +81,11 @@ class user_edit_form extends moodleform {
$mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
$mform->setType('firstname', PARAM_MULTILANG);
$mform->setType('firstname', PARAM_NOTAGS);
$mform->addRule('firstname', $strrequired, 'required', null, 'client');
$mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
$mform->setType('lastname', PARAM_MULTILANG);
$mform->setType('lastname', PARAM_NOTAGS);
$mform->addRule('lastname', $strrequired, 'required', null, 'client');
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
@@ -174,10 +175,11 @@ class user_edit_form extends moodleform {
$choices = get_list_of_countries();
$choices[0] = get_string('selectacountry').'...';
$mform->addElement('select', 'country', get_string('selectacountry'), $choices);
$mform->setType('country', PARAM_ALPHA);
$mform->addRule('country', $strrequired, 'required', null, 'client');
if ($CFG->country) {
if (!empty($CFG->country)) {
$mform->setDefault('country', $CFG->country);
}
@@ -188,6 +190,7 @@ class user_edit_form extends moodleform {
} else {
$mform->addElement('select', 'timezone', get_string('timezone'), $choices);
$mform->setType('timezone', PARAM_PATH);
$mform->setDefault('timezone', '99');
}
$choices = array();