MDL-17151: Missing code to check for uniqueness of values.

Merged from MOODLE_19_STABLE
This commit is contained in:
ikawhero
2008-11-07 05:57:24 +00:00
parent 339ef4c246
commit 35a261eb6d
2 changed files with 11 additions and 2 deletions
+1
View File
@@ -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
View File
@@ -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;
}
/**