You are here

function constant_contact_import_submit in Constant Contact 7.3

Same name and namespace in other branches
  1. 5 constant_contact.module \constant_contact_import_submit()
  2. 6.3 admin.import.inc \constant_contact_import_submit()
  3. 6 constant_contact.module \constant_contact_import_submit()

Submit handler for the import form.

File

./admin.import.inc, line 57
Contact import functions.

Code

function constant_contact_import_submit($form, &$form_state) {
  $cc = constant_contact_create_object();
  if (!is_object($cc)) {
    return;
  }
  $lists = $form_state['values']['lists'];
  if (isset($_FILES['files']['tmp_name']['file']) && is_uploaded_file($_FILES['files']['tmp_name']['file'])) {
    $status = $cc
      ->create_contacts($_FILES['files']['tmp_name']['file'], $lists);
  }
  else {
    drupal_set_message(t('The uploaded file is invalid please try again'), 'error');
    return;
  }
  if ($status) {
    drupal_set_message(t('An import activity has been created and will be completed soon'));
  }
  else {
    drupal_set_message(t('Your subscribers could not be imported: %last_error', array(
      '%last_error' => $cc->last_error,
    )), 'error');
  }
}