mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
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:
parent
a5d3b07224
commit
04f639a0f4
@ -69,6 +69,7 @@
|
||||
$authplugin = get_auth_plugin($usernew->auth);
|
||||
}
|
||||
|
||||
$usernew->username = trim($usernew->username);
|
||||
$usernew->timemodified = time();
|
||||
|
||||
if ($usernew->id == -1) {
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user