You are here

function user_import_edit_validate in User Import 6.2

Same name and namespace in other branches
  1. 8 user_import.admin.inc \user_import_edit_validate()
  2. 6.4 user_import.admin.inc \user_import_edit_validate()
  3. 7.3 user_import.admin.inc \user_import_edit_validate()
  4. 7 user_import.admin.inc \user_import_edit_validate()
  5. 7.2 user_import.admin.inc \user_import_edit_validate()

File

./user_import.admin.inc, line 428
Provide administration configuration pages to import users.

Code

function user_import_edit_validate($form, &$form_state) {
  $email = FALSE;
  $fields = array();
  foreach ($form_state['values']['field_match'] as $row => $values) {

    // check each field is unique
    if ($values['field_match'] != '0' && $values['field_match'] != '-------------' && in_array($values['field_match'], $fields)) {
      form_set_error('field_match', t('Database fields can only be matched to one column of the csv file.'));
    }
    $fields[$values['field_match']] = $values['field_match'];

    // check email address has been selected
    if ($values['field_match'] == 'user-email') {
      $email = TRUE;
    }
  }
  if (!$email) {
    form_set_error('email', t('One column of the csv file must be set as the email address.'));
  }
  if ($form_state['values']['name']) {
    $form_state['values']['name'] = rtrim($form_state['values']['name']);
    if (drupal_strlen($form_state['values']['name']) < 1 || drupal_strlen($form_state['values']['name']) > 25) {
      form_set_error('name', t('Name of saved settings must be 25 characters or less.'));
    }
  }
  return;
}