You are here

function eloqua_admin_form in Eloqua 8

Same name and namespace in other branches
  1. 6 eloqua.admin.inc \eloqua_admin_form()
  2. 7.2 eloqua.admin.inc \eloqua_admin_form()
  3. 7 eloqua.admin.inc \eloqua_admin_form()

Form constructor for the Eloqua administration form.

File

./eloqua.admin.inc, line 13
General administration form for Eloqua settings.

Code

function eloqua_admin_form() {
  $form = array();
  $form['general'] = array(
    '#type' => 'fieldset',
    '#title' => t('General Settings'),
    '#description' => t('General settings applicable to all Eloqua functionality.'),
    'eloqua_site_id' => array(
      '#type' => 'textfield',
      '#title' => t('Site Identifier'),
      '#description' => t('The Eloqua Site ID for this web site.'),
      '#size' => 20,
      '#maxlength' => 64,
      '#default_value' => variable_get('eloqua_site_id', 0),
      '#required' => TRUE,
    ),
  );

  // Visibilty setting, shameless stolen from googleanalytics/pardot module.
  $form['tracking_title'] = array(
    '#type' => 'item',
    '#title' => t('Tracking scope'),
  );
  $form['tracking'] = array(
    '#type' => 'vertical_tabs',
  );

  // Page specific visibility configurations.
  $php_access = user_access('use PHP for tracking visibility');
  $visibility = variable_get('eloqua_visibility_pages', 0);
  $pages = variable_get('eloqua_pages', ELOQUA_PAGES);
  $form['tracking']['page_vis_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Pages'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  if ($visibility == 2 && !$php_access) {
    $form['tracking']['page_vis_settings'] = array();
    $form['tracking']['page_vis_settings']['visibility'] = array(
      '#type' => 'value',
      '#value' => 2,
    );
    $form['tracking']['page_vis_settings']['pages'] = array(
      '#type' => 'value',
      '#value' => $pages,
    );
  }
  else {
    $options = array(
      t('Every page except the listed pages'),
      t('The listed pages only'),
    );
    $description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
      '%blog' => 'blog',
      '%blog-wildcard' => 'blog/*',
      '%front' => '<front>',
    ));
    if (module_exists('php') && $php_access) {
      $options[] = t('Pages on which this PHP code returns <code>TRUE</code> (experts only)');
      $title = t('Pages or PHP code');
      $description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array(
        '%php' => '<?php ?>',
      ));
    }
    else {
      $title = t('Pages');
    }
    $form['tracking']['page_vis_settings']['eloqua_visibility_pages'] = array(
      '#type' => 'radios',
      '#title' => t('Add tracking to specific pages'),
      '#options' => $options,
      '#default_value' => $visibility,
    );
    $form['tracking']['page_vis_settings']['eloqua_pages'] = array(
      '#type' => 'textarea',
      '#title' => $title,
      '#title_display' => 'invisible',
      '#default_value' => $pages,
      '#description' => $description,
      '#rows' => 10,
    );
  }

  // Render the role overview.
  $form['tracking']['role_vis_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Roles'),
  );
  $form['tracking']['role_vis_settings']['eloqua_visibility_roles'] = array(
    '#type' => 'radios',
    '#title' => t('Add tracking for specific roles'),
    '#options' => array(
      t('Add to the selected roles only'),
      t('Add to every role except the selected ones'),
    ),
    '#default_value' => variable_get('eloqua_visibility_roles', 0),
  );
  $role_options = array_map('check_plain', user_roles());
  $form['tracking']['role_vis_settings']['eloqua_roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Roles'),
    '#default_value' => variable_get('eloqua_roles', array()),
    '#options' => $role_options,
    '#description' => t('If none of the roles are selected, all users will be tracked. If a user has any of the roles checked, that user will be tracked (or excluded, depending on the setting above).'),
  );
  return system_settings_form($form);
}