MDL-8096 - added proper trimming of usernames; site:config capability is now neede to change definition of custom profile fields

This commit is contained in:
skodak 2007-01-26 16:19:33 +00:00
parent a5d3b07224
commit 04f639a0f4
2 changed files with 9 additions and 3 deletions

View File

@ -69,6 +69,7 @@
$authplugin = get_auth_plugin($usernew->auth);
}
$usernew->username = trim($usernew->username);
$usernew->timemodified = time();
if ($usernew->id == -1) {

View File

@ -93,10 +93,15 @@ class user_editadvanced_form extends moodleform {
global $CFG;
$usernew = (object)$usernew;
$user = get_record('user', 'id', $usernew->id);
$err = array();
$usernew->username = trim($usernew->username);
if (!$user or $user->username !== $usernew->username) {
$user = get_record('user', 'id', $usernew->id);
$err = array();
if (empty($usernew->username)) {
//might be only whitespace
$err['username'] = get_string('required');
} else if (!$user or $user->username !== $usernew->username) {
//check new username does not exist
if (record_exists('user', 'username', $usernew->username, 'mnethostid', $CFG->mnet_localhost_id)) {
$err['username'] = get_string('usernameexists');