function uif_import_form_validate in User Import Framework 6
Same name and namespace in other branches
- 7 uif.admin.inc \uif_import_form_validate()
Validate the import data.
File
- ./
uif.admin.inc, line 91 - Simple, extensible user import from a CSV file.
Code
function uif_import_form_validate($form, &$form_state) {
$step = empty($form_state['storage']['step']) ? 1 : $form_state['storage']['step'];
switch ($step) {
case 1:
// Validate the upload file
$validators = array(
'file_validate_extensions' => array(
'csv',
),
'file_validate_size' => array(
file_upload_max_size(),
),
);
if ($user_file = file_save_upload('user_upload', $validators)) {
$errors = uif_validate_user_file($user_file->filepath, $data, $form_state);
if (!empty($errors)) {
form_set_error('user_upload', '<ul><li>' . implode('</li><li>', $errors) . '</li></ul>');
return;
}
}
else {
form_set_error('user_upload', t('Cannot save the import file to temporary storage. Please try again.'));
return;
}
// Save the validated data to avoid reparsing
$form_state['storage']['data'] = $data;
break;
}
}