You are here

flood_unblock.module in Flood Unblock 8

File

flood_unblock.module
View source
<?php

use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\user\Entity\User;
use Drupal\Core\Url;
use Drupal\Core\Link;

/**
 * Implements hook_help().
 */
function flood_unblock_help($route_name, RouteMatchInterface $route_match) {
  $user = User::load(\Drupal::currentUser()
    ->id());
  $links = [
    'permissions' => 'user.admin_permissions',
    'interface' => 'flood_unblock.form',
  ];
  foreach ($links as $key => $route) {
    $f_links[$key] = Link::fromTextAndUrl(t($key), Url::fromRoute($route)
      ->setOptions([
      'attributes' => [
        'target' => '_blank',
      ],
    ]));
  }
  $f_link['official'] = Link::fromTextAndUrl(t('module page'), Url::fromUri('https://www.drupal.org/project/flood_unblock')
    ->setOptions([
    'attributes' => [
      'target' => '_blank',
    ],
  ]));
  switch ($route_name) {
    case 'help.page.flood_unblock':
      $output = [
        '#markup' => t("<h2>About</h2><p>This module provides a simple @interface that\n          makes possible for site administrators to remove ip-adresses from the\n          flood table, or to remove all ip-adresses from the flood table depending on\n          the event type.</p><p>Drupal prevents brute force attacks on accounts. It does so by\n          refusing login attempts when more than 5 attempts failed. The amount\n          of failed logins is recorded in the table 'flood'. You can either\n          wait before trying to login again or clean the flood table with the\n          procedure below.</p><h2>Uses</h2><p>To use this module you can use the @interface.</p><p>The module does have restricted by @permissions,\n          contact an administrator to get access on this module features.</p>\n          <p>If you need some extra tools for flood management please\n          open an issue on the @page", [
          '@permissions' => $user
            ->hasRole('administrator') ? $f_links['permissions']
            ->toString() : '<no access>',
          '@interface' => $user
            ->hasPermission('access flood unblock') ? $f_links['interface']
            ->setText('user interface')
            ->toString() : 'user interface',
          '@page' => $f_link['official']
            ->toString(),
        ]),
      ];
      return $output;
  }
}

Functions

Namesort descending Description
flood_unblock_help Implements hook_help().