function uif_import_form in User Import Framework 7
Same name and namespace in other branches
- 6 uif.admin.inc \uif_import_form()
User import multi-part form.
1 string reference to 'uif_import_form'
- uif_menu in ./
uif.module - Implementation of hook_menu().
File
- ./
uif.admin.inc, line 11 - Simple, extensible user import from a CSV file.
Code
function uif_import_form($form, &$form_state) {
// Cause return to beginning if we just completed an import
if (isset($form_state['storage']['step']) && $form_state['storage']['step'] >= 3) {
unset($form_state['storage']);
}
$step = empty($form_state['storage']['step']) ? 1 : $form_state['storage']['step'];
$form_state['storage']['step'] = $step;
switch ($step) {
case 1:
$form['instructions'] = array(
'#type' => 'fieldset',
'#title' => t('User import help'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['instructions']['help'] = array(
'#markup' => theme('uif_form_help'),
);
$file_size_msg = t('Your PHP settings limit the maximum file size per upload to %size. Depending on your server environment, these settings may be changed in the system-wide php.ini file, a php.ini file in your Drupal root directory, in your Drupal site\'s settings.php file, or in the .htaccess file in your Drupal root directory.', array(
'%size' => format_size(file_upload_max_size()),
));
$form['user_upload'] = array(
'#type' => 'file',
'#title' => t('Import file'),
'#size' => 40,
'#description' => t('Select the CSV file to be imported.') . '<br />' . $file_size_msg,
);
$form['field_delimiter'] = array(
'#type' => 'select',
'#title' => t('Field delimiter'),
'#default_value' => variable_get('uif_field_delimiter', ','),
'#options' => uif_field_delimiters(),
'#description' => t('Select field delimiter. Comma is typical for CSV export files.'),
);
$form['value_delimiter'] = array(
'#type' => 'select',
'#title' => t('Value delimiter'),
'#default_value' => variable_get('uif_value_delimiter', '|'),
'#options' => uif_value_delimiters(),
'#description' => t('Select value delimiter for fields receiving multiple values.'),
);
$form['preview_count'] = array(
'#type' => 'select',
'#title' => t('Users to preview'),
'#default_value' => variable_get('uif_users_to_preview', 10),
'#options' => uif_options_users_to_preview(),
'#description' => t('Number of users to preview before importing. Note: If you run out of memory set this lower or increase your memory.'),
);
$form['notify'] = array(
'#type' => 'checkbox',
'#title' => t('Notify new users of account'),
'#default_value' => variable_get('uif_notify', FALSE),
'#description' => t('If checked, each newly created user will receive the <em>Welcome, new user created by administrator</em> email using the template on the <a href="@url1">user settings page</a>. This is the same email sent for <a href="@url2">admin-created accounts</a>.', array(
'@url1' => url('admin/user/settings'),
'@url2' => url('admin/user/user/create'),
)),
);
$form['next'] = array(
'#type' => 'submit',
'#value' => t('Next'),
);
// Set form parameters so we can accept file uploads.
$form['#attributes'] = array(
'enctype' => 'multipart/form-data',
);
break;
case 2:
$form['instructions'] = array(
'#markup' => t('Preview these records and when ready to import click Import users.'),
'#prefix' => '<div id="uif_form_instructions">',
'#suffix' => '</div>',
);
$form['user_preview'] = array(
'#markup' => $form_state['storage']['user_preview'],
'#prefix' => '<div id="uif_user_preview">',
'#suffix' => '</div>',
);
$form['back'] = array(
'#type' => 'submit',
'#value' => t('Back'),
'#submit' => array(
'uif_import_form_back',
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Import users'),
);
break;
}
return $form;
}