function user_import_add_form in User Import 7.3
Same name and namespace in other branches
- 8 user_import.admin.inc \user_import_add_form()
- 5.2 user_import.module \user_import_add_form()
- 5 user_import.module \user_import_add_form()
- 6.4 user_import.admin.inc \user_import_add_form()
- 6.2 user_import.admin.inc \user_import_add_form()
- 7 user_import.admin.inc \user_import_add_form()
- 7.2 user_import.admin.inc \user_import_add_form()
Start new import. Form to select file.
1 string reference to 'user_import_add_form'
File
- ./
user_import.admin.inc, line 406 - Provide administration configuration pages to import users.
Code
function user_import_add_form($import_id = NULL) {
$form = array();
$ftp_files = array();
if (variable_get('user_import_selectable_files', 0) == 1) {
$ftp_files = _user_import_ftp_files();
}
$form['browser'] = array(
'#type' => 'fieldset',
'#title' => t('Browser Upload'),
'#collapsible' => TRUE,
'#description' => t("Upload a CSV file."),
);
if (function_exists('file_upload_max_size')) {
$file_size = t('Maximum file size: @size.', array(
'@size' => format_size(file_upload_max_size()),
));
}
$form['browser']['file_upload'] = array(
'#type' => 'file',
'#title' => t('CSV File'),
'#size' => 40,
'#description' => check_plain(t('Select the CSV file to be imported.') . ' ' . $file_size),
);
if (!empty($ftp_files)) {
$form['ftp'] = array(
'#type' => 'fieldset',
'#title' => t('FTP Upload'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t("Any files uploaded to the 'user_import' directory using FTP can be selected for import here. Useful if the import file is too large for upload via the browser."),
);
$form['ftp']['file_ftp'] = array(
'#type' => 'radios',
'#title' => t('Files'),
'#default_value' => '0',
'#options' => $ftp_files,
);
// reload the page to show any files that have been added by FTP
$form['ftp']['scan'] = array(
'#type' => 'submit',
'#value' => t('Check for new files'),
'#validate' => array(),
'#submit' => array(),
);
}
$form['file_settings'] = array(
'#type' => 'fieldset',
'#title' => t('File Settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#description' => t("File column delimiter"),
);
$form['file_settings']['delimiter'] = array(
'#type' => 'textfield',
'#title' => t('Delimiter'),
'#size' => 4,
'#default_value' => variable_get('user_import_delimiter', ','),
'#required' => TRUE,
'#description' => t("The column delimiter for the file. Use '/t' for Tab."),
);
$form['file_settings']['encoding'] = array(
'#type' => 'select',
'#title' => t('Character Encoding'),
'#options' => array(
'UTF-8' => t('UTF-8'),
'Windows-1252' => t('Windows-1252'),
),
'#default_value' => variable_get('user_import_encoding', 'UTF-8'),
'#required' => TRUE,
'#description' => t('Select the encoding used in the file.'),
);
$settings = _user_import_settings_select(NULL, TRUE);
if ($settings) {
$saved_settings = array(
t('-- none --'),
);
foreach ($settings as $settings_set) {
$saved_settings[$settings_set['import_id']] = $settings_set['name'];
}
$form['import_template_select'] = array(
'#type' => 'select',
'#title' => t('Saved Settings'),
'#description' => t('Select if you want to use a previously saved set of settings.'),
'#default_value' => variable_get('user_import_settings', 0),
'#options' => $saved_settings,
);
}
$form['next'] = array(
'#type' => 'submit',
'#value' => t('Next'),
);
// Set form parameters so we can accept file uploads.
$form['#attributes'] = array(
'enctype' => 'multipart/form-data',
);
return $form;
}