mirror of
https://github.com/Mibew/real-ban-plugin.git
synced 2025-04-18 00:37:25 +03:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
88990aa760 | |||
446a513f7a | |||
8ca0285646 | |||
26ce7982f2 | |||
|
c2c9d475a2 | ||
|
fe3eda94c5 | ||
|
46ea203894 | ||
|
e0e41200ea |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
# Do not index node.js modules that are used for building
|
||||
node_modules
|
||||
package-lock.json
|
||||
|
||||
# Do not index releases
|
||||
release
|
||||
|
38
Plugin.php
38
Plugin.php
@ -28,6 +28,8 @@ use Mibew\EventDispatcher\EventDispatcher;
|
||||
use Mibew\EventDispatcher\Events;
|
||||
use Mibew\Plugin\AbstractPlugin;
|
||||
use Mibew\Plugin\PluginInterface;
|
||||
use Mibew\Settings;
|
||||
use Mibew\Thread;
|
||||
|
||||
/**
|
||||
* The main plugin's file definition.
|
||||
@ -52,9 +54,15 @@ class Plugin extends AbstractPlugin implements PluginInterface
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if (!Settings::get('enableban')) {
|
||||
// Bans are disabled. The plugin should do nothing in this case.
|
||||
return;
|
||||
}
|
||||
|
||||
$dispatcher = EventDispatcher::getInstance();
|
||||
$dispatcher->attachListener(Events::USERS_UPDATE_THREADS_ALTER, $this, 'alterThreads');
|
||||
$dispatcher->attachListener(Events::USERS_UPDATE_VISITORS_ALTER, $this, 'alterVisitors');
|
||||
$dispatcher->attachListener(Events::THREAD_UPDATE, $this, 'handleThreadUpdate');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,6 +117,34 @@ class Plugin extends AbstractPlugin implements PluginInterface
|
||||
$args['visitors'] = $visitors;
|
||||
}
|
||||
|
||||
/**
|
||||
* A handler for {@link \Mibew\EventDispatcher\Events::THREAD_UPDATE} event.
|
||||
*
|
||||
* When the thread is added to the awaiting queue the method sends
|
||||
* notification about ban if it's needed.
|
||||
*
|
||||
* @param array $args Event arguments.
|
||||
*/
|
||||
public function handleThreadUpdate($args)
|
||||
{
|
||||
$thread = $args['thread'];
|
||||
$orig_thread = $args['original_thread'];
|
||||
|
||||
if ($thread->state != $orig_thread->state && $thread->state == Thread::STATE_QUEUE) {
|
||||
// State is change and the thread is in the awaiting queue now.
|
||||
$ban = Ban::loadByAddress($thread->remote);
|
||||
if ($ban && !$ban->isExpired()) {
|
||||
// Operators could not see the user, because he is banned. A
|
||||
// notification should be sent to let user know that he is
|
||||
// banned.
|
||||
$thread->postMessage(
|
||||
Thread::KIND_INFO,
|
||||
getlocal('Sorry, but your IP address is banned by some reasons. Try to use another way to contact the support.')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify version of the plugin.
|
||||
*
|
||||
@ -116,6 +152,6 @@ class Plugin extends AbstractPlugin implements PluginInterface
|
||||
*/
|
||||
public static function getVersion()
|
||||
{
|
||||
return '1.0.0';
|
||||
return '1.1.0';
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ It hides banned threads and visitors on the awaiting page.
|
||||
|
||||
## Installation
|
||||
|
||||
1. Get the archive with the plugin sources. At the moment the only option is to build the plugin from sources.
|
||||
1. Get the archive with the plugin sources. You can download it from the [official site](https://mibew.org/plugins#mibew-real-ban) or build the plugin from sources.
|
||||
2. Untar/unzip the plugin's archive.
|
||||
3. Put files of the plugins to the `<Mibew root>/plugins` folder.
|
||||
4. Navigate to "`<Mibew Base URL>`/operator/plugin" page and enable the plugin.
|
||||
|
@ -21,9 +21,7 @@ gulp.task('prepare-release', function() {
|
||||
});
|
||||
|
||||
// Builds and packs plugins sources
|
||||
gulp.task('default', ['prepare-release'], function() {
|
||||
// The "default" task is just an alias for "prepare-release" task.
|
||||
});
|
||||
gulp.task('default', gulp.series('prepare-release'));
|
||||
|
||||
/**
|
||||
* Returns files stream with the plugin sources.
|
||||
|
10
package.json
10
package.json
@ -1,12 +1,12 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"devDependencies": {
|
||||
"gulp": "~3.8.10",
|
||||
"gulp": "~4.0.0",
|
||||
"event-stream": "~3.1.7",
|
||||
"gulp-zip": "~2.0.2",
|
||||
"gulp-tar": "~1.3.1",
|
||||
"gulp-tar": "~3.1.0",
|
||||
"gulp-gzip": "~0.0.8",
|
||||
"gulp-chmod": "~1.2.0",
|
||||
"gulp-chmod": "~3.0.0",
|
||||
"gulp-rename": "~1.2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user