You are here

function spamicide_form_alter in Spamicide 5

Same name and namespace in other branches
  1. 8 spamicide.module \spamicide_form_alter()
  2. 6 spamicide.module \spamicide_form_alter()
  3. 7 spamicide.module \spamicide_form_alter()

Implementation of hook_form_alter

Parameters

$form_id:

$form:

File

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

Code

function spamicide_form_alter($form_id, &$form) {
  $spamicide_field = _spamicide_get_field($form_id);
  if ($spamicide_field) {
    if ($spamicide_field == 'feed_me') {
      drupal_add_css(drupal_get_path('module', 'spamicide') . '/feed_me.css');
    }
    else {
      drupal_add_css(file_directory_path() . '/spamicide/' . $spamicide_field . '.css');
    }
    $spamicide_description = _spamicide_get_description();
    $form[$spamicide_field] = array(
      '#type' => 'textfield',
      '#size' => 30,
      '#description' => $spamicide_description,
    );
    $form['destination'] = array(
      '#type' => 'value',
      '#value' => drupal_get_destination(),
    );
    $form['#pre_render'][] = 'spamicide_pre_render_place_spamicide';
    $form['spamicide']['#validate']['spamicide_validate'] = array();
  }
  else {
    if (user_access('administer spamicide') && variable_get('spamicide_administration_mode', TRUE) && arg(0) != 'admin') {
      $form['spamicide'] = array(
        '#type' => 'fieldset',
        '#title' => t('Spamicide'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      );
      $form['spamicide']['add_spamicide'] = array(
        '#value' => l(t('Add Spamicide protection to this form.'), "admin/settings/spamicide/spamicide_form/add/{$form_id}", array()),
      );

      // Add pre_render function for placing the Spamicide just above the submit button
      $form['#pre_render'][] = 'spamicide_pre_render_place_spamicide';
    }
    else {
      return;
    }
  }
}