release 1.4
This commit is contained in:
parent
11ce530dff
commit
2493f16f97
11 changed files with 166 additions and 201 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
whiteListCom 1.4 - 2023.10.11
|
||||||
|
===========================================================
|
||||||
|
* Require Dotclear 2.27
|
||||||
|
* Require PHP 8.1
|
||||||
|
* Upgrade to Dotclear 2.28
|
||||||
|
|
||||||
whiteListCom 1.3.1 - 2023.08.13
|
whiteListCom 1.3.1 - 2023.08.13
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.27
|
* Require Dotclear 2.27
|
||||||
|
|
29
README.md
29
README.md
|
@ -1,26 +1,22 @@
|
||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-1.3.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/whiteListCom/releases)
|
[![Release](https://img.shields.io/badge/release-1.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/whiteListCom/releases)
|
||||||
[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/whiteListCom/releases)
|
![Date](https://img.shields.io/badge/date-2023.10.11-c44d58.svg)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
[![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/whiteListCom)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/whiteListCom)
|
||||||
[![License](https://img.shields.io/github/license/JcDenis/whiteListCom)](https://git.dotclear.watch/JcDenis/whiteListCom/blob/master/LICENSE)
|
[![License](https://img.shields.io/github/license/JcDenis/whiteListCom)](https://git.dotclear.watch/JcDenis/whiteListCom/blob/master/LICENSE)
|
||||||
|
|
||||||
## WHAT IS WHITELISTCOM ?
|
## ABOUT
|
||||||
|
|
||||||
_whiteListCom_ "White list for comments" is a plugin for the open-source
|
_tinyPacker_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||||
web publishing software called Dotclear.
|
|
||||||
|
|
||||||
Set up a list of users which can publish comments without validation
|
> Set up a list of users which can publish comments without validation and a list of reserved names (pair of nickname / email ).
|
||||||
and a list of reserved names (pair of nickname / email ).
|
|
||||||
|
|
||||||
## REQUIREMENTS
|
## REQUIREMENTS
|
||||||
|
|
||||||
_whiteListCom_ requires:
|
* Dotclear 2.28
|
||||||
|
* PHP 8.1+
|
||||||
* permissions to manage antispam
|
* permissions to manage antispam
|
||||||
* Dotclear 2.27
|
|
||||||
* PHP 7.4
|
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
@ -33,12 +29,13 @@ Note: User must write a comment before able to be added to the list.
|
||||||
|
|
||||||
## LINKS
|
## LINKS
|
||||||
|
|
||||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
* [License](https://git.dotclear.watch/JcDenis/whiteListCom/src/branch/master/LICENSE)
|
||||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/whiteListCom) or [GitHub Page](https://github.com/JcDenis/whiteListCom)
|
* [Packages & details](https://git.dotclear.watch/JcDenis/whiteListCom/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/whiteListCom))
|
||||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/whiteListCom/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/whiteListCom)
|
* [Sources & contributions](https://git.dotclear.watch/JcDenis/whiteListCom) (or on [GitHub](https://github.com/JcDenis/whiteListCom))
|
||||||
|
* [Issues & security](https://git.dotclear.watch/JcDenis/whiteListCom/issues) (or on [GitHub](https://github.com/JcDenis/whiteListCom/issues))
|
||||||
|
|
||||||
## CONTRIBUTORS
|
## CONTRIBUTORS
|
||||||
|
|
||||||
* Jean-Christian Denis
|
* Jean-Christian Denis (author)
|
||||||
|
|
||||||
You are welcome to contribute to this code.
|
You are welcome to contribute to this code.
|
||||||
|
|
36
_define.php
36
_define.php
|
@ -1,37 +1,33 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief whiteListCom, a plugin for Dotclear 2
|
* @file
|
||||||
|
* @brief The plugin whiteListCom definition
|
||||||
|
* @ingroup whiteListCom
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @defgroup whiteListCom Plugin whiteListCom.
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* Whitelists for comments moderation.
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @author Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
declare(strict_types=1);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
'Whitelist comments',
|
'Whitelist comments',
|
||||||
'Whitelists for comments moderation',
|
'Whitelists for comments moderation',
|
||||||
'Jean-Christian Denis and Contributors',
|
'Jean-Christian Denis and Contributors',
|
||||||
'1.3.1',
|
'1.4',
|
||||||
[
|
[
|
||||||
'requires' => [
|
'requires' => [
|
||||||
['core', '2.27'],
|
['core', '2.28'],
|
||||||
['antispam', '2.0'],
|
['antispam', '2.0'],
|
||||||
],
|
],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => 'My',
|
||||||
dcCore::app()->auth::PERMISSION_USAGE,
|
'priority' => 200,
|
||||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
'type' => 'plugin',
|
||||||
]),
|
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||||
'priority' => 200,
|
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||||
'type' => 'plugin',
|
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||||
'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/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="whiteListCom">
|
<module id="whiteListCom">
|
||||||
<name>Whitelist comments</name>
|
<name>Whitelist comments</name>
|
||||||
<version>1.3.1</version>
|
<version>1.4</version>
|
||||||
<author>Jean-Christian Denis and Contributors</author>
|
<author>Jean-Christian Denis and Contributors</author>
|
||||||
<desc>Whitelists for comments moderation</desc>
|
<desc>Whitelists for comments moderation</desc>
|
||||||
<file>https://git.dotclear.watch/JcDenis/whiteListCom/releases/download/v1.3.1/plugin-whiteListCom.zip</file>
|
<file>https://git.dotclear.watch/JcDenis/whiteListCom/releases/download/v1.4/plugin-whiteListCom.zip</file>
|
||||||
<da:dcmin>2.27</da:dcmin>
|
<da:dcmin>2.28</da:dcmin>
|
||||||
<da:details>https://git.dotclear.watch/JcDenis/whiteListCom/src/branch/master/README.md</da:details>
|
<da:details>https://git.dotclear.watch/JcDenis/whiteListCom/src/branch/master/README.md</da:details>
|
||||||
<da:support>https://git.dotclear.watch/JcDenis/whiteListCom/issues</da:support>
|
<da:support>https://git.dotclear.watch/JcDenis/whiteListCom/issues</da:support>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief whiteListCom, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and Contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\whiteListCom;
|
namespace Dotclear\Plugin\whiteListCom;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use dcNamespace;
|
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief whiteListCom install class.
|
||||||
|
* @ingroup whiteListCom
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class Install extends Process
|
class Install extends Process
|
||||||
{
|
{
|
||||||
// Module specs
|
/**
|
||||||
|
* Module specs.
|
||||||
|
*
|
||||||
|
* @var array<int,array<int,string|array>> $mod_conf
|
||||||
|
*/
|
||||||
private static array $mod_conf = [
|
private static array $mod_conf = [
|
||||||
[
|
[
|
||||||
'unmoderated',
|
'unmoderated',
|
||||||
|
@ -66,7 +66,7 @@ class Install extends Process
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
App::error()->add($e->getMessage());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -74,25 +74,25 @@ class Install extends Process
|
||||||
|
|
||||||
public static function growUp(): void
|
public static function growUp(): void
|
||||||
{
|
{
|
||||||
$current = dcCore::app()->getVersion(My::id());
|
$current = App::version()->getVersion(My::id());
|
||||||
|
|
||||||
// Update settings id, ns
|
// Update settings id, ns
|
||||||
if ($current && version_compare($current, '1.0', '<')) {
|
if ($current && version_compare($current, '1.0', '<')) {
|
||||||
$record = dcCore::app()->con->select(
|
$record = App::con()->select(
|
||||||
'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' .
|
'SELECT * FROM ' . App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME . ' ' .
|
||||||
"WHERE setting_ns = 'whiteListCom' "
|
"WHERE setting_ns = 'whiteListCom' "
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($record->fetch()) {
|
while ($record->fetch()) {
|
||||||
if (preg_match('/^whiteListCom(.*?)$/', $record->f('setting_id'), $match)) {
|
if (preg_match('/^whiteListCom(.*?)$/', $record->f('setting_id'), $match)) {
|
||||||
$value = @unserialize(@base64_decode($record->f('setting_value')));
|
$value = @unserialize(@base64_decode($record->f('setting_value')));
|
||||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
$cur = App::blogWorkspace()->openBlogWorkspaceCursor();
|
||||||
$cur->setField('setting_id', $match[1]);
|
$cur->setField('setting_id', $match[1]);
|
||||||
$cur->setField('setting_ns', My::id());
|
$cur->setField('setting_ns', My::id());
|
||||||
$cur->setField('setting_value', is_array($value) ? json_encode($value) : '[]');
|
$cur->setField('setting_value', is_array($value) ? json_encode($value) : '[]');
|
||||||
$cur->update(
|
$cur->update(
|
||||||
"WHERE setting_id = '" . $record->f('setting_id') . "' and setting_ns = 'whiteListCom' " .
|
"WHERE setting_id = '" . $record->f('setting_id') . "' and setting_ns = 'whiteListCom' " .
|
||||||
'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . dcCore::app()->con->escapeStr((string) $record->f('blog_id')) . "' "))
|
'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . App::con()->escapeStr((string) $record->f('blog_id')) . "' "))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
19
src/My.php
19
src/My.php
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief whiteListCom, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and Contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\whiteListCom;
|
namespace Dotclear\Plugin\whiteListCom;
|
||||||
|
@ -17,8 +7,13 @@ namespace Dotclear\Plugin\whiteListCom;
|
||||||
use Dotclear\Module\MyPlugin;
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module definitions.
|
* @brief whiteListCom My helper.
|
||||||
|
* @ingroup whiteListCom
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class My extends MyPlugin
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
|
// Use default permissions
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief whiteListCom, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and Contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\whiteListCom;
|
namespace Dotclear\Plugin\whiteListCom;
|
||||||
|
|
||||||
use dcBlog;
|
use ArrayObject;
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
|
use Dotclear\Database\Cursor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief whiteListCom prepend class.
|
||||||
|
* @ingroup whiteListCom
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class Prepend extends Process
|
class Prepend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -31,30 +29,32 @@ class Prepend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->spamfilters[] = UnmoderatedWhiteList::class;
|
App::behavior()->addBehaviors([
|
||||||
dcCore::app()->spamfilters[] = ReservedWhiteList::class;
|
'AntispamInitFilters' => function (ArrayObject $spamfilters): void {
|
||||||
|
$spamfilters[] = UnmoderatedWhiteList::class;
|
||||||
|
$spamfilters[] = ReservedWhiteList::class;
|
||||||
|
},
|
||||||
|
'publicAfterCommentCreate' => function (Cursor $cur, int $id): void {
|
||||||
|
if (!App::blog()->isDefined() || App::blog()->settings()->get('system')->get('comments_pub')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehavior('publicAfterCommentCreate', function ($cur, $id): void {
|
if ($cur->__get('comment_spam_filter') == 'UnmoderatedWhiteList'
|
||||||
if (dcCore::app()->blog === null
|
&& $cur->__get('comment_spam_status') == 'unmoderated') {
|
||||||
|| dcCore::app()->blog->settings->get('system')->get('comments_pub')) {
|
App::con()->writeLock(App::con()->prefix() . App::blog()::COMMENT_TABLE_NAME);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($cur->__get('comment_spam_filter') == 'UnmoderatedWhiteList'
|
$cur->__set('comment_status', 1);
|
||||||
&& $cur->__get('comment_spam_status') == 'unmoderated') {
|
$cur->__set('comment_spam_status', 0);
|
||||||
dcCore::app()->con->writeLock(dcCore::app()->prefix . dcBlog::COMMENT_TABLE_NAME);
|
$cur->__set('comment_spam_filter', 0);
|
||||||
|
$cur->update('WHERE comment_id = ' . $id . ' ');
|
||||||
|
|
||||||
$cur->__set('comment_status', 1);
|
App::con()->unlock();
|
||||||
$cur->__set('comment_spam_status', 0);
|
|
||||||
$cur->__set('comment_spam_filter', 0);
|
|
||||||
$cur->update('WHERE comment_id = ' . $id . ' ');
|
|
||||||
|
|
||||||
dcCore::app()->con->unlock();
|
App::blog()->triggerComment($id);
|
||||||
|
App::blog()->triggerBlog();
|
||||||
dcCore::app()->blog->triggerComment($id);
|
}
|
||||||
dcCore::app()->blog->triggerBlog();
|
},
|
||||||
}
|
]);
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief whiteListCom, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and Contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\whiteListCom;
|
namespace Dotclear\Plugin\whiteListCom;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Backend\Notices;
|
use Dotclear\Core\Backend\Notices;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Checkbox,
|
Checkbox,
|
||||||
|
@ -26,19 +16,18 @@ use Dotclear\Plugin\antispam\SpamFilter;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup DC_PLUGIN_WHITELISTCOM
|
* @brief whiteListCom resserved name antispam filter.
|
||||||
* @brief Filter for reserved names.
|
* @ingroup whiteListCom
|
||||||
* @since 2.6
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class ReservedWhiteList extends SpamFilter
|
class ReservedWhiteList extends SpamFilter
|
||||||
{
|
{
|
||||||
public $name = 'Reserved names';
|
public string $name = 'Reserved names';
|
||||||
public $has_gui = true;
|
public bool $has_gui = true;
|
||||||
|
|
||||||
/**
|
protected function setInfo(): void
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function setInfo()
|
|
||||||
{
|
{
|
||||||
$this->name = __('Reserved names');
|
$this->name = __('Reserved names');
|
||||||
$this->description = __('Whitelist of reserved names of users');
|
$this->description = __('Whitelist of reserved names of users');
|
||||||
|
@ -47,7 +36,7 @@ class ReservedWhiteList extends SpamFilter
|
||||||
/**
|
/**
|
||||||
* @return void|null|bool
|
* @return void|null|bool
|
||||||
*/
|
*/
|
||||||
public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
|
public function isSpam(string $type, ?string $author, ?string $email, ?string $site, ?string $ip, ?string $content, ?int $post_id, string &$status)
|
||||||
{
|
{
|
||||||
if ($type != 'comment') {
|
if ($type != 'comment') {
|
||||||
return null;
|
return null;
|
||||||
|
@ -72,10 +61,7 @@ class ReservedWhiteList extends SpamFilter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getStatusMessage(string $status, ?int $comment_id): string
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getStatusMessage($status, $comment_id)
|
|
||||||
{
|
{
|
||||||
return __('This name is reserved to an other user.');
|
return __('This name is reserved to an other user.');
|
||||||
}
|
}
|
||||||
|
@ -97,7 +83,7 @@ class ReservedWhiteList extends SpamFilter
|
||||||
|
|
||||||
$comments = Utils::getCommentsUsers();
|
$comments = Utils::getCommentsUsers();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
App::error()->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = '<form action="' . Html::escapeURL($url) . '" method="post">' .
|
$res = '<form action="' . Html::escapeURL($url) . '" method="post">' .
|
||||||
|
@ -124,7 +110,7 @@ class ReservedWhiteList extends SpamFilter
|
||||||
$res .= '</tbody>' .
|
$res .= '</tbody>' .
|
||||||
'</table>' .
|
'</table>' .
|
||||||
'<p><input type="submit" name="update_reserved" value="' . __('Save') . '" />' .
|
'<p><input type="submit" name="update_reserved" value="' . __('Save') . '" />' .
|
||||||
dcCore::app()->formNonce() . '</p>' .
|
App::nonce()->getFormNonce() . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
|
|
@ -1,23 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief whiteListCom, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and Contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\whiteListCom;
|
namespace Dotclear\Plugin\whiteListCom;
|
||||||
|
|
||||||
use dcCore;
|
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief whiteListCom uninstall class.
|
||||||
|
* @ingroup whiteListCom
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class Uninstall extends Process
|
class Uninstall extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -27,7 +23,7 @@ class Uninstall extends Process
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief whiteListCom, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and Contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\whiteListCom;
|
namespace Dotclear\Plugin\whiteListCom;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\COre\Backend\Notices;
|
use Dotclear\Core\Backend\Notices;
|
||||||
use Dotclear\Helper\Html\Form\Checkbox;
|
use Dotclear\Helper\Html\Form\Checkbox;
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Dotclear\Helper\Network\Http;
|
use Dotclear\Helper\Network\Http;
|
||||||
|
@ -23,21 +13,18 @@ use Dotclear\Plugin\antispam\SpamFilter;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup DC_PLUGIN_WHITELISTCOM
|
* @brief whiteListCom unmoderated antispam filter.
|
||||||
* @brief Filter for unmoderated authors.
|
* @ingroup whiteListCom
|
||||||
* @since 2.6
|
|
||||||
*
|
*
|
||||||
* This filter is used only if comments are moderates
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class UnmoderatedWhiteList extends SpamFilter
|
class UnmoderatedWhiteList extends SpamFilter
|
||||||
{
|
{
|
||||||
public $name = 'Unmoderated authors';
|
public string $name = 'Unmoderated authors';
|
||||||
public $has_gui = true;
|
public bool $has_gui = true;
|
||||||
|
|
||||||
/**
|
protected function setInfo(): void
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function setInfo()
|
|
||||||
{
|
{
|
||||||
$this->name = __('Unmoderated authors');
|
$this->name = __('Unmoderated authors');
|
||||||
$this->description = __('Whitelist of unmoderated authors');
|
$this->description = __('Whitelist of unmoderated authors');
|
||||||
|
@ -46,11 +33,11 @@ class UnmoderatedWhiteList extends SpamFilter
|
||||||
/**
|
/**
|
||||||
* @return void|null|bool
|
* @return void|null|bool
|
||||||
*/
|
*/
|
||||||
public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
|
public function isSpam(string $type, ?string $author, ?string $email, ?string $site, ?string $ip, ?string $content, ?int $post_id, string &$status)
|
||||||
{
|
{
|
||||||
if ($type != 'comment'
|
if ($type != 'comment'
|
||||||
|| dcCore::app()->blog === null
|
|| !App::blog()->isDefined()
|
||||||
|| dcCore::app()->blog->settings->get('system')->get('comments_pub')) {
|
|| App::blog()->settings()->get('system')->get('comments_pub')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,12 +72,12 @@ class UnmoderatedWhiteList extends SpamFilter
|
||||||
$posts = Utils::getPostsUsers();
|
$posts = Utils::getPostsUsers();
|
||||||
$comments = Utils::getCommentsUsers();
|
$comments = Utils::getCommentsUsers();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
App::error()->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = '';
|
$res = '';
|
||||||
|
|
||||||
if (!is_null(dcCore::app()->blog) && dcCore::app()->blog->settings->get('system')->get('comments_pub')) {
|
if (App::blog()->isDefined() && App::blog()->settings()->get('system')->get('comments_pub')) {
|
||||||
$res .= '<p class="message">' .
|
$res .= '<p class="message">' .
|
||||||
__('This filter is used only if comments are moderates') .
|
__('This filter is used only if comments are moderates') .
|
||||||
'</p>';
|
'</p>';
|
||||||
|
@ -141,7 +128,7 @@ class UnmoderatedWhiteList extends SpamFilter
|
||||||
'</div>' .
|
'</div>' .
|
||||||
'</div>' .
|
'</div>' .
|
||||||
'<p><input type="submit" id="update_unmoderated" name="update_unmoderated" value="' . __('Save') . '" />' .
|
'<p><input type="submit" id="update_unmoderated" name="update_unmoderated" value="' . __('Save') . '" />' .
|
||||||
dcCore::app()->formNonce() . '</p>' .
|
App::nonce()->getFormNonce() . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
|
|
@ -1,41 +1,43 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @brief whiteListCom, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and Contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\whiteListCom;
|
namespace Dotclear\Plugin\whiteListCom;
|
||||||
|
|
||||||
use dcBlog;
|
use Dotclear\App;
|
||||||
use dcCore;
|
|
||||||
use dcUtils;
|
|
||||||
use Dotclear\Database\Statement\{
|
use Dotclear\Database\Statement\{
|
||||||
JoinStatement,
|
JoinStatement,
|
||||||
SelectStatement,
|
SelectStatement,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup DC_PLUGIN_WHITELISTCOM
|
* @brief whiteListCom utils.
|
||||||
* @brief White list filters methods
|
* @ingroup whiteListCom
|
||||||
* @since 2.6
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
/** @var bool $init preload check */
|
/**
|
||||||
|
* Preload check.
|
||||||
|
*
|
||||||
|
* @var bool $init
|
||||||
|
*/
|
||||||
private static bool $init = false;
|
private static bool $init = false;
|
||||||
|
|
||||||
/** @var array $unmoderated List of unmoderated users */
|
/**
|
||||||
|
* List of unmoderated users.
|
||||||
|
*
|
||||||
|
* @var array<int,string> $unmoderated
|
||||||
|
*/
|
||||||
private static array $unmoderated = [];
|
private static array $unmoderated = [];
|
||||||
|
|
||||||
/** @var array $unmoderated List of reserved name */
|
/**
|
||||||
|
* List of reserved name.
|
||||||
|
*
|
||||||
|
* @var array<string,string> $reserved
|
||||||
|
*/
|
||||||
private static array $reserved = [];
|
private static array $reserved = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185,18 +187,18 @@ class Utils
|
||||||
*/
|
*/
|
||||||
public static function getPostsUsers(): array
|
public static function getPostsUsers(): array
|
||||||
{
|
{
|
||||||
if (is_null(dcCore::app()->blog)) {
|
if (!App::blog()->isDefined()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$rs = dcCore::app()->blog->getPostsUsers();
|
$rs = App::blog()->getPostsUsers();
|
||||||
if ($rs->isEmpty()) {
|
if ($rs->isEmpty()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = [];
|
$users = [];
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
$name = dcUtils::getUserCN(
|
$name = App::users()->getUserCN(
|
||||||
$rs->f('user_id'),
|
$rs->f('user_id'),
|
||||||
$rs->f('user_name'),
|
$rs->f('user_name'),
|
||||||
$rs->f('user_firstname'),
|
$rs->f('user_firstname'),
|
||||||
|
@ -218,12 +220,12 @@ class Utils
|
||||||
*/
|
*/
|
||||||
public static function getCommentsUsers(): array
|
public static function getCommentsUsers(): array
|
||||||
{
|
{
|
||||||
if (is_null(dcCore::app()->blog)) {
|
if (!App::blog()->isDefined()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = new SelectStatement();
|
$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'))
|
||||||
->columns([
|
->columns([
|
||||||
'comment_author',
|
'comment_author',
|
||||||
'comment_email',
|
'comment_email',
|
||||||
|
@ -231,11 +233,11 @@ class Utils
|
||||||
->join(
|
->join(
|
||||||
(new JoinStatement())
|
(new JoinStatement())
|
||||||
->left()
|
->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')
|
->on('C.post_id = P.post_id')
|
||||||
->statement()
|
->statement()
|
||||||
)
|
)
|
||||||
->where('blog_id = ' . $sql->quote(dcCore::app()->blog->id))
|
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||||
->and('comment_trackback = 0')
|
->and('comment_trackback = 0')
|
||||||
->and("comment_email != ''")
|
->and("comment_email != ''")
|
||||||
->group('comment_email, comment_author') // Added author to fix postgreSql
|
->group('comment_email, comment_author') // Added author to fix postgreSql
|
||||||
|
|
Loading…
Reference in a new issue