You are here

function httpbl_form_ban_ip_form_alter in http:BL 8

Implements hook_form_FORM_ID_alter().

File

./httpbl.module, line 405
Implements Project Honeypot's http:BL for Drupal. It provides IP-based blacklisting through http:BL and allows linking to a honeypot.

Code

function httpbl_form_ban_ip_form_alter(&$form, FormStateInterface $form_state) {

  // Hide the the ability to add IPs to Ban module when httpbl is enabled.
  $httpblUrl = Url::fromRoute('entity.host.collection');
  $httpblLink = Link::fromTextAndUrl(t('Http:BL module'), $httpblUrl)
    ->toString();
  $httpblLink2 = Link::fromTextAndUrl(t('from Http:BL Evaluated Hosts'), $httpblUrl)
    ->toString();

  // Add an 'item' message with links to httpbl evaluated hosts admin.
  $form['httpbl_message'] = array(
    '#type' => 'item',
    '#markup' => t('<h3>The @httpbl is installed, enabling automated, expiry managed IPs (white-listing, grey-listing and blacklisting -- with auto-banning).  All IP banning should be handled @hosts.</h3>', [
      '@httpbl' => $httpblLink,
      '@hosts' => $httpblLink2,
    ]),
  );

  // Hide the textfield and submit button used for "manual" banning of IPs.
  $form['ip']['#type'] = 'hidden';
  $form['actions']['submit']['#type'] = 'hidden';
}