You are here

function _user_import_file in User Import 6.2

Same name and namespace in other branches
  1. 8 user_import.admin.inc \_user_import_file()
  2. 5.2 user_import.module \_user_import_file()
  3. 5 user_import.module \_user_import_file()
  4. 6.4 user_import.admin.inc \_user_import_file()
  5. 7.3 user_import.admin.inc \_user_import_file()
  6. 7 user_import.admin.inc \_user_import_file()
  7. 7.2 user_import.admin.inc \_user_import_file()
2 calls to _user_import_file()
user_import_add_form_submit in ./user_import.admin.inc
user_import_add_form_validate in ./user_import.admin.inc

File

./user_import.admin.inc, line 655
Provide administration configuration pages to import users.

Code

function _user_import_file($import_id = NULL, $ftp_file_selected = NULL) {
  static $file;
  if (!empty($file)) {
    return $file;
  }

  // file was uploaded through browser
  $file = file_save_upload('file_upload');
  if (!empty($file)) {
    return $file;
  }

  // file was uploaded by FTP
  if (!empty($ftp_file_selected)) {
    $ftp_files = _user_import_ftp_files();
    $filepath = drupal_get_path('module', 'user_import');
    $filename = $ftp_files[$ftp_file_selected];
    $file = new stdClass();
    $file->filepath = "{$filepath}/{$filename}";
    $file->filename = $filename;
    return $file;
  }

  // use file info stored in database
  if (!empty($import_id)) {
    $import = _user_import_settings_select($import_id);
    $file->filepath = $import['filepath'];
    $file->oldfilename = $import['oldfilename'];
    $file->filename = $import['filename'];
    return $file;
  }
  return;
}