Merge branch 'MDL-29317-master' of git://github.com/junpataleta/moodle
This commit is contained in:
@@ -225,8 +225,23 @@ class gradeimport_csv_load_data {
|
||||
$errorkey = false;
|
||||
// The user may use the incorrect field to match the user. This could result in an exception.
|
||||
try {
|
||||
$field = $userfields['field'];
|
||||
// Fields that can be queried in a case-insensitive manner.
|
||||
$caseinsensitivefields = [
|
||||
'email',
|
||||
'username',
|
||||
];
|
||||
// Build query predicate.
|
||||
if (in_array($field, $caseinsensitivefields)) {
|
||||
// Case-insensitive.
|
||||
$select = $DB->sql_equal($field, ':' . $field, false);
|
||||
} else {
|
||||
// Exact-value.
|
||||
$select = "{$field} = :{$field}";
|
||||
}
|
||||
|
||||
// Make sure the record exists and that there's only one matching record found.
|
||||
$user = $DB->get_record('user', array($userfields['field'] => $value), '*', MUST_EXIST);
|
||||
$user = $DB->get_record_select('user', $select, array($userfields['field'] => $value), '*', MUST_EXIST);
|
||||
} catch (dml_missing_record_exception $missingex) {
|
||||
$errorkey = 'usermappingerror';
|
||||
} catch (dml_multiple_records_exception $multiex) {
|
||||
|
||||
@@ -252,6 +252,9 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",[email protected],75.00,,75.00,{exportdat
|
||||
'Fetch by email' => [
|
||||
'email', '[email protected]', true
|
||||
],
|
||||
'Fetch by email, different case' => [
|
||||
'email', '[email protected]', true
|
||||
],
|
||||
'Fetch data using a non-existent email' => [
|
||||
'email', '[email protected]', false
|
||||
],
|
||||
@@ -267,6 +270,9 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",[email protected],75.00,,75.00,{exportdat
|
||||
'Fetch data using a valid username' => [
|
||||
'username', 's1', true
|
||||
],
|
||||
'Fetch data using a valid username, different case' => [
|
||||
'username', 'S1', true
|
||||
],
|
||||
'Fetch data using an invalid username' => [
|
||||
'username', 's2', false
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user