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