You are here

function spamicide_admin_form in Spamicide 7

Same name and namespace in other branches
  1. 5 spamicide.module \spamicide_admin_form()
  2. 6 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
Implements hook_menu().

File

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

Code

function spamicide_admin_form() {
  $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'),
    )),
  );
  $form['spamicide_log_attempts'] = array(
    '#type' => 'checkbox',
    '#title' => t('Log attempts'),
    '#description' => t('Report information about attempts to the !dblog.', array(
      '!dblog' => l(t('log'), 'admin/reports/dblog'),
    )),
    '#default_value' => variable_get('spamicide_log_attempts', TRUE),
  );
  $form['spamicide_dir'] = array(
    '#type' => 'textfield',
    '#size' => 30,
    '#title' => t('Spamicide Directory'),
    '#description' => t("Set the spamicide directory name to further hide it's signature."),
    '#default_value' => variable_get('spamicide_dir', "spamicide"),
  );
  $form['spamicide_description'] = array(
    '#type' => 'textfield',
    '#size' => 90,
    '#title' => t('Spamicide Description Message'),
    '#description' => t("Set the spamicide description message to further hide it's signature."),
    '#default_value' => variable_get('spamicide_description', "To prevent automated spam submissions leave this field empty."),
  );
  $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 <strong>form_id</strong>'s). You can easily add arbitrary forms with the help of the <strong>'Add Spamicide administration links to forms'</strong> option above then navigating to any form."),
  );
  $form['spamicide_forms']['spamicide_form'] = array(
    '#tree' => TRUE,
    '#theme' => 'spamicide_admin_settings',
  );

  // list all possible form_id's
  $result = db_query("SELECT * FROM {spamicide} ORDER BY form_id");
  while ($spamicide = $result
    ->fetchObject()) {
    $form['spamicide_forms']['spamicide_form'][$spamicide->form_id]['enabled'] = array(
      '#type' => 'checkbox',
      '#default_value' => $spamicide->enabled,
    );
    $form['spamicide_forms']['spamicide_form'][$spamicide->form_id]['form_id'] = array(
      '#markup' => check_plain($spamicide->form_id),
    );
    $form['spamicide_forms']['spamicide_form'][$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'][$spamicide->form_id]['operations'] = array(
        '#markup' => implode(", ", array(
          l(t('delete'), "admin/config/people/spamicide/spamicide_form/delete/{$spamicide->form_id}"),
        )),
      );
    }
    else {
      $form['spamicide_forms']['spamicide_form'][$spamicide->form_id]['operations'] = array(
        '#markup' => "N/A",
      );
    }
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}