upgrade to Dotclear 2.28
This commit is contained in:
parent
633579fa89
commit
abb7b14ccb
@ -1,3 +1,9 @@
|
||||
dcFilterDuplicate 1.4 - 2023.10.15
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
dcFilterDuplicate 1.3 - 2023.08.06
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
35
README.md
35
README.md
@ -1,24 +1,22 @@
|
||||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-1.3-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/dcFilterDuplicate/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.08.06-c44d58.svg)](https://git.dotclear.watch/JcDenis/dcFilterDuplicate/releases)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Release](https://img.shields.io/badge/release-1.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/dcFilterDuplicate/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.10.15-c44d58.svg)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/dcFilterDuplicate)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/dcFilterDuplicate)](https://git.dotclear.watch/JcDenis/dcFilterDuplicate/blob/master/LICENSE)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/dcFilterDuplicate/src/branch/master/LICENSE)
|
||||
|
||||
## WHAT IS DCFILTERDUPLICATE ?
|
||||
## ABOUT
|
||||
|
||||
dcFilterDuplicate "Dupicate comments filter" is a plugin for the
|
||||
open-source web publishing software called Dotclear.
|
||||
_dcFilterDuplicate_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
|
||||
Filter as spam same (duplicate) comments from multiple blogs of a Dotclear's install.
|
||||
> Filter as spam same (duplicate) comments from multiple blogs of a Dotclear's install.
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
dcFilterDuplicate requires:
|
||||
|
||||
* permissions to manage antispam
|
||||
* Dotclear 2.27
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1
|
||||
* Dotclear permissions to manage antispam
|
||||
|
||||
## USAGE
|
||||
|
||||
@ -29,13 +27,14 @@ Enable and configure "Dupicate comments filter" from antispam manager.
|
||||
|
||||
## MORE
|
||||
|
||||
* License : GNU GPL v2
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/dcFilterDuplicate) or [GitHub Page](https://github.com/JcDenis/dcFilterDuplicate)
|
||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/dcFilterDuplicate/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/dcFilterDuplicate)
|
||||
* [License](https://git.dotclear.watch/JcDenis/dcFilterDuplicate/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/dcFilterDuplicate/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/dcFilterDuplicate))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/dcFilterDuplicate) (or on [GitHub](https://github.com/JcDenis/dcFilterDuplicate))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/dcFilterDuplicate/issues) (or on [GitHub](https://github.com/JcDenis/dcFilterDuplicate/issues))
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Jean-Chirstian Denis
|
||||
* Pierre Van Glabeke
|
||||
* Jean-Chirstian Denis (author)
|
||||
* Pierre Van Glabeke
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
You are welcome to contribute to this code.
|
||||
|
36
_define.php
36
_define.php
@ -1,33 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief dcFilterDuplicate, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin dcFilterDuplicate definition
|
||||
* @ingroup dcFilterDuplicate
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
* @defgroup dcFilterDuplicate Plugin dcFilterDuplicate.
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
* Antispam for duplicate comments on multiblog.
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Tomtom (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
declare(strict_types=1);
|
||||
|
||||
$this->registerModule(
|
||||
'Duplicate filter',
|
||||
'Antispam for duplicate comments on multiblog',
|
||||
'Jean-Christian Denis, Pierre Van Glabeke',
|
||||
'1.3',
|
||||
'1.4',
|
||||
[
|
||||
'requires' => [['core', '2.27']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||
]),
|
||||
'priority' => 200,
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => 'My',
|
||||
'priority' => 200,
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||
]
|
||||
);
|
||||
|
@ -2,11 +2,11 @@
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="dcFilterDuplicate">
|
||||
<name>Duplicate filter</name>
|
||||
<version>1.3</version>
|
||||
<version>1.4</version>
|
||||
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
|
||||
<desc>Antispam for duplicate comments on multiblog</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/dcFilterDuplicate/releases/download/v1.3/plugin-dcFilterDuplicate.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/dcFilterDuplicate/releases/download/v1.4/plugin-dcFilterDuplicate.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/dcFilterDuplicate/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/dcFilterDuplicate/issues</da:support>
|
||||
</module>
|
||||
|
@ -1,21 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief dcFilterDuplicate, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\dcFilterDuplicate;
|
||||
|
||||
use dcBlog;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Notices;
|
||||
use Dotclear\Database\Statement\{
|
||||
JoinStatement,
|
||||
@ -34,14 +23,16 @@ use Dotclear\Plugin\antispam\SpamFilter;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @ingroup DC_PLUGIN_DCFILTERDUPLICATE
|
||||
* @brief Filter duplicate comments on multiblogs.
|
||||
* @since 2.6
|
||||
* @brief dcFilterDuplicate antispam class.
|
||||
* @ingroup dcFilterDuplicate
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class FilterDuplicate extends SpamFilter
|
||||
{
|
||||
public $name = 'Duplicate filter';
|
||||
public $has_gui = true;
|
||||
public string $name = 'Duplicate filter';
|
||||
public bool $has_gui = true;
|
||||
|
||||
protected function setInfo(): void
|
||||
{
|
||||
@ -49,7 +40,7 @@ class FilterDuplicate extends SpamFilter
|
||||
$this->description = __('Same comments on others blogs of a multiblog');
|
||||
}
|
||||
|
||||
public function isSpam(string $type, ?string $author, ?string $email, ?string $site, ?string $ip, ?string $content, ?int $post_id, string &$status): ?bool
|
||||
public function isSpam(string $type, ?string $author, ?string $email, ?string $site, ?string $ip, ?string $content, ?int $post_id, string &$status)
|
||||
{
|
||||
if ($type != 'comment' || is_null($content) || is_null($ip)) {
|
||||
return null;
|
||||
@ -74,21 +65,20 @@ class FilterDuplicate extends SpamFilter
|
||||
|
||||
public function isDuplicate(string $content, string $ip): bool
|
||||
{
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = new SelectStatement();
|
||||
$rs = $sql->from($sql->as(dcCore::app()->prefix . dcBlog::COMMENT_TABLE_NAME, 'C'))
|
||||
$rs = $sql->from($sql->as(App::con()->prefix() . App::blog()::COMMENT_TABLE_NAME, 'C'))
|
||||
->join(
|
||||
(new JoinStatement())
|
||||
->left()
|
||||
->from($sql->as(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME, 'P'))
|
||||
->from($sql->as(App::con()->prefix() . App::blog()::POST_TABLE_NAME, 'P'))
|
||||
->on('C.post_id = P.post_id')
|
||||
->statement()
|
||||
)
|
||||
->where('P.blog_id != ' . $sql->quote(dcCore::app()->blog->id))
|
||||
->where('P.blog_id != ' . $sql->quote(App::blog()->id()))
|
||||
->and('C.comment_content = ' . $sql->quote($content))
|
||||
->and('C.comment_ip=' . $sql->quote($ip))
|
||||
->select();
|
||||
@ -98,28 +88,27 @@ class FilterDuplicate extends SpamFilter
|
||||
|
||||
public function markDuplicate(string $content, string $ip): void
|
||||
{
|
||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcBlog::COMMENT_TABLE_NAME);
|
||||
dcCore::app()->con->writeLock(dcCore::app()->prefix . dcBlog::COMMENT_TABLE_NAME);
|
||||
$cur = App::blog()->openCommentCursor();
|
||||
App::con()->writeLock(App::con()->prefix() . App::blog()::COMMENT_TABLE_NAME);
|
||||
|
||||
$cur->setField('comment_status', -2);
|
||||
$cur->setField('comment_spam_status', 'Duplicate on other blog');
|
||||
$cur->setField('comment_spam_filter', My::id());
|
||||
$cur->update(
|
||||
"WHERE comment_content='" . dcCore::app()->con->escapeStr($content) . "' " .
|
||||
"WHERE comment_content='" . App::con()->escapeStr($content) . "' " .
|
||||
"AND comment_ip='" . $ip . "' "
|
||||
);
|
||||
dcCore::app()->con->unlock();
|
||||
App::con()->unlock();
|
||||
$this->triggerOtherBlogs($content, $ip);
|
||||
}
|
||||
|
||||
public function gui(string $url): string
|
||||
{
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (dcCore::app()->auth->isSuperAdmin()) {
|
||||
if (App::auth()->isSuperAdmin()) {
|
||||
My::settings()->drop(My::SETTING_PREFIX . 'minlen');
|
||||
if (isset($_POST[My::SETTING_PREFIX . 'minlen'])) {
|
||||
My::settings()->put(
|
||||
@ -142,7 +131,7 @@ class FilterDuplicate extends SpamFilter
|
||||
]),
|
||||
(new Para())->items([
|
||||
(new Submit('save'))->value(__('Save')),
|
||||
dcCore::app()->formNonce(false),
|
||||
App::nonce()->formNonce(),
|
||||
]),
|
||||
])->render();
|
||||
}
|
||||
@ -156,8 +145,7 @@ class FilterDuplicate extends SpamFilter
|
||||
|
||||
private function getMinLength(): int
|
||||
{
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -167,12 +155,12 @@ class FilterDuplicate extends SpamFilter
|
||||
public function triggerOtherBlogs(string $content, string $ip): void
|
||||
{
|
||||
$sql = new SelectStatement();
|
||||
$rs = $sql->from($sql->as(dcCore::app()->prefix . dcBlog::COMMENT_TABLE_NAME, 'C'))
|
||||
$rs = $sql->from($sql->as(App::con()->prefix() . App::blog()::COMMENT_TABLE_NAME, 'C'))
|
||||
->column('P.blog_id')
|
||||
->join(
|
||||
(new JoinStatement())
|
||||
->left()
|
||||
->from($sql->as(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME, 'P'))
|
||||
->from($sql->as(App::con()->prefix() . App::blog()::POST_TABLE_NAME, 'P'))
|
||||
->on('C.post_id = P.post_id')
|
||||
->statement()
|
||||
)
|
||||
@ -184,10 +172,12 @@ class FilterDuplicate extends SpamFilter
|
||||
return;
|
||||
}
|
||||
|
||||
$old = App::blog()->id();
|
||||
|
||||
while ($rs->fetch()) {
|
||||
$b = new dcBlog($rs->f('blog_id'));
|
||||
$b->triggerBlog();
|
||||
unset($b);
|
||||
App::blog()->loadFromBlog($rs->f('blog_id'))->triggerBlog();
|
||||
}
|
||||
|
||||
App::blog()->loadFromBlog($old);
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief dcFilterDuplicate, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\dcFilterDuplicate;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief dcFilterDuplicate install class.
|
||||
* @ingroup dcFilterDuplicate
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Install extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -44,7 +41,7 @@ class Install extends Process
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
26
src/My.php
26
src/My.php
@ -1,15 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief dcFilterDuplicate, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\dcFilterDuplicate;
|
||||
@ -17,10 +7,20 @@ namespace Dotclear\Plugin\dcFilterDuplicate;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
* @brief dcFilterDuplicate My helper.
|
||||
* @ingroup dcFilterDuplicate
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/** @var string Plugin setting prefix */
|
||||
/**
|
||||
* Plugin setting prefix.
|
||||
*
|
||||
* @var string SETTING_PREFIX
|
||||
*/
|
||||
public const SETTING_PREFIX = 'dcfilterduplicate_';
|
||||
|
||||
// Use default permissions
|
||||
}
|
||||
|
@ -1,22 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief dcFilterDuplicate, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\dcFilterDuplicate;
|
||||
|
||||
use dcCore;
|
||||
use ArrayObject;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief dcFilterDuplicate prepend class.
|
||||
* @ingroup dcFilterDuplicate
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Prepend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -30,7 +28,9 @@ class Prepend extends Process
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->spamfilters[] = FilterDuplicate::class;
|
||||
App::behavior()->addBehavior('AntispamInitFilters', function (ArrayObject $spamfilters): void {
|
||||
$spamfilters[] = FilterDuplicate::class;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,23 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief dcFilterDuplicate, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\dcFilterDuplicate;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
/**
|
||||
* @brief dcFilterDuplicate uninstall class.
|
||||
* @ingroup dcFilterDuplicate
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -27,7 +23,7 @@ class Uninstall extends Process
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user