diff -ur ../files/deadwood/file_import/file_import.info file_import/file_import.info
--- ../files/deadwood/file_import/file_import.info	2008-02-16 04:10:07.000000000 +1300
+++ file_import/file_import.info	2009-04-15 15:18:10.000000000 +1200
@@ -1,14 +1,8 @@
 ; $Id: file_import.info,v 1.1 2008/02/15 01:02:27 neochief Exp $
 name = File Import
 description = Allows batches of files to be imported from a directory on the server.
-dependencies = upload
+dependencies[] = upload
 package = Other
-version = "5.x-1.0"
+version = "6.x-0.1 port of 5.x-1.0 by xurizaemon"
 project = "file_import"
-
-
-; Information added by drupal.org packaging script on 2008-02-15
-version = "5.x-1.0"
-project = "file_import"
-datestamp = "1203088207"
-
+core = 6.x
\ No newline at end of file
diff -ur ../files/deadwood/file_import/file_import.module file_import/file_import.module
--- ../files/deadwood/file_import/file_import.module	2008-02-15 14:02:27.000000000 +1300
+++ file_import/file_import.module	2009-04-15 15:16:23.000000000 +1200
@@ -4,7 +4,7 @@
 /**
  * Implementation of hook_help().
  */
-function file_import_help($section = '') {
+function file_import_help($path, $arg) {
   switch ($section) {
     case 'admin/content/file_import':
       $output = '<p>'. t("Import multiple files and save them as node attachments. The files will be moved from their default location."). '<br/>'
@@ -31,47 +31,41 @@
 /**
  * Implementation of hook_menu().
  */
-function file_import_menu($may_cache) {
+function file_import_menu() {
   $items = array();
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/content/file_import',
-      'title' => t('File import'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('file_import_form'),
-      'access' => user_access('import files'),
-      'type' => MENU_NORMAL_ITEM,
-      'description' => t('Import files from the filesystem.')
-    );
-    $items[] = array(
-      'path' => 'admin/settings/file_import',
-      'title' => t('File import'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('file_import_admin_settings'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
-      'description' => t('Change settings for the File Import module.')
-    );
-    $items['file_import/js'] = array(
-      'page callback' => 'file_import_js',
-      'access arguments' => array('import files'),
-      'type' => MENU_CALLBACK,
-    );
-  }
-  else
-  {
-    if ((variable_get('file_import_tab', FALSE))&&(arg(0) == 'node' && is_numeric(arg(1)))) {
-      $node = node_load(arg(1));
-      if ((file_import_access_for_node($node))&&($node->nid)) {
-        $items[] = array(
-          'path' => 'node/'. arg(1). '/file_import',
-          'title' => t('File import'),
-          'callback' => 'drupal_get_form',
-          'callback arguments' => array('file_import_form'),
-          'access' => user_access('import files'),
-          'type' => MENU_LOCAL_TASK,
-          'weight' => 5);
-      }
+  // these entries were cached
+  $items['admin/content/file_import'] = array(
+    'title' => 'File import',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('file_import_form'),
+    'access arguments' => array('import files'),
+    'type' => MENU_NORMAL_ITEM,
+    'description' => 'Import files from the filesystem.'
+  );
+  $items['admin/settings/file_import'] = array(
+    'title' => 'File import',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('file_import_admin_settings'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+    'description' => 'Change settings for the File Import module.'
+  );
+  $items['file_import/js'] = array(
+    'page callback' => 'file_import_js',
+    'access arguments' => array('import files'),
+    'type' => MENU_CALLBACK,
+  );
+  // this entry was not
+  if ((variable_get('file_import_tab', FALSE))&&(arg(0) == 'node' && is_numeric(arg(1)))) {
+    $node = node_load(arg(1));
+    if ((file_import_access_for_node($node))&&($node->nid)) {
+      $items['node/%/file_import'] = array(
+        'title' => 'File import',
+        'page callback' => 'drupal_get_form',
+        'page arguments' => array('file_import_form'),
+        'access arguments' => array('import files'),
+        'type' => MENU_LOCAL_TASK,
+        'weight' => 5);
     }
   }
 
@@ -98,7 +92,6 @@
   ksort($files);
 
   if ($files) {
-
     // Put the image files into an array for the checkboxes and gather
     // additional information like dimensions and filesizes. Make sure that
     // there's no 0th element, because a checkbox with a zero value is seen as
@@ -155,17 +148,24 @@
       '#options' => $filelist,
     );
     
-
-
-    // Getting list of node ID's to pot them into the combo box
+    // Getting list of node ID's to put them into the combo box
+    //
+    // TODO: this would be pretty crazy on a site with a significant number of nodes! 
+    // how about Drupal6's nice type-to-select-node element?
     $types = node_get_types();
     $only_with_uploads = variable_get("only_with_uploads",TRUE);
     $allowed_types = array();
-    foreach ($types as $type){
-        if ((!$only_with_uploads)||(variable_get("upload_$type->type", $only_with_upload))) {
-            $allowed_types[] = "'".$type->type."'";
-        }
+    foreach ($types as $type) {
+      // in D6, variable_get('upload_$node_type') may not return 1 when the content type has
+      // not yet been edited, so this test needed reversing from the D5 version
+      if ((!$only_with_uploads)||!(variable_get("upload_$type->type", $only_with_upload)==0)) {
+        // TODO: suspect this could maybe be done better with DB api? 
+        //       this is imploded in a few lines
+        $allowed_types[] = "'".$type->type."'";
+      }
     }
+
+    $nids = array() ;
     if ($allowed_types)
     {
         $result = db_query(db_rewrite_sql("SELECT {node}.nid, {node}.title FROM {node} where type in (".implode(',',$allowed_types).") ORDER BY {node}.created DESC"));
@@ -175,32 +175,33 @@
         }
     }
 
-
-    $form['node_select'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Target node'),
-      '#collapsible' => TRUE,
-      '#collapsed' => FALSE,
-      '#weight' => -4,
-      '#attributes' => array('id' => 'target_node'),
-      '#description' => t('You can set target node to a bunch of selected files at once.').'<br/>'.t(' Select node from list below and press button to set the values.')
-    );
-    if ($default_nid) $form['node_select']['#collapsed'] = TRUE;
-
-    $form['node_select']['combobox'] = array(
-      '#type' => 'select',
-      '#options' => $nids,
-      '#default_value' => $default_nid,
-      '#weight' => -4,
-      '#id' => 'node_select_combo',
-      '#description' => t('ID - Title'),
-      
-    );
-    $form['node_select']['button'] = array(
-      '#type' => 'button',
-      '#value' => t('Set for selected rows'),
-      '#id' => 'node_select_button'
-    );
+    if ( !empty( $nids ) ) {
+      $form['node_select'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Target node'),
+        '#collapsible' => TRUE,
+        '#collapsed' => FALSE,
+        '#weight' => -4,
+        '#attributes' => array('id' => 'target_node'),
+        '#description' => t('You can set target node to a bunch of selected files at once.').'<br/>'.t(' Select node from list below and press button to set the values.')
+      );
+      if ($default_nid) $form['node_select']['#collapsed'] = TRUE;
+  
+      $form['node_select']['combobox'] = array(
+        '#type' => 'select',
+        '#options' => $nids,
+        '#default_value' => $default_nid,
+        '#weight' => -4,
+        '#id' => 'node_select_combo',
+        '#description' => t('ID - Title'),
+        
+      );
+      $form['node_select']['button'] = array(
+        '#type' => 'button',
+        '#value' => t('Set for selected rows'),
+        '#id' => 'node_select_button'
+      );
+    }
     
     $form['edit_titles'] = array(
       '#type' => 'fieldset',
@@ -329,7 +330,7 @@
 }
 
 /**
- * Checks if has acces to import files in node
+ * Checks if has access to import files in node
  */
 function file_import_access_for_node($node){
 	$only_with_uploads = variable_get("only_with_uploads",TRUE);
@@ -337,8 +338,14 @@
 }
 
 
-function file_import_form_submit($form_id, $form_values) {
-  $op = isset($form_values['op']) ? $form_values['op'] : '';
+function file_import_form_submit($form, &$form_state) {
+/* TODO The 'op' element in the form values is deprecated.
+   Each button can have #validate and #submit functions associated with it.
+   Thus, there should be one button that submits the form and which invokes
+   the normal form_id_validate and form_id_submit handlers. Any additional
+   buttons which need to invoke different validate or submit functionality
+   should have button-specific functions. */
+  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
   if ($op == t('Import')) {
     $dirpath = variable_get('file_import_path', '');
     if (file_check_directory($dirpath)) {
@@ -346,15 +353,16 @@
       $list = variable_get('upload_list_default', TRUE);
       //array for node objects
       $nodes = array();
-      foreach (array_filter($form_values['import_file']) as $index) {
+      foreach (array_filter($form_state['values']['import_file']) as $index) {
         //current nid
-        $node_index = $form_values['node'][$index];
+        $node_index = $form_state['values']['node'][$index];
         if (is_numeric($node_index))
         {
           //fill aray of objects or skip if something wrong with a node
-          
-          if ((!$nodes[$node_index])&&($n = node_load($node_index))&&(file_import_access_for_node($n)))
+          if ((!$nodes[$node_index])&&($n = node_load($node_index))&&(file_import_access_for_node($n))) {
             $nodes[$node_index] = $n;
+          }
+  
           //check if we have that node, if no - skip
           if ($nodes[$node_index])
           {
@@ -365,7 +373,7 @@
             if (!ini_get('safe_mode')) {
               set_time_limit(0);
             }
-            $origname = $form_values['file_list'][$index];
+            $origname = $form_state['values']['file_list'][$index];
             $filename = file_check_location($dirpath .'/'. $origname, $dirpath);
             $new_filename = variable_get('file_import_output_path', file_directory_path()).'/'. $origname;
             
@@ -383,23 +391,31 @@
 
             if (file_move($filename, $new_filename, FILE_EXISTS_RENAME))
             {
-              $fid = db_next_id('{files}_fid'); // best way?
-              db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)",
-                $fid, 
-                $nid,
+              db_query("INSERT INTO {files} (filename, filepath, filemime, filesize, status, timestamp) VALUES ('%s', '%s', '%s', %d, %d, %d)",
                 $origname,
                 $new_filename,
                 content_type($filename),
-                filesize($new_filename));
-
-              db_query("INSERT INTO {file_revisions} (fid, vid, description, list) VALUES (%d, %d, '%s', %d)",
-                $fid, 
-                $vid, 
-                $form_values['title'][$index],
-                $list);
-                $i++;
+                filesize($new_filename),
+                1, // status (1 = permanent, 0=temporary)
+                time());
+              if ( !db_error() ) {
+                $fid = db_last_insert_id('files','fid');
+                db_query("INSERT INTO {upload} (fid, vid, description, list) VALUES (%d, %d, '%s', %d)",
+                  $fid, 
+                  $vid, 
+                  $form_state['values']['title'][$index],
+                  $list);
+                  $i++;
+              } else {
+                drupal_set_message('Move failed') ;
+              }
             }
+            
+          } else {
+            drupal_set_message( t("Failed to attach files to node !nid", array( '!nid' => $nid ) ), 'error' ) ;
           }
+        } else {
+          drupal_set_message( t("Node ID '!nid' is not numeric", array( '!nid' => $nid ) ), 'error' ) ;          
         }
       }
       // report back on our progress
@@ -407,7 +423,7 @@
         drupal_set_message(t('Successfully imported %count', array('%count' => format_plural($i, '1 file', '@count files'))));
       }
       else {
-        drupal_set_message(t('No files files were imported.'));
+        drupal_set_message(t('No files were imported.'));
       }
     }
   }
@@ -484,3 +500,14 @@
   variable_set('file_import_tab', $form_element['#value']);
   return $form_element;
 }
+
+function file_import_theme() {
+  return array(
+    'file_import_form' => array(
+      'file' => 'file_import.module',
+      'arguments' => array(
+        'form' => NULL,
+      ),
+    ),
+  );
+}
\ No newline at end of file
Only in ../files/deadwood/file_import: po
Only in file_import/: translations
