Merge branch 'MDL-80605-master' of https://github.com/jbs1/moodle

This commit is contained in:
Sara Arjona 2024-02-21 16:19:11 +01:00
commit 617442dc16
No known key found for this signature in database
3 changed files with 34 additions and 0 deletions

View File

@ -688,6 +688,17 @@ class process {
break;
case UU_USER_ADD_UPDATE:
if ($this->get_match_on_email()) {
if ($usersbyname = $DB->get_records('user', ['username' => $user->username])) {
foreach ($usersbyname as $userbyname) {
if (strtolower($userbyname->email) != strtolower($user->email)) {
$this->usersskipped++;
$this->upt->track('status', get_string('usernotaddedusernameexists', 'error'), 'warning');
$skip = true;
}
}
}
}
break;
case UU_USER_UPDATE:

View File

@ -296,3 +296,25 @@ Feature: Upload users
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I should see "Bilbo Baggins"
And I should not see "Frodo Baggins"
@javascript
Scenario: Create a new user when matching them on email where where the username already exists
Given the following "users" exist:
| username | firstname | lastname | email |
| bilbob | Samwise | Gamgee | samwise@example.com |
| frodob | Frodeo | Baspins | frodo@example.com |
And I log in as "admin"
And I navigate to "Users > Accounts > Upload users" in site administration
When I upload "lib/tests/fixtures/upload_users_email_matching.csv" file to "File" filemanager
And I press "Upload users"
Then I should see "Upload users preview"
And I set the following fields to these values:
| Upload type | Add new and update existing users |
| Existing user details | Override with file |
| Match on email address | Yes |
And I press "Upload users"
And I should see "User not added - username already exists under a different email"
And I press "Continue"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I should see "Samwise Gamgee"
And I should see "Frodo Baggins"

View File

@ -613,6 +613,7 @@ $string['usermustbemnet'] = 'Users in the MNET access control list must be remot
$string['usernamelowercase'] = 'The username must be in lower case';
$string['usernotaddederror'] = 'User not added - error';
$string['usernotaddedregistered'] = 'User not added - already registered';
$string['usernotaddedusernameexists'] = 'User not added - username already exists under a different email';
$string['usernotavailable'] = 'The details of this user are not available to you';
$string['usernotdeletedadmin'] = 'User not deleted as administrator accounts cannot be deleted.';
$string['usernotdeleteddeleted'] = 'This user has already been deleted.';