mirror of
https://github.com/Mibew/real-ban-plugin.git
synced 2025-01-22 09:30:32 +03:00
Hide banned visitors too
This commit is contained in:
parent
f2619bb105
commit
860aa5b82c
23
Plugin.php
23
Plugin.php
@ -23,6 +23,7 @@
|
||||
|
||||
namespace Mibew\Mibew\Plugin\RealBan;
|
||||
|
||||
use Mibew\Ban;
|
||||
use Mibew\EventDispatcher\EventDispatcher;
|
||||
use Mibew\EventDispatcher\Events;
|
||||
use Mibew\Plugin\AbstractPlugin;
|
||||
@ -53,6 +54,7 @@ class Plugin extends AbstractPlugin implements PluginInterface
|
||||
{
|
||||
$dispatcher = EventDispatcher::getInstance();
|
||||
$dispatcher->attachListener(Events::USERS_UPDATE_THREADS_ALTER, $this, 'alterThreads');
|
||||
$dispatcher->attachListener(Events::USERS_UPDATE_VISITORS_ALTER, $this, 'alterVisitors');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,4 +87,25 @@ class Plugin extends AbstractPlugin implements PluginInterface
|
||||
|
||||
$args['threads'] = $threads;
|
||||
}
|
||||
|
||||
/**
|
||||
* A handler for
|
||||
* {@link \Mibew\EventDispatcher\Events::USERS_UPDATE_VISITORS_ALTER} event.
|
||||
*
|
||||
* @param array $args Event arguments.
|
||||
*/
|
||||
public function alterVisitors(&$args)
|
||||
{
|
||||
$visitors = array();
|
||||
foreach ($args['visitors'] as $visitor) {
|
||||
$ban = Ban::loadByAddress($visitor['userIp']);
|
||||
if ($ban && !$ban->isExpired()) {
|
||||
// Skip banned visitors
|
||||
continue;
|
||||
}
|
||||
$visitors[] = $visitor;
|
||||
}
|
||||
|
||||
$args['visitors'] = $visitors;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Mibew Real Ban plugin
|
||||
|
||||
It hides banned users from the awaiting page.
|
||||
It hides banned threads and visitors on the awaiting page.
|
||||
|
||||
|
||||
## Installation
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "real-ban-plugin",
|
||||
"version": "0.1.0",
|
||||
"description": "A plugin for Mibew that hides banned users from the threads list.",
|
||||
"description": "A plugin for Mibew that hides banned threads and visitors on the awaiting page.",
|
||||
"private": true,
|
||||
"bugs": {
|
||||
"url": "https://github.com/mibew/real-ban-plugin/issues"
|
||||
|
Loading…
Reference in New Issue
Block a user