You are here

function apachesolr_stats_admin in Apache Solr Statistics 7

Same name and namespace in other branches
  1. 6.3 apachesolr_stats.module \apachesolr_stats_admin()
  2. 6 apachesolr_stats.module \apachesolr_stats_admin()

Build the settings form.

1 string reference to 'apachesolr_stats_admin'
apachesolr_stats_menu in ./apachesolr_stats.module
Implements hook_menu().

File

./apachesolr_stats.module, line 42
Keeps and reports statistics about Apache Solr usage and performance.

Code

function apachesolr_stats_admin($form, &$form_state) {
  $form = array();
  $form['tip'] = array(
    '#markup' => t('You can also visit the <a href="@report-url">reports page</a> and <a href="@blocks-url">block administration page</a> for the enabled search pages.', array(
      '@report-url' => url('admin/reports/apachesolr_stats'),
      '@blocks-url' => url('admin/structure/block'),
    )),
  );
  $search_pages = apachesolr_search_load_all_search_pages();
  $options = array();
  foreach ($search_pages as $search_page) {
    $options[$search_page['page_id']] = $search_page['label'] . ' (' . $search_page['search_path'] . ')';
  }
  $form['apachesolr_stats_enabled'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Enable search logging for these search pages'),
    '#default_value' => variable_get('apachesolr_stats_enabled', array()),
    '#options' => $options,
    '#description' => t('Log information about all queries launched via the Apache Solr Search Integration module. Disabling a page here will also disable the associated block.'),
  );
  $periods = drupal_map_assoc(array(
    3600,
    10800,
    21600,
    32400,
    43200,
    86400,
    172800,
    259200,
    604800,
    1209600,
    2419200,
    4838400,
    9676800,
  ), 'format_interval');
  $form['apachesolr_stats_flush_log_timer'] = array(
    '#type' => 'select',
    '#title' => t('Discard query logs older than'),
    '#default_value' => variable_get('apachesolr_stats_flush_log_timer', 259200),
    '#options' => $periods,
    '#description' => t('Older query log entries will be automatically discarded. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array(
      '@cron' => url('admin/reports/status'),
    )),
  );

  // Blacklist settings.
  $form['access'] = array(
    '#type' => 'fieldset',
    '#title' => t('Log blacklist'),
    '#description' => t('Note: Changing this does not alter existing logged queries.'),
  );
  $form['access']['apachesolr_stats_ignore_ip_list'] = array(
    '#type' => 'textarea',
    '#title' => t('IP addresses that will not be logged'),
    '#default_value' => variable_get('apachesolr_stats_ignore_ip_list', ''),
    '#description' => t('Enter IP addresses (e.g.: 192.168.1.2), one per line. You can match entire subnets using a partial IP address ending with a period (e.g.: 192.168.)'),
  );
  $form['access']['apachesolr_stats_ignore_role_list'] = array(
    '#type' => 'checkboxes',
    '#title' => t('User roles that will not be logged'),
    '#options' => user_roles(),
    '#default_value' => variable_get('apachesolr_stats_ignore_role_list', array()),
    '#description' => t('Check all roles which should not be logged.'),
  );
  return system_settings_form($form);
}