You are here

function regcode_ie_admin_import_validate in Registration codes 7

Same name and namespace in other branches
  1. 6.2 regcode_ie/regcode_ie.module \regcode_ie_admin_import_validate()
  2. 7.2 regcode_ie/regcode_ie.module \regcode_ie_admin_import_validate()

Validate import form.

File

regcode_ie/regcode_ie.module, line 125
Import and export functionality for regcode module.

Code

function regcode_ie_admin_import_validate($form, &$form_state) {
  variable_set('regcode_ie_delimiter', $form_state['values']['regcode_import_delimiter']);
  variable_set('regcode_ie_enclosure', $form_state['values']['regcode_import_enclosure']);
  variable_set('regcode_ie_fieldorder', $form_state['values']['regcode_import_fieldorder']);

  // Validators for file.
  $validators = array(
    'file_validate_extensions' => array(
      'csv',
      'txt',
    ),
  );

  // Save the file.
  if ($file = file_save_upload('regcode_import_file', $validators)) {
    $form_state['values']['fileobj'] = $file;
    drupal_set_message(t('File successfully saved'));
  }
  else {
    form_set_error('regcode_import_file', t('Unable to parse CSV file'));
    return FALSE;
  }
}