You are here

function spam_admin_settings_form in Spam 5.3

Same name and namespace in other branches
  1. 6 spam.module \spam_admin_settings_form()

Spam module settings form.

1 string reference to 'spam_admin_settings_form'
spam_admin_settings in ./spam.module
Spam module settings page.

File

./spam.module, line 769

Code

function spam_admin_settings_form() {
  $form['content'] = array(
    '#type' => 'fieldset',
    '#title' => t('Content to filter'),
    '#collapsible' => TRUE,
  );
  $modules = spam_invoke_api('content_module');
  foreach ($modules as $module) {
    $content_types = spam_invoke_module($module, 'content_types');
    if (is_array($content_types)) {
      foreach ($content_types as $content_type) {
        $name = $content_type['name'];
        $form['content'][$name] = array(
          '#type' => 'checkbox',
          '#title' => t($content_type['title']),
          '#description' => $content_type['description'],
          '#default_value' => variable_get("spam_filter_{$name}", (int) $content_type['default_value']),
        );
      }
    }
  }
  $form['actions'] = array(
    '#type' => 'fieldset',
    '#title' => t('Actions'),
    '#collapsible' => TRUE,
  );
  $form['actions']['spam_visitor_action'] = array(
    '#type' => 'select',
    '#title' => t('Posting action'),
    '#options' => array(
      t('silently prevent spam content from being posted'),
      t('prevent spam content from being posted, notify visitor'),
      t('place spam into special review queue, notify visitor'),
      t('allow spam content to be posted, automatically unpublish and notify visitor'),
    ),
    '#default_value' => variable_get('spam_visitor_action', SPAM_ACTION_PREVENT),
  );
  $form['actions']['spam_filtered_message'] = array(
    '#type' => 'textarea',
    '#title' => t('Spam filter message'),
    '#default_value' => variable_get('spam_filtered_message', t('<p>Your posting on @site from %IP has been automatically flagged by our spam filters as being inappropriate for this website.</p><p>At @site we work very hard behind the scenes to keep our web pages free of spam.  Unfortunately, sometimes we accidentally block legitimate content.  If you are attempting to post legitimate content to this website, you can help us to improve our spam filters by emailing the following information to a site administrator:</p><p>%LINK</p>', array(
      '@site' => variable_get('site_name', 'Drupal'),
    ))),
    '#description' => t('Message to show visitors when the spam filters block them from posting content.  The text "%IP" will be replaced by the visitors actual IP address.'),
  );

  // TODO: These options are for debugging the spam module.  They should be
  //       disabled before the module is released.
  $form['advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced configuration'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $options = drupal_map_assoc(spam_range(10, 40, 10)) + drupal_map_assoc(spam_range(45, 70, 5)) + drupal_map_assoc(spam_range(72, 88, 2)) + drupal_map_assoc(spam_range(90, 99));
  $form['advanced']['spam_threshold'] = array(
    '#type' => 'select',
    '#title' => t('Spam threshold'),
    '#options' => $options,
    '#default_value' => variable_get('spam_threshold', SPAM_DEFAULT_THRESHOLD),
    '#description' => t('Each of filtered content will be assigned a single number from 1 to 99.  This number signifies the percent of likelihood that the filtered content is spam.  Any piece of content whose spam value is equal to or greater than this threshold will be considered spam.  Any piece of content whose spam value is less than this threshold will be considered not spam.'),
  );
  $form['advanced']['spam_log_level'] = array(
    '#type' => 'select',
    '#title' => t('Log level'),
    '#options' => array(
      0 => t('Disabled'),
      SPAM_LOG => t('Important'),
      SPAM_VERBOSE => t('Verbose'),
      SPAM_DEBUG => t('Debug'),
    ),
    '#default_value' => variable_get('spam_log_level', SPAM_LOG),
    // TODO: Add informative description.
    '#description' => t('Logging level.'),
  );
  $period = drupal_map_assoc(array(
    0,
    3600,
    10800,
    21600,
    32400,
    43200,
    86400,
    172800,
    259200,
    604800,
    1209600,
    2419200,
    4838400,
    9676800,
    31536000,
  ), 'format_interval');
  $period[0] = t('never');
  $form['advanced']['spam_log_delete'] = array(
    '#type' => 'select',
    '#title' => t('Discard spam logs older than'),
    '#default_value' => variable_get('spam_log_delete', 259200),
    '#options' => $period,
    '#description' => t('Older spam log entries will be automatically discarded. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array(
      '@cron' => url('admin/reports/status'),
    )),
  );
  return system_settings_form($form);
}