You are here

function constant_contact_export_submit in Constant Contact 7.3

Same name and namespace in other branches
  1. 6.3 admin.export.inc \constant_contact_export_submit()

Submit handler for the module export form.

File

./admin.export.inc, line 76
Export contacts functions.

Code

function constant_contact_export_submit($form, &$form_state) {
  $cc = constant_contact_create_object();
  if (!is_object($cc)) {
    return;
  }
  $type = $form_state['values']['export']['type'];
  $columns = array_values($form_state['values']['export']['columns']);
  $list_id = $form_state['values']['export']['list'];
  $sort_by = $form_state['values']['export']['sort_by'];

  // Check we have an object.
  $cc = constant_contact_create_object();
  $status = $cc
    ->export_contacts($list_id, $type, $columns, $sort_by);
  if ($status) {
    drupal_set_message(t('An export activity has been created and the download will be available soon'));
  }
  else {
    drupal_set_message(t('Your subscribers could not be exported: %last_error', array(
      '%last_error' => $cc->last_error,
    )), 'error');
  }
}