ban.module 1.38 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Allows to ban individual IP addresses.
6 7
 */

8
use Drupal\Core\Routing\RouteMatchInterface;
9

10 11 12
/**
 * Implements hook_help().
 */
13
function ban_help($route_name, RouteMatchInterface $route_match) {
14 15
  switch ($route_name) {
    case 'help.page.ban':
16 17
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
18
      $output .= '<p>' . t('The Ban module allows administrators to ban visits to their site from individual IP addresses. For more information, see <a href="!url">the online documentation for the Ban module</a>.', array('!url' => 'https://drupal.org/documentation/modules/ban')) . '</p>';
19 20 21
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Banning IP addresses') . '</dt>';
22
      $output .= '<dd>' . t('Administrators can enter IP addresses to ban on the <a href="!bans">IP address bans</a> page.', array('!bans' => \Drupal::url('ban.admin_page'))) . '</dd>';
23 24 25
      $output .= '</dl>';
      return $output;

26
    case 'ban.admin_page':
27 28 29 30 31 32 33 34 35 36 37 38 39 40
      return '<p>' . t('IP addresses listed here are banned from your site. Banned addresses are completely forbidden from accessing the site and instead see a brief message explaining the situation.') . '</p>';
  }
}

/**
 * Implements hook_permission().
 */
function ban_permission() {
  return array(
    'ban IP addresses' => array(
      'title' => t('Ban IP addresses'),
    ),
  );
}