function uif_import_form in User Import Framework 6
Same name and namespace in other branches
- 7 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 10 - Simple, extensible user import from a CSV file.
Code
function uif_import_form(&$form_state) {
// Cause return to beginning if we just completed an import
if ($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(
'#prefix' => '<div id="uif_form_help">',
'#suffix' => '</div>',
'#value' => 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,
);
$preview_count = drupal_map_assoc(array(
0,
1,
10,
100,
1000,
10000,
9999999,
));
$preview_count[0] = t('None - just do it');
$preview_count[9999999] = t('Preview all');
$form['preview_count'] = array(
'#type' => 'select',
'#title' => t('Users to preview'),
'#default_value' => 10,
'#options' => $preview_count,
'#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'),
'#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(
'#prefix' => '<div id="uif_form_instructions">',
'#suffix' => '</div>',
'#value' => t('Preview these records and when ready to import click Import users.'),
);
$form['user_preview'] = array(
'#prefix' => '<div id="uif_user_preview">',
'#suffix' => '</div>',
'#value' => $form_state['storage']['user_preview'],
);
$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;
}