Skip to content

Commit

Permalink
Check to ensure custom profile fields do not have same name as current
Browse files Browse the repository at this point in the history
fields in the $USER record
  • Loading branch information
ikawhero committed Oct 8, 2007
1 parent 4baf254 commit cfdb170
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions user/profile/definelib.php
Expand Up @@ -93,6 +93,8 @@ function define_validate($data) {
* @return array associative array of error messages * @return array associative array of error messages
*/ */
function define_validate_common($data) { function define_validate_common($data) {
global $USER;

$err = array(); $err = array();


/// Check the shortname was not truncated by cleaning /// Check the shortname was not truncated by cleaning
Expand All @@ -102,6 +104,10 @@ function define_validate_common($data) {
/// Check the shortname is unique /// Check the shortname is unique
} else if (($field = get_record('user_info_field', 'shortname', $data->shortname)) and ($field->id <> $data->id)) { } else if (($field = get_record('user_info_field', 'shortname', $data->shortname)) and ($field->id <> $data->id)) {
$err['shortname'] = get_string('profileshortnamenotunique', 'admin'); $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 /// No further checks necessary as the form class will take care of it
Expand Down

0 comments on commit cfdb170

Please sign in to comment.