Permalink
Browse files

Merge branch 'MDL-26177' of git://github.com/timhunt/moodle

  • Loading branch information...
2 parents d44d644 + 25f44c7 commit bee34e2b6deb6bb85d2310d1d747fec70be25e6a @skodak skodak committed Jan 31, 2011
Showing with 8 additions and 4 deletions.
  1. +8 −4 user/profile/lib.php
View
@@ -131,10 +131,14 @@ function edit_validate_field($usernew) {
$errors = array();
/// Check for uniqueness of data if required
if ($this->is_unique()) {
- if ($userid = $DB->get_field('user_info_data', 'userid', array('fieldid'=>$this->field->id, 'data'=>$usernew->{$this->inputname}))) {
- if ($userid != $usernew->id) {
- $errors["{$this->inputname}"] = get_string('valuealreadyused');
- }
+ $userid = $DB->get_field_sql('
+ SELECT userid
+ FROM {user_info_data}
+ WHERE fieldid = ?
+ AND ' . $DB->sql_compare_text('data') . ' = ?',
+ array($this->field->id, $usernew->{$this->inputname}));
+ if ($userid && $userid != $usernew->id) {
+ $errors[$this->inputname] = get_string('valuealreadyused');
}
}
return $errors;

0 comments on commit bee34e2

Please sign in to comment.