Index: field_file.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield/field_file.inc,v
retrieving revision 1.32
diff -u -r1.32 field_file.inc
--- field_file.inc	12 Apr 2009 21:22:17 -0000	1.32
+++ field_file.inc	28 Apr 2009 03:56:55 -0000
@@ -100,6 +100,12 @@
 /**
  * Save a file into a file node after running all the associated validators.
  *
+ * This function is usually used to move a file from the temporary file
+ * directory to a permanent location. It may be used by import scripts or other
+ * modules that want to save an existing file into the database.
+ *
+ * @param $filepath
+ *   The local file path of the file to be saved.
  * @param $validators
  *   An optional, associative array of callback functions used to validate the
  *   file. The keys are function names and the values arrays of callback
@@ -110,26 +116,22 @@
  * @param $dest
  *   A string containing the directory $source should be copied to. If this is
  *   not provided or is not writable, the temporary directory will be used.
+ * @param $account
+ *   The user account object that should associated with the uploaded file.
  * @return
  *   An array containing the file information, or 0 in the event of an error.
  */
-function field_file_save_file($filepath, $validators = array(), $dest = FALSE) {
-  global $user;
+function field_file_save_file($filepath, $validators = array(), $dest = FALSE, $account = NULL) {
+  if (!isset($account)) {
+    $account = $GLOBALS['user'];
+  }
 
   // Add in our check of the the file name length.
   $validators['file_validate_name_length'] = array();
 
-  // Build the list of non-munged extensions.
-  // @todo: this should not be here. we need to figure out the right place.
-  $extensions = '';
-  foreach ($user->roles as $rid => $name) {
-    $extensions .= ' '. variable_get("upload_extensions_$rid",
-    variable_get('upload_extensions_default', 'jpg jpeg gif png txt html doc xls pdf ppt pps odt ods odp'));
-  }
-
   // Begin building file object.
   $file = new stdClass();
-  $file->uid = $user->uid;
+  $file->uid = $account->uid;
   $file->filename = basename($filepath);
   $file->filepath = $filepath;
   $file->filemime = module_exists('mimedetect') ? mimedetect_mime($file) : file_get_mimetype($file->filename);
