Index: node_import.api.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_import/Attic/node_import.api.inc,v
retrieving revision 1.8.2.1.2.1
diff -u -r1.8.2.1.2.1 node_import.api.inc
--- node_import.api.inc	3 May 2007 07:06:23 -0000	1.8.2.1.2.1
+++ node_import.api.inc	3 May 2007 11:48:50 -0000
@@ -45,7 +45,7 @@
 
   if (!isset($types)) {
     $types = array();
-    foreach ((array) module_invoke_all('node_import_types') as $type => $name) {
+    foreach (module_invoke_all('node_import_types') as $type => $name) {
       $types[$type] = $name;
     }
     asort($types);
Index: node_import.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_import/Attic/node_import.module,v
retrieving revision 1.50.2.3.2.1
diff -u -r1.50.2.3.2.1 node_import.module
--- node_import.module	3 May 2007 07:06:23 -0000	1.50.2.3.2.1
+++ node_import.module	9 May 2007 09:44:21 -0000
@@ -57,14 +57,11 @@
   // Include the API.
   include_once(drupal_get_path('module', 'node_import') . '/node_import.api.inc');
 
-  // Loads the hooks for the supported modules.
+  // Load hooks for supported modules.
   node_import_load_supported();
 
   $edit = array_merge((array)$_SESSION['node_import'], (array)$_POST);
 
-  // This prevents drupal_get_form() from performing extra validation.
-  unset($_POST);
-
   // validate the form
   if ($_SESSION['node_import_page'] && $_POST) {
     $function = $_SESSION['node_import_page'] .'_validate';
@@ -74,10 +71,13 @@
     $_SESSION['node_import_page'] = '_node_import_start';
   }
 
-  // create the new page
+  // This prevents drupal_get_form() from performing extra validation.
+  unset($_POST);
+
+  // Create the new page.
   $output = drupal_get_form($_SESSION['node_import_page'], $edit);
 
-  // save everything back to the session
+  // Save everything back to the session.
   $_SESSION['node_import'] = $edit;
 
   return $output;
@@ -89,10 +89,14 @@
 
 function _node_import_start(&$edit) {
   if ($edit['file']) {
+    $form['file'] = array(
+      '#type' => 'value',
+      '#value' => $edit['file'],
+    );
     $form[] = array(
       '#type' => 'item',
       '#title' => t('File'),
-      '#value' => $edit['filename'] .' ('. format_size($edit['file']->filesize) .')'
+      '#value' => $edit['filename'] .' ('. format_size($edit['file']->filesize) .')',
     );
   }
   else {
@@ -169,7 +173,6 @@
       file_move($file, 'drupal.node_import.'. strtr($base_url, array('http://' => '', '/' => '.')) .'.'. $user->uid, 1);
       $edit['file'] = $file;
     }
-
     if (!$edit['file']) {
       form_set_error('file', t('You must select a file to import.'));
       return;
@@ -280,10 +283,10 @@
 }
 
 function _node_import_mapping_validate($op, &$edit) {
-  if ($op == t('Back')) {
+  if ($edit['op'] == t('Back')) {
     $_SESSION['node_import_page'] = '_node_import_start';
   }
-  else if ($op == t('Next (options)')) {
+  else if ($edit['op'] == t('Next (options)')) {
     $_SESSION['node_import_page'] = '_node_import_options';
   }
 }
@@ -341,10 +344,10 @@
 }
 
 function _node_import_options_validate($op, &$edit) {
-  if ($op == t('Back')) {
+  if ($edit['op'] == t('Back')) {
     $_SESSION['node_import_page'] = '_node_import_mapping';
   }
-  else if ($op == t('Next (preview)')) {
+  else if ($edit['op'] == t('Next (preview)')) {
     $_SESSION['node_import_page'] = '_node_import_preview';
   }
 }
@@ -409,7 +412,7 @@
 }
 
 function _node_import_preview_validate($op, &$edit) {
-  if ($op == t('Back')) {
+  if ($edit['op'] == t('Back')) {
     if ($edit['type'] == 'node_import') {
       $_SESSION['node_import_page'] = '_node_import_start';
     }
@@ -417,10 +420,10 @@
       $_SESSION['node_import_page'] = '_node_import_options';
     }
   }
-  else if ($op == t('Apply (import nodes)')) {
+  else if ($edit['op'] == t('Apply (import nodes)')) {
     $_SESSION['node_import_page'] = '_node_import_import';
   }
-  else if ($op == t('Reload')) {
+  else if ($edit['op'] == t('Reload')) {
     $_SESSION['node_import_page'] = '_node_import_preview';
   }
 }
@@ -457,7 +460,7 @@
 
   if (count($edit['errors']) > 0) {
     $form[] = array(
-      '#type' => 'button',
+      '#type' => 'submit',
       '#value' => t('Download rows with errors'),
     );
   }
@@ -471,14 +474,14 @@
 }
 
 function _node_import_import_validate($op, &$edit) {
-  if ($op == t('Delete CSV file from server')) {
+  if ($edit['op'] == t('Delete file from server')) {
     if (file_delete($edit['file']->filepath)) {
-      drupal_set_message(t('Deleted the CSV file from the server.'));
+      drupal_set_message(t('Deleted the file from the server.'));
     }
     $edit = array();
     $_SESSION['node_import_page'] = '_node_import_start';
   }
-  else if ($op == t('Download rows with errors')) {
+  else if ($edit['op'] == t('Download rows with errors')) {
     $_SESSION['node_import_page'] = '_node_import_errors';
   }
 }
@@ -488,6 +491,9 @@
  ************************************************************/
 
 function _node_import_errors($edit) {
+  if (!isset($edit['errors']) || empty($edit['errors'])) {
+    return;
+  }
   switch ($edit['file_format']) {
     case '_node_import_csv_get_row':
       header('Content-type: text/comma-separated-values');
@@ -601,7 +607,7 @@
           $node->name = $account->name;
         }
         else {
-          $errors[] = t('The username %name does not exist.', array('%name' => theme('placeholder', $node->name)));
+          $errors[] = t('The username %name does not exist.', array('%name' => $node->name));
         }
       }
     }
@@ -638,7 +644,7 @@
     // See if we are allowed to create this node. This is again only for
     // "raw input".
     if (!node_access('create', $node)) {
-      $errors[] = t('You are not authorized to create a node of type %type.', array('%type' => theme('placeholder', node_get_types('name', $node))));
+      $errors[] = t('You are not authorized to create a node of type %type.', array('%type' => node_get_types('name', $node)));
     }
 
     // Ok, we're done. Preview the node or save it (if no errors).
@@ -681,7 +687,7 @@
       drupal_set_message(t("!errors Click 'Download rows with errors' for a CSV file of the failed rows.", array('!errors' => format_plural(count($error_rows), t('There was 1 error.'), t('There were @count errors.')))));
       $error_rows = array_merge(array($header), $error_rows);
     }
-    drupal_set_message(format_plural($success, 'Successfully imported 1 node.', 'Successfully imported @count nodes.'));
+    drupal_set_message(format_plural($success, t('Successfully imported 1 node.'), t('Successfully imported @count nodes.')));
   }
   
   return $output;
Index: supported/cck/content.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_import/supported/cck/Attic/content.inc,v
retrieving revision 1.1.2.2.2.1
diff -u -r1.1.2.2.2.1 content.inc
--- supported/cck/content.inc	3 May 2007 07:06:23 -0000	1.1.2.2.2.1
+++ supported/cck/content.inc	3 May 2007 11:51:41 -0000
@@ -131,14 +131,32 @@
               break;
 
             case 'nodereference':
-              if (($nid = node_import_nodereference($value))) {
-                $value = $nid;
+              // If $value is numeric use it, otherwise
+              // find a node title that matches and get nid.
+              if (intval($value) > 0) {
+                $value = intval($value);
+              }
+              else {
+                $referenced_nodes = array();
+                $sql = "SELECT nid, title FROM {node} WHERE title SOUNDS LIKE '%s'";
+                $result = db_query($sql, $value);
+                $record_found = db_fetch_object($result);
+                if ($record_found) {
+                  $value = $record_found->nid;
+                }
               }
               break;
 
             case 'userreference':
-              if (($uid = node_import_userreference($value))) {
-                $value = $uid;
+              // If $value is numeric use it, otherwise
+              // find a user name that matches and get uid.
+              if (intval($value) > 0) {
+                $value = intval($value);
+              }
+              else {
+                if (($account = user_load(array('name' => $author['name'])))) {
+                  $value = $account->uid;
+                }
               }
               break;
 
@@ -185,14 +203,14 @@
   if (isset($types[$type])) {
     $content_type = $types[$type];
     foreach ($content_type['fields'] as $field) {
-    
       // Create a default value for each field column by creating a dummy name for each column.
       $db_info = content_database_info($field);
       foreach ($db_info['columns'] as $column => $info) {
         $form['content_import_node']['fields'][$field['field_name'] .'_'. $column] = array(
           '#type' => 'textfield',
           '#title' => $field['widget']['label'] .' '. $column,
-          );
+          '#default_value' => $field['widget']['default_value'][0]['value'],
+        );
       }
     }
   }

