You are here

function spamicide_admin_form in Spamicide 6

Same name and namespace in other branches
  1. 5 spamicide.module \spamicide_admin_form()
  2. 7 spamicide.module \spamicide_admin_form()

Form for spamicide administration

Parameters

$spamicide_form_id:

Return value

unknown_type

1 string reference to 'spamicide_admin_form'
spamicide_menu in ./spamicide.module
Implementation of hook_menu().

File

./spamicide.module, line 101
This module provides yet another tool to eliminate spam.

Code

function spamicide_admin_form($form) {
  $form = array();
  $form['spamicide_administration_mode'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add Spamicide administration links to forms'),
    '#default_value' => variable_get('spamicide_administration_mode', TRUE),
    '#description' => t('This option will allow enabling/disabling Spamicide on forms. When enabled, users with the "%adminspamicide" permission will see Spamicide administration links on all forms (except on administrative pages, which shouldn\'t be accessible to untrusted users in the first place). These links make it possible to enable or disable it for the desired type.', array(
      '%adminspamicide' => t('administer Spamicide settings'),
    )),
  );
  $form['spamicide_forms'] = array(
    '#type' => 'fieldset',
    '#title' => t('Add Spamicide to a form or remove an added form'),
    '#description' => t('Select from the listed forms (identified by their so called <em>form_id</em>\'s). You can easily add arbitrary forms with the help of the \'%spamicide_admin_links\' option.', array(
      '%spamicide_admin_links' => t('Add Spamicide administration links to forms'),
      '!add_spamicide' => url('admin/settings/spamicide/add_form'),
    )),
    '#tree' => TRUE,
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#theme' => 'spamicide_admin_settings_spamicide',
  );

  // list all possible form_id's
  $result = db_query("SELECT * FROM {spamicide} ORDER BY form_id");
  while ($spamicide = db_fetch_object($result)) {
    $form['spamicide_forms'][$spamicide->form_id]['enabled'] = array(
      '#type' => 'checkbox',
      '#default_value' => $spamicide->enabled,
    );
    $form['spamicide_forms'][$spamicide->form_id]['form_id'] = array(
      '#value' => $spamicide->form_id,
    );
    $form['spamicide_forms'][$spamicide->form_id]['form_field'] = array(
      '#type' => 'textfield',
      '#size' => 30,
      '#default_value' => $spamicide->form_field,
    );

    // additional operations
    if ($spamicide->removable) {
      $form['spamicide_forms'][$spamicide->form_id]['operations'] = array(
        '#value' => implode(", ", array(
          l(t('delete'), "admin/settings/spamicide/spamicide_form/delete/{$spamicide->form_id}"),
        )),
      );
    }
    else {
      $form['spamicide_forms'][$spamicide->form_id]['operations'] = array(
        '#value' => "N/A",
      );
    }
  }
  $form['spamicide_log_attempts'] = array(
    '#type' => 'checkbox',
    '#title' => t('Log attempts'),
    '#description' => t('Report information about attempts to the !watchdoglog.', array(
      '!watchdoglog' => l(t('log'), 'admin/reports/watchdog'),
    )),
    '#default_value' => variable_get('spamicide_log_attempts', TRUE),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}