You are here

function watchdog_prune_admin_config_form in Watchdog Prune 7

Function watchdog_prune_admin_config_form

1 string reference to 'watchdog_prune_admin_config_form'
watchdog_prune_menu in ./watchdog_prune.module
Implements hook_menu

File

./watchdog_prune.module, line 58
This is the main module file for watchdog_prune.

Code

function watchdog_prune_admin_config_form($form, &$form_state) {
  $form['mark_top'] = array(
    '#markup' => "<p>" . t("This module allows you to delete watchdog entries, on cron run, based on certain criteria (like age or watchdog entry types).In order for this module to work, Drupal's built in setting <strong>Database log messages to keep</strong>\n      must be set to <strong>All</strong>. <br><br><strong>You must have a correctly configured cron task for this module to work.</strong>") . "</p>",
  );
  $form['core_fs'] = array(
    '#type' => 'fieldset',
    '#title' => t('From Drupal Core'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['core_fs']['dblog_row_limit'] = array(
    '#type' => 'select',
    '#title' => t('[From Drupal Core:] Database log messages to keep'),
    '#options' => array(
      '0' => 'All',
    ),
    '#default_value' => 0,
    '#description' => t('For this module to function, we must keep this Drupal Core setting set to <strong>All</strong>.  This setting is provided here simply as a reminder of where this setting is coming from.'),
  );
  $prune_age_options = array(
    '' => t('None - do not prune based on age'),
    '-1 MONTH' => t('1 month'),
    '-2 MONTHS' => t('2 months'),
    '-3 MONTHS' => t('3 months'),
    '-6 MONTHS' => t('6 months'),
    '-9 MONTHS' => t('9 months'),
    '-12 MONTHS' => t('12 months (1 year)'),
    '-18 MONTHS' => t('18 months (1.5 years)'),
    '-24 MONTHS' => t('24 months (2 years)'),
    '-30 MONTHS' => t('30 months (2.5 years)'),
    '-36 MONTHS' => t('36 months (3 years)'),
  );
  $form['watchdog_prune_age'] = array(
    '#type' => 'select',
    '#title' => t('Delete watchdog entries older than:'),
    '#options' => $prune_age_options,
    '#default_value' => variable_get('watchdog_prune_age', '-18 MONTHS'),
    '#description' => t('Watchdog entries older than this time will be deleted on each cron run. This will ignore all watchdog types entered in "Delete watchdog entries by type" settings.'),
  );
  $watchdog_types = db_query('SELECT DISTINCT(type) FROM {watchdog}')
    ->fetchCol('type');
  $watchdog_types = implode(", ", $watchdog_types);
  if (count($watchdog_types) == 0) {
    $watchdog_types = t('Watchdog is empty');
  }
  $form['watchdog_prune_age_type'] = array(
    '#type' => 'textarea',
    '#title' => t('Delete watchdog entries by type'),
    '#description' => t('Configure different prune time for each watchdog type, enter separate values on new line. Currently <em>logged</em> watchdog entry types are (<em>' . $watchdog_types . '</em>). For all available values for age check the ' . l(t("PHP Date Manual"), "http://php.net/manual/en/datetime.formats.relative.php", array(
      "attributes" => array(
        "target" => "_blank",
      ),
    )) . '
      <br><br>Insert values with format
      <br><b><h4>watchdog_entry_type|age</h4></b>
      <br>Examples
      <br><b>php|-1 MONTH</b>
      <br><b>system|-1 MONTH</b>
      </br>This will delete all watchdog entries of type php and system which are older than a month on cron run.'),
    '#rows' => 10,
    '#cols' => 40,
    '#default_value' => variable_get('watchdog_prune_age_type', ''),
  );
  return system_settings_form($form);
}