You are here

function statistics_filter_admin_settings in Statistics Filter 5

Same name and namespace in other branches
  1. 6 statistics_filter.module \statistics_filter_admin_settings()

Admin settings callback.

1 string reference to 'statistics_filter_admin_settings'
statistics_filter_menu in ./statistics_filter.module
Implementation of hook_menu().

File

./statistics_filter.module, line 123
Filter specified hits out from your statistics.

Code

function statistics_filter_admin_settings() {
  $form = array();

  // Restrict administration of this module
  if (user_access('administer statistics filter') === FALSE) {
    return drupal_access_denied();
  }
  $form['statistics_filter_noadmin'] = array(
    '#type' => 'checkbox',
    '#title' => t('Ignore administrator'),
    '#default_value' => variable_get('statistics_filter_noadmin', FALSE),
    '#description' => t("Ignore the special administrator account's accesses to this site."),
  );
  $roles = user_roles();
  $variable_roles = variable_get('statistics_filter_roles', array());
  $default_roles = array();
  foreach ($roles as $key => $value) {
    if (in_array($key, $variable_roles)) {
      $default_roles[] = $key;
    }
  }
  $form['statistics_filter_roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Roles to ignore'),
    '#default_value' => $default_roles,
    '#options' => $roles,
    '#description' => t("Ignore accesses by users in any of the checked roles."),
  );
  if (module_exists('browscap')) {
    $form['statistics_filter_crawlers'] = array(
      '#type' => 'checkbox',
      '#title' => t('Ignore crawlers'),
      '#default_value' => variable_get('statistics_filter_crawlers', FALSE),
      '#description' => t("Ignore search engine crawlers' accesses to this site."),
    );
  }
  return system_settings_form($form);
}