You are here

system.admin.inc in Constant Contact 6.2

File

system.admin.inc
View source
<?php

/**
 * @file
 */

/**
 * Displays the module intro page in the admin settings page
 */
function constant_contact_intro() {
  $info_filename = drupal_get_path('module', 'constant_contact') . '/' . 'constant_contact' . '.info';
  $module = drupal_parse_info_file($info_filename);

  // not sure translation will work here :(
  $html = '<p>This is version ' . $module['version'] . ' of the Constant Contact module for Drupal.</p>';
  $html .= '<p>Instructions for setting up the module can be found <a href="@instructions">here</a>.</p>';
  $params = array(
    '@instructions' => url('admin/help/constant_contact'),
  );
  return t($html, $params);
}

/**
 * Displays the module settings page in the admin
 */
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);
}

/**
 * Submit handler for the module settings page
 */
function constant_contact_settings_submit($form, &$form_state) {
  cache_clear_all('variables', 'cache');
  drupal_set_message(t('Constant Contact module settings have been saved'));
}

Functions

Namesort descending Description
constant_contact_intro Displays the module intro page in the admin settings page
constant_contact_settings Displays the module settings page in the admin
constant_contact_settings_submit Submit handler for the module settings page