=== modified file 'modules/system/system.install'
--- modules/system/system.install	2009-08-28 20:00:03 +0000
+++ modules/system/system.install	2009-08-29 10:28:13 +0000
@@ -2459,6 +2459,126 @@
 }
 
 /**
+ * Change profile.module fields into Field API fields.
+ */
+function system_update_7061() {
+  $ret = array();
+  $fields = array();
+  
+  if (!db_table_exists('profile_field')) {
+    return $ret;
+  }
+  // Get all profile fields.
+  $old_fields = db_query('SELECT * FROM {profile_field} ORDER BY category, weight');
+
+  foreach ($old_fields as $old_field) {
+    // Create new fields using the field API.
+    $field = array(
+      'field_name' => strtolower(str_replace('-', '_', $old_field->name)),
+    );
+
+    // Create field instance on the user bundle.
+    $instance = array(
+      'field_name' => $field['field_name'],
+      'bundle' => 'user',
+      'description' => $old_field->explanation,
+      'label' => $old_field->title,
+      'required' => $old_field->required,
+      'widget' => array(
+        'weight' => $old_field->weight,
+      ),
+      'display' => array(
+        'full' => array(
+          'weight' => $old_field->weight,
+        ),
+      ),
+    );
+
+    switch ($old_field->type) {
+      case 'textfield':
+        $field['type'] = 'text';
+        $instance['widget']['type'] = 'text_textfield';
+
+        // Only allow plain text.
+        $instance['settings']['text_processing'] = 0;
+        break;
+
+      case 'textarea':
+        $field['type'] = 'text_long';
+        $instance['widget']['type'] = 'text_textarea';
+        // Use the default text format.
+        $instance['settings']['text_processing'] = variable_get('filter_default_format', 1);
+        break;
+
+      case 'checkbox':
+        $field['type'] = 'list_boolean';
+        $instance['widget']['type'] = 'options_onoff';
+        $field['settings']['allowed_values'] = "0\n1|" . $old_field->title;
+        break;
+
+      case 'selection':
+        $field['type'] = 'list_text';
+        $instance['widget']['type'] = 'options_select';
+        $field['settings']['allowed_values'] = $old_field->options;
+        break;
+
+      case 'list':
+        $field['type'] = 'text';
+        $field['cardinality'] = FIELD_CARDINALITY_UNLIMITED;
+        break;
+
+      case 'date':
+        $ret[] = array('success' => TRUE, 'query' => 'To migrate date fields from the profile module, install the <a href="http://drupal.org/project/date">date</a> module.');        
+        continue 2;
+        
+      case 'url':
+        $ret[] = array('success' => TRUE, 'query' => 'To migrate URL fields from the profile module, install the <a href="http://drupal.org/project/link">link</a> module.');
+        continue 2;
+    }
+
+    try {
+      field_create_field($field);
+      field_create_instance($instance);
+      $fields[$old_field->fid] = $field;
+    }
+    catch (Exception $e) {
+      $ret[] = array('success' => FALSE, 'query' => t('There was a problem creating field %label: @message.', array('%label' => $instance['label'], '@message' => $e->getMessage())));
+    }
+  }
+
+  // Get old field values from the profile.module table.
+  $results = db_query('SELECT uid, fid, value FROM {profile_value} WHERE value IS NOT NULL');
+
+  $accounts = array();
+  foreach ($results as $result) {
+    $field_name = $fields[$result->fid]['field_name'];
+    $accounts[$result->uid]['uid'] = $result->uid;
+    
+    if ($fields[$result->fid]['type'] == 'text' && $fields[$result->fid]['cardinality'] == FIELD_CARDINALITY_UNLIMITED) {
+      $values = array_filter(array_map('trim', preg_split("/[,\n\r]/", $result->value)));
+      $delta = 0;
+      foreach ($values as $value) {
+        $accounts[$result->uid][$field_name][FIELD_LANGUAGE_NONE][$delta]['value'] = $value;
+        $delta++;
+      }
+    }
+    else {
+      $accounts[$result->uid][$field_name][FIELD_LANGUAGE_NONE][0]['value'] = $result->value;
+    }
+  }
+
+  // Set new field values using the field API.
+  foreach ($accounts as $account) {
+    $account = (object) $account;
+    field_attach_update('user', $account);
+  }
+    
+  $ret[] = array('success' => TRUE, 'query' => 'The profile module has been replaced by the new Fields UI. For additional functionality such as adding fields to the registration form, install the <a href="http://drupal.org/project/retro_profile">Retro Profile</a> module.');
+  
+  return $ret; 
+}
+
+/**
  * @} End of "defgroup updates-6.x-to-7.x"
  * The next series of updates should start at 8000.
  */

