MDL-17151: Missing code to check for uniqueness of values.
Merged from MOODLE_19_STABLE
This commit is contained in:
@@ -1602,6 +1602,7 @@ $string['usersnoaccesssince'] = 'Inactive for more than';
|
||||
$string['userzones'] = 'User zones';
|
||||
$string['usethiscourse'] = 'Use this course';
|
||||
$string['usingexistingcourse'] = 'Using existing course';
|
||||
$string['valuealreadyused'] = 'This value has already been used.';
|
||||
$string['version'] = 'Version';
|
||||
$string['view'] = 'View';
|
||||
$string['viewfileinpopup'] = 'View file in a popup window';
|
||||
|
||||
+10
-2
@@ -110,8 +110,16 @@ class profile_field_base {
|
||||
* @return string contains error message otherwise NULL
|
||||
**/
|
||||
function edit_validate_field($usernew) {
|
||||
//no errors by default
|
||||
return array();
|
||||
$errors = array();
|
||||
/// Check for uniqueness of data if required
|
||||
if ($this->is_unique()) {
|
||||
if ($userid = get_field('user_info_data', 'userid', 'fieldid', $this->field->id, 'data', $usernew->{$this->inputname})) {
|
||||
if ($userid != $usernew->id) {
|
||||
$errors["{$this->inputname}"] = get_string('valuealreadyused');
|
||||
}
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user