upgrade to Dotclear 2.27
This commit is contained in:
parent
4d307f01cd
commit
71b546d652
5 changed files with 29 additions and 68 deletions
|
@ -16,7 +16,7 @@ namespace Dotclear\Plugin\dcFilterDuplicate;
|
|||
|
||||
use dcBlog;
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use Dotclear\Core\Backend\Notices;
|
||||
use Dotclear\Database\Statement\{
|
||||
JoinStatement,
|
||||
SelectStatement
|
||||
|
@ -115,14 +115,14 @@ class FilterDuplicate extends SpamFilter
|
|||
public function gui(string $url): string
|
||||
{
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog)) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (dcCore::app()->auth->isSuperAdmin()) {
|
||||
dcCore::app()->blog->settings->get(My::id())->drop(My::SETTING_PREFIX . 'minlen');
|
||||
My::settings()->drop(My::SETTING_PREFIX . 'minlen');
|
||||
if (isset($_POST[My::SETTING_PREFIX . 'minlen'])) {
|
||||
dcCore::app()->blog->settings->get(My::id())->put(
|
||||
My::settings()->put(
|
||||
My::SETTING_PREFIX . 'minlen',
|
||||
abs((int) $_POST[My::SETTING_PREFIX . 'minlen']),
|
||||
'integer',
|
||||
|
@ -130,7 +130,7 @@ class FilterDuplicate extends SpamFilter
|
|||
true,
|
||||
true
|
||||
);
|
||||
dcPage::addSuccessNotice(__('Configuration successfully updated.'));
|
||||
Notices::addSuccessNotice(__('Configuration successfully updated.'));
|
||||
Http::redirect($url);
|
||||
}
|
||||
|
||||
|
@ -157,11 +157,11 @@ class FilterDuplicate extends SpamFilter
|
|||
private function getMinLength(): int
|
||||
{
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog)) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return abs((int) dcCore::app()->blog->settings->get(My::id())->getGlobal(My::SETTING_PREFIX . 'minlen'));
|
||||
return abs((int) My::settings()->getGlobal(My::SETTING_PREFIX . 'minlen'));
|
||||
}
|
||||
|
||||
public function triggerOtherBlogs(string $content, string $ip): void
|
||||
|
|
|
@ -15,49 +15,32 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\dcFilterDuplicate;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Exception;
|
||||
|
||||
class Install extends dcNsProcess
|
||||
class Install extends Process
|
||||
{
|
||||
# -- Module specs --
|
||||
private static array $mod_conf = [[
|
||||
'dcfilterduplicate_minlen',
|
||||
'Minimum lenght of comment to filter',
|
||||
30,
|
||||
'integer',
|
||||
]];
|
||||
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::INSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
# Set module settings
|
||||
foreach (self::$mod_conf as $v) {
|
||||
dcCore::app()->blog->settings->get(My::id())->put(
|
||||
$v[0],
|
||||
$v[2],
|
||||
$v[3],
|
||||
$v[1],
|
||||
false,
|
||||
true
|
||||
);
|
||||
}
|
||||
My::settings()->put(
|
||||
My::SETTING_PREFIX . 'minlen',
|
||||
30,
|
||||
'integer',
|
||||
'Minimum lenght of comment to filter',
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
|
|
22
src/My.php
22
src/My.php
|
@ -14,31 +14,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\dcFilterDuplicate;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
*/
|
||||
class My
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/** @var string Plugin setting prefix */
|
||||
public const SETTING_PREFIX = 'dcfilterduplicate_';
|
||||
|
||||
/**
|
||||
* This module id.
|
||||
*/
|
||||
public static function id(): string
|
||||
{
|
||||
return basename(dirname(__DIR__));
|
||||
}
|
||||
|
||||
/**
|
||||
* This module name.
|
||||
*/
|
||||
public static function name(): string
|
||||
{
|
||||
$name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
|
||||
|
||||
return __(is_string($name) ? $name : self::id());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,20 +15,18 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\dcFilterDuplicate;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
class Prepend extends dcNsProcess
|
||||
class Prepend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = true;
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::PREPEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,21 +15,19 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\dcFilterDuplicate;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
class Uninstall extends dcNsProcess
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::UNINSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue