admin.export.inc in Constant Contact 7.3
Same filename and directory in other branches
Export contacts functions.
File
admin.export.incView source
<?php
/**
* @file
* Export contacts functions.
*/
/**
* Displays the export page
*/
function constant_contact_export() {
$cc = constant_contact_create_object();
if (!is_object($cc)) {
return '';
}
$form['constant_contact']['export'] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
'#title' => t('Export Subscribers'),
);
$options = array(
'CSV' => t('CSV'),
'TXT' => t('TXT'),
);
$form['constant_contact']['export']['type'] = array(
'#type' => 'radios',
'#title' => t('File Format'),
'#description' => t('Choose what format to use for the export'),
'#size' => 60,
'#options' => $options,
'#default_value' => 'CSV',
'#required' => TRUE,
);
$form['constant_contact']['export']['columns'] = array(
'#type' => 'select',
'#title' => t('Columns'),
'#options' => $cc
->get_export_file_columns(),
'#multiple' => TRUE,
'#size' => 10,
'#description' => t('You can select which columns to include in the export file'),
);
$lists = constant_contact_get_lists($cc, 0);
$form['constant_contact']['export']['list'] = array(
'#type' => 'select',
'#title' => t('Contact list'),
'#options' => $lists,
'#size' => 1,
'#description' => t('Select which contact list you want to export from'),
'#required' => TRUE,
);
$sort_by = array(
'DATE_DESC' => t('Date Subscribed'),
'EMAIL_ADDRESS' => t('Email Address'),
);
$form['constant_contact']['export']['sort_by'] = array(
'#type' => 'select',
'#title' => t('Sort By'),
'#description' => t('Choose how to sort the data'),
'#options' => $sort_by,
'#default_value' => 'DATE_DESC',
'#required' => TRUE,
);
$form['#redirect'] = 'admin/settings/constant_contact/activities';
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Export'),
);
return $form;
}
/**
* Submit handler for the module export form.
*/
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');
}
}
Functions
Name | Description |
---|---|
constant_contact_export | Displays the export page |
constant_contact_export_submit | Submit handler for the module export form. |