Permalink
Browse files

custom profile fields MDL-26177 fields with unique were broken becaus…

…e you cannot use get_field with TEXT columns.
  • Loading branch information...
1 parent 8cdc85a commit 25f44c72bdf3b524cda704ab02d380a5fded69b5 @timhunt timhunt committed Jan 29, 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 25f44c7

Please sign in to comment.