You are here

function pardot_admin_form in Pardot Integration 7

Same name and namespace in other branches
  1. 6 pardot.admin.inc \pardot_admin_form()
  2. 7.2 pardot.admin.inc \pardot_admin_form()

Form constructor for general pardot settings.

1 string reference to 'pardot_admin_form'
pardot_menu in ./pardot.module
Implements hook_menu().

File

./pardot.admin.inc, line 12
Admin forms.

Code

function pardot_admin_form() {
  $form = array();
  $form['pardot_a_id'] = array(
    '#title' => t('Pardot account id'),
    '#type' => 'textfield',
    '#description' => t('The value show in the pardot demo script for piAId. eg. if the script has piAId = "1001"; this field should be 1001'),
    '#default_value' => variable_get('pardot_a_id', ''),
  );
  $form['pardot_c_id'] = array(
    '#title' => t('Default Pardot campaign id'),
    '#type' => 'textfield',
    '#description' => t('The value show in the pardot demo script for piCId. eg. if the script has piCId = "1001"; this field should be 1001'),
    '#default_value' => variable_get('pardot_c_id', ''),
  );
  $form['pardot']['pardot_validate_url'] = array(
    '#title' => t('Validate Pardot url'),
    '#type' => 'checkbox',
    '#description' => t('Validate Pardot form handler URL during webform creation.'),
    '#default_value' => variable_get('pardot_validate_url', 1),
  );

  // If curl isn't available want them that this functionality isn't available
  // and mark it as disabled.
  if (!function_exists('curl_getinfo')) {
    $form['pardot']['pardot_validate_url']['#description'] .= '<p class="warning">' . t('<a href="@curl">Curl</a> library required for this functionality not found.', array(
      '@curl' => 'http://php.net/manual/en/book.curl.php',
    )) . '</p>';
    $form['pardot']['pardot_validate_url']['#default_value'] = FALSE;
    $form['pardot']['pardot_validate_url']['#disabled'] = TRUE;
  }

  // Visibilty setting, shameless stolen from googleanalytics 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('pardot_visibility_pages', 0);
  $pages = variable_get('pardot_pages', PARDOT_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']['pardot_visibility_pages'] = array(
      '#type' => 'radios',
      '#title' => t('Add tracking to specific pages'),
      '#options' => $options,
      '#default_value' => $visibility,
    );
    $form['tracking']['page_vis_settings']['pardot_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']['pardot_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('pardot_visibility_roles', 0),
  );
  $role_options = array_map('check_plain', user_roles());
  $form['tracking']['role_vis_settings']['pardot_roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Roles'),
    '#default_value' => variable_get('pardot_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);
}