Permalink
Browse files

Check to ensure custom profile fields do not have same name as current

fields in the $USER record
  • Loading branch information...
ikawhero
ikawhero committed Oct 8, 2007
1 parent 4baf254 commit cfdb1706091748a9a0c369d2aaa3abb6a463fbc6
Showing with 6 additions and 0 deletions.
  1. +6 −0 user/profile/definelib.php
@@ -93,6 +93,8 @@ function define_validate($data) {
* @return array associative array of error messages
*/
function define_validate_common($data) {
+ global $USER;
+
$err = array();
/// Check the shortname was not truncated by cleaning
@@ -102,6 +104,10 @@ function define_validate_common($data) {
/// Check the shortname is unique
} else if (($field = get_record('user_info_field', 'shortname', $data->shortname)) and ($field->id <> $data->id)) {
$err['shortname'] = get_string('profileshortnamenotunique', 'admin');
+
+ /// Shortname must also be unique compared to the standard user fields
+ } else if (isset($USER->{$data->shortname})) {
+ $err['shortname'] = get_string('profileshortnamenotunique', 'admin');
}
/// No further checks necessary as the form class will take care of it

0 comments on commit cfdb170

Please sign in to comment.