You are here

auditfiles.admin.inc in Audit Files 7.4

This is where the administrative settings configuration is.

File

auditfiles.admin.inc
View source
<?php

/**
 * @file
 * This is where the administrative settings configuration is.
 */

/**
 * Creates page for configuring the administrative settings.
 */
function auditfiles_admin_settings($form, &$form_state) {
  $form['auditfiles_exclusions'] = array(
    '#type' => 'fieldset',
    '#title' => t('Exclusions'),
    '#collapsible' => TRUE,
  );
  $form['auditfiles_exclusions']['auditfiles_exclude_files'] = array(
    '#type' => 'textfield',
    '#title' => t('Exclude these files'),
    '#default_value' => trim(variable_get('auditfiles_exclude_files', '.htaccess')),
    '#description' => t('Enter a list of files to exclude, each separated by the
      semi-colon character (;).'),
  );
  $form['auditfiles_exclusions']['auditfiles_exclude_extensions'] = array(
    '#type' => 'textfield',
    '#title' => t('Exclude these extensions'),
    '#default_value' => trim(variable_get('auditfiles_exclude_extensions', '')),
    '#description' => t('Enter a list of extensions to exclude, each separated
      by the semi-colon character (;). Do not include the leading dot.'),
  );
  $form['auditfiles_exclusions']['auditfiles_exclude_paths'] = array(
    '#type' => 'textfield',
    '#title' => t('Exclude these paths'),
    '#default_value' => trim(variable_get('auditfiles_exclude_paths', 'color;css;ctools;js')),
    '#description' => t('Enter a list of paths to exclude, each separated by the
      semi-colon character (;). Do not include the leading slash. Paths are
      relative to %directorypath', array(
      '%directorypath' => file_default_scheme(),
    )),
  );
  $form['auditfiles_domains'] = array(
    '#type' => 'fieldset',
    '#title' => t('Domains'),
    '#collapsible' => TRUE,
  );
  $form['auditfiles_domains']['auditfiles_include_domains'] = array(
    '#type' => 'textfield',
    '#title' => t('Include references to these domains'),
    '#default_value' => trim(variable_get('auditfiles_include_domains', '')),
    '#size' => 80,
    '#maxlength' => 1024,
    '#description' => t('Enter a list of domains (e.g., www.example.com)
      pointing to your website, each separated by the semi-colon character (;).
      <br />When scanning content for file references (such as &lt;img&gt;
      tags), any absolute references using these domains will be included and
      rewritten to use relative references. Absolute references to domains not
      in this list will be considered to be external references and will not be
      audited or rewritten.'),
  );
  $form['auditfiles_report_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Report options'),
    '#collapsible' => TRUE,
  );

  // Show date format select list.
  $date_types = system_get_date_types();
  $options = array();
  foreach ($date_types as $date_type) {
    $options[$date_type['type']] = $date_type['title'];
  }
  $form['auditfiles_report_options']['auditfiles_report_options_date_format'] = array(
    '#type' => 'select',
    '#title' => 'Date format',
    '#default_value' => variable_get('auditfiles_report_options_date_format', ''),
    '#options' => $options,
    '#description' => t('Select the date format to use when displaying file
      dates in the reports.<br />
      Date types and formats can be modified in the system !datetime settings
      pages.', array(
      '!datetime' => l(t('Date and time'), 'admin/config/regional/date-time'),
    )),
  );
  $form['auditfiles_report_options']['auditfiles_report_options_items_per_page'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of items per page'),
    '#default_value' => variable_get('auditfiles_report_options_items_per_page', 50),
    '#size' => 10,
    '#description' => t('Enter an integer representing the number of items to
      display on each page of a report.<br />
      If there are more than this number on a page, then a pager will be used to
      display the additional items.<br />
      Set this to 0 to show all items on a single page.'),
  );
  $form['auditfiles_report_options']['auditfiles_report_options_maximum_records'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum records'),
    '#default_value' => variable_get('auditfiles_report_options_maximum_records', 0),
    '#size' => 10,
    '#description' => t('Enter an integer representing the maximum number of
      records to return on each report.<br />
      If any of the reports are timing out, set this to some positive integer to
      limit the number of records that are queried in the database. For reports
      where the limit is reached, a button to batch process the loading of the
      page will be available that will allow all records to be retrieved without
      timing out.<br />
      Set this to 0 for no limit.'),
  );
  $form['auditfiles_report_options']['auditfiles_report_options_batch_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Batch set size'),
    '#default_value' => variable_get('auditfiles_report_options_batch_size', 0),
    '#size' => 10,
    '#description' => t("Sometimes, the above limitations and batching\n      operations aren't enough, and the reports may still timeout or exhaust the\n      available memory. If that is the case, enter a positive integer here and\n      the batch operations will be broken up into sets of this number of\n      records. You will be given a method for paging from one batch set to\n      anther.<br />\n      To test if this will be helpful or not, set it to a low number. If the\n      report loads, then set it to a higher number to access more records per\n      batch load operation.<br />\n      Set this to 0 for no limit."),
  );
  return system_settings_form($form);
}

/**
 * Validates some user input for auditfiles_admin_settings().
 */
function auditfiles_admin_settings_validate($form, &$form_state) {
  $fields = array(
    'auditfiles_report_options_items_per_page' => t('Number of items per page'),
    'auditfiles_report_options_maximum_records' => t('Maximum records'),
    'auditfiles_report_options_batch_size' => t('Batch set size'),
  );
  foreach ($fields as $field => $label) {
    if (!is_numeric($form_state['values'][$field])) {
      form_set_error($field, t('You must enter zero or a positive integer for !label.', array(
        '!label' => $label,
      )));
    }
    elseif (!is_int($form_state['values'][$field] + 0) || $form_state['values'][$field] < 0) {
      form_set_error($field, t('!label must be zero or a positive integer.', array(
        '!label' => $label,
      )));
    }
  }
}

Functions

Namesort descending Description
auditfiles_admin_settings Creates page for configuring the administrative settings.
auditfiles_admin_settings_validate Validates some user input for auditfiles_admin_settings().