You are here

function constant_contact_block_configure in Constant Contact 7.3

Implements hook_block_configure().

File

./constant_contact.module, line 878

Code

function constant_contact_block_configure($delta = '') {
  $form = array();
  $lists = array();

  // If we have an object get the users contact lists.
  $cc = constant_contact_create_object();
  if (is_object($cc)) {
    $lists = constant_contact_get_lists($cc);
  }

  // Form block settings
  $form['cc_block_show_list_selection_' . $delta] = array(
    '#type' => 'radios',
    '#title' => t('Show List Selection'),
    '#default_value' => variable_get('cc_block_show_list_selection_' . $delta, CC_BLOCK_SHOW_LIST_SELECTION),
    '#options' => array(
      0 => 'No',
      1 => 'Yes',
    ),
    '#description' => t('Do you want to display a contact list selection to the user?'),
  );
  $form['cc_block_list_selection_format_' . $delta] = array(
    '#type' => 'radios',
    '#title' => t('List Selection Format'),
    '#default_value' => variable_get('cc_block_list_selection_format_' . $delta, CC_LIST_SELECTION_FORMAT),
    '#options' => array(
      'select' => 'Multi-Select',
      'checkbox' => 'Checkboxes',
    ),
    '#description' => t('You can change the format of the list selection to either checkboxes or a multi-select drop down, the default is a multi-select drop down.'),
  );
  $form['cc_show_format_choice_' . $delta] = array(
    '#type' => 'checkbox',
    '#title' => t('Show Email Format Selection'),
    '#description' => t('Should we show an email format selection to subscribers, if you check this box it will show a selection to the user allowing them to choose between HTML and Text email'),
    '#default_value' => variable_get('cc_show_format_choice_' . $delta, CC_SHOW_FORMAT_CHOICE),
  );
  $form['cc_subscribe_format_' . $delta] = array(
    '#type' => 'radios',
    '#title' => t('Default Email Format'),
    '#description' => t('You can choose the format of email for new subscribers, HTML or Text, if you select to show a selection to the user below it will ask them what format email they would like to receive and the option you choose here will be selected by default'),
    '#default_value' => variable_get('cc_subscribe_format_' . $delta, CC_SUBSCRIBE_FORMAT),
    '#options' => array(
      'HTML' => 'HTML',
      'Text' => 'Text',
    ),
  );
  $form['cc_list_selection_title_' . $delta] = array(
    '#type' => 'textfield',
    '#title' => t('Title text for the list selection, if enabled'),
    '#description' => t('If you show the list selection this text is shown above it'),
    '#default_value' => variable_get('cc_list_selection_title_' . $delta, CC_SIGNUP_TITLE),
  );
  $form['cc_list_selection_description_' . $delta] = array(
    '#type' => 'textarea',
    '#title' => t('Description text for the list selection, if enabled'),
    '#description' => t('If you show the list selection this text is shown below it'),
    '#default_value' => variable_get('cc_list_selection_description_' . $delta, CC_SIGNUP_DESCRIPTION),
    '#maxlength' => NULL,
    '#rows' => 3,
  );
  if ($lists) {
    $form['cc_block_lists_' . $delta] = array(
      '#type' => 'select',
      '#title' => t('Contact lists'),
      '#description' => t('If you show the list selection you should choose which contact lists the user will be shown, if you do not show the list selection you should choose which contact lists the user will be automatically added to, if you dont select any lists here all lists will be used'),
      '#default_value' => variable_get('cc_block_lists_' . $delta, ''),
      '#options' => $lists,
      '#multiple' => TRUE,
      '#size' => 10,
    );
  }
  $form['cc_block_redirect_url_' . $delta] = array(
    '#type' => 'textfield',
    '#title' => t('Thank You Page'),
    '#description' => t('After a user submits the form you can send them to a URL, enter the full website address here or leave blank for no redirect'),
    '#default_value' => variable_get('cc_block_redirect_url_' . $delta, ''),
  );
  $extra_fields = array_slice(variable_get('cc_extra_fields', array()), 0, 18);
  $options = $extra_fields ? array_combine(array_values($extra_fields), array_values($extra_fields)) : array();
  $form['cc_form_block_fields_' . $delta] = array(
    '#type' => 'checkboxes',
    '#title' => t('Extra Fields'),
    '#description' => t('Select which extra fields you would like to display in the form, these will be sent to Constant Contact with the subscribers data'),
    '#default_value' => variable_get('cc_form_block_fields_' . $delta, array()),
    '#options' => $options,
  );
  $form['cc_email_field_position_' . $delta] = array(
    '#type' => 'textfield',
    '#title' => t('Position of email field'),
    '#description' => t('Enter the position of the email field in the form, numbers only, depending which extra fields you choose above you may not need to configure this option'),
    '#default_value' => variable_get('cc_email_field_position_' . $delta, 1),
    '#size' => 10,
  );
  return $form;
}