You are here

function constant_contact_settings in Constant Contact 6.2

Same name and namespace in other branches
  1. 6.3 admin.system.inc \constant_contact_settings()
  2. 7.3 admin.system.inc \constant_contact_settings()

Displays the module settings page in the admin

1 string reference to 'constant_contact_settings'
constant_contact_menu in ./constant_contact.module
Adds an admin menu for the Cnstant Contact module

File

./system.admin.inc, line 26

Code

function constant_contact_settings() {
  drupal_add_js(drupal_get_path('module', 'constant_contact') . '/constant_contact.js');
  $form = array();

  // account settings
  $form['constant_contact']['account'] = array(
    '#type' => 'fieldset',
    '#title' => t('Account Settings'),
    '#collapsible' => TRUE,
    '#collapsed' => true,
    '#tree' => false,
    '#description' => t('Change your constant contact account settings'),
  );
  $form['constant_contact']['account']['constant_contact_username'] = array(
    '#id' => 'cc_username',
    '#type' => 'textfield',
    '#title' => t('Username'),
    '#description' => t("The Constant Contact Account Username"),
    '#default_value' => variable_get('constant_contact_username', ''),
    '#size' => 60,
    '#required' => TRUE,
  );
  $form['constant_contact']['account']['constant_contact_password'] = array(
    '#id' => 'cc_password',
    '#type' => 'textfield',
    '#title' => t('Password'),
    '#description' => t("The Constant Contact Account Password"),
    '#default_value' => variable_get('constant_contact_password', ''),
    '#size' => 60,
    '#required' => TRUE,
  );
  $form['constant_contact']['account']['constant_contact_api_key'] = array(
    '#id' => 'cc_key',
    '#type' => 'textfield',
    '#title' => t('API Key'),
    '#description' => t("The Constant Contact API Key"),
    '#default_value' => variable_get('constant_contact_api_key', ''),
    '#size' => 60,
    '#required' => TRUE,
  );
  $form['constant_contact']['account']['cc_auth_res'] = array(
    '#type' => 'markup',
    '#value' => '<div class="cc_auth_res">&nbsp;</div>',
  );
  $form['constant_contact']['account']['cc_path'] = array(
    '#id' => 'cc_path',
    '#type' => 'hidden',
    '#value' => drupal_get_path('module', 'constant_contact'),
  );
  $form['constant_contact']['account']['cc_auth'] = array(
    '#id' => 'cc_auth',
    '#type' => 'submit',
    '#value' => t('Check Account Details'),
  );

  // contact list settings
  $form['constant_contact']['lists'] = array(
    '#type' => 'fieldset',
    '#title' => t('Contact List Settings'),
    '#collapsible' => TRUE,
    '#collapsed' => true,
    '#tree' => false,
    '#description' => t('Change your contact list settings'),
  );
  $form['constant_contact']['lists']['constant_contact_show_list_selection'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show List Selection?'),
    '#default_value' => variable_get('constant_contact_show_list_selection', CONSTANT_CONTACT_SHOW_LIST_SELECTION),
    '#options' => $lists,
    '#description' => t('Should we allow the user to choose which contact lists they are added to, if you do not check this box the user will be automatically added to all the lists you select below.'),
  );
  $form['constant_contact']['lists']['constant_contact_signup_lists_description'] = array(
    '#type' => 'textfield',
    '#title' => t('Select List Description'),
    '#description' => t("The text displayed above the list selection box, if enabled"),
    '#default_value' => variable_get('constant_contact_signup_lists_description', CONSTANT_CONTACT_SIGNUP_LISTS_DESCRIPTION),
    '#size' => 60,
  );

  // if we have an object get the users contact lists
  $cc = constant_contact_create_object();
  if (is_object($cc)) {
    $_lists = $cc
      ->get_lists();
    if ($_lists) {
      foreach ($_lists as $k => $v) {
        $lists[$v['id']] = t($v['Name']);
      }
    }
    $form['constant_contact']['lists']['constant_contact_lists'] = array(
      '#type' => 'select',
      '#title' => t('Contact lists'),
      '#default_value' => variable_get('constant_contact_lists', ''),
      '#options' => $lists,
      '#multiple' => true,
      '#size' => 10,
      '#description' => t('If you disable list selection above select which contact list the subscribers are automatically added to.<br />Alternatively, if you enable list selection above select which contact lists to exclude from the list selection presented to your users.'),
    );
  }

  // add register page settings
  $form['constant_contact']['form'] = array(
    '#type' => 'fieldset',
    '#title' => t('Register Page Settings'),
    '#collapsible' => TRUE,
    '#collapsed' => true,
    '#tree' => false,
    '#description' => t('Customize register page signup checkbox settings'),
  );
  $form['constant_contact']['form']['constant_contact_show_on_register'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show Signup Checkbox on Register Page?'),
    '#description' => t('You can display a checkbox on the register page and on the update user page'),
    '#default_value' => variable_get('constant_contact_show_on_register', CONSTANT_CONTACT_SHOW_ON_REGISTER),
  );
  $form['constant_contact']['form']['constant_contact_signup_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Signup Title Text'),
    '#description' => t("The title text displayed on the register page, if enabled"),
    '#default_value' => variable_get('constant_contact_signup_title', CONSTANT_CONTACT_SIGNUP_TITLE),
    '#size' => 60,
  );
  $form['constant_contact']['form']['constant_contact_signup_description'] = array(
    '#type' => 'textfield',
    '#title' => t('Signup Description Text'),
    '#description' => t("The description text displayed on the register page, if enabled"),
    '#default_value' => variable_get('constant_contact_signup_description', CONSTANT_CONTACT_SIGNUP_DESCRIPTION),
    '#size' => 60,
  );
  $form['constant_contact']['form']['constant_contact_custom_fields'] = array(
    '#type' => 'textarea',
    '#title' => t('Custom Fields'),
    '#description' => t("Specify the names for your custom fields, if found in your form these will be sent to the API, you should define these in the format FirstName:ActualFieldname and separate with a comma. You will only need to change the second value to match your form fieldnames eg. ActualFieldname"),
    '#default_value' => variable_get('constant_contact_custom_fields', CONSTANT_CONTACT_CUSTOM_FIELDS),
    '#rows' => 3,
  );

  // add form block settings
  $form['constant_contact']['block'] = array(
    '#type' => 'fieldset',
    '#title' => t('Form Block Settings'),
    '#collapsible' => TRUE,
    '#collapsed' => true,
    '#tree' => false,
    '#description' => t('Change settings for the custom form that is shown using the block method'),
  );
  $form['constant_contact']['block']['constant_contact_show_firstname'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show Firstname field?'),
    '#default_value' => variable_get('constant_contact_show_firstname', CONSTANT_CONTACT_SHOW_FIRSTNAME),
  );
  $form['constant_contact']['block']['constant_contact_show_lastname'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show Lastname field?'),
    '#default_value' => variable_get('constant_contact_show_lastname', CONSTANT_CONTACT_SHOW_LASTNAME),
  );
  $form['constant_contact']['block']['constant_contact_show_job_title'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show Job Title field?'),
    '#default_value' => variable_get('constant_contact_show_job_title', CONSTANT_CONTACT_SHOW_JOB_TITLE),
  );
  $form['constant_contact']['block']['constant_contact_show_company_name'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show Company Name field?'),
    '#default_value' => variable_get('constant_contact_show_company_name', CONSTANT_CONTACT_SHOW_COMPANY_NAME),
  );
  $form['#redirect'] = 'admin/constant_contact';
  return system_settings_form($form);
}