Skip to content

Commit

Permalink
MDL-17151: Missing code to check for uniqueness of values.
Browse files Browse the repository at this point in the history
Merged from MOODLE_19_STABLE
  • Loading branch information
ikawhero committed Nov 7, 2008
1 parent 339ef4c commit 35a261e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions lang/en_utf8/moodle.php
Expand Up @@ -1602,6 +1602,7 @@
$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';
Expand Down
12 changes: 10 additions & 2 deletions user/profile/lib.php
Expand Up @@ -110,8 +110,16 @@ function edit_save_data($usernew) {
* @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;
}

/**
Expand Down

0 comments on commit 35a261e

Please sign in to comment.