function _user_import_file in User Import 7
Same name and namespace in other branches
- 8 user_import.admin.inc \_user_import_file()
- 5.2 user_import.module \_user_import_file()
- 5 user_import.module \_user_import_file()
- 6.4 user_import.admin.inc \_user_import_file()
- 6.2 user_import.admin.inc \_user_import_file()
- 7.3 user_import.admin.inc \_user_import_file()
- 7.2 user_import.admin.inc \_user_import_file()
2 calls to _user_import_file()
File
- ./
user_import.admin.inc, line 790 - 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.
if (empty($ftp_file_selected) && empty($import_id)) {
// Delete record from database management so we don't have duplicates problems.
db_delete('file_managed')
->condition('uri', 'temporary://' . $_FILES['files']['name']['file_upload'])
->execute();
$file = file_save_upload('file_upload', array(
'file_validate_extensions' => array(
'csv txt',
),
), FALSE, FILE_EXISTS_RENAME);
if (!empty($file)) {
return $file;
}
}
// File was uploaded by FTP
if (!empty($ftp_file_selected)) {
$ftp_files = file_scan_directory('private://user_import/uploads/selectable', '/.*$/', array(
'key' => 'filename',
));
$file = $ftp_files[$ftp_file_selected];
$file->filepath = $file->uri;
return $file;
}
// Use file info stored in database
if (!empty($import_id)) {
$import = _user_import_settings_select($import_id);
$file->uri = $import['filepath'];
$file->filepath = $import['filepath'];
$file->oldfilename = $import['oldfilename'];
$file->filename = $import['filename'];
return $file;
}
return;
}