]> git.mjollnir.org Git - moodle.git/commitdiff
Check to ensure custom profile fields do not have same name as current
authorikawhero <ikawhero>
Mon, 8 Oct 2007 06:59:00 +0000 (06:59 +0000)
committerikawhero <ikawhero>
Mon, 8 Oct 2007 06:59:00 +0000 (06:59 +0000)
fields in the $USER record

user/profile/definelib.php

index 8dc42977d6a6ad8433645cf226843133a5f4c3c8..543da4937d57947421343869dd87ccab0db3526d 100644 (file)
@@ -93,6 +93,8 @@ class profile_define_base {
      * @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 @@ class profile_define_base {
         /// 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