From d3818b273ccb1adb44fad687cae02f8a320ccb8d Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sun, 13 Aug 2023 22:10:06 +0200 Subject: [PATCH] upgrade to Dotclear 2.27 --- src/Backend.php | 10 ++++------ src/BackendBehaviors.php | 10 ---------- src/Frontend.php | 10 ++++------ src/My.php | 21 +++++++++++++++++++++ 4 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 src/My.php diff --git a/src/Backend.php b/src/Backend.php index 3f0ea31..67ce112 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -15,20 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\topWriter; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; -class Backend extends dcNsProcess +class Backend extends Process { public static function init(): bool { - static::$init = defined('DC_CONTEXT_ADMIN'); - - return static::$init; + return self::status(My::checkContext(My::BACKEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php index 235e587..d2b4074 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -114,11 +114,6 @@ class BackendBehaviors public static function adminAfterDashboardOptionsUpdate(?string $user_id): void { - // nullsafe - if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) { - return; - } - dcCore::app()->auth->user_prefs->get('dashboard')->put( 'topWriterPostsItems', !empty($_POST['topWriterPostsItems']), @@ -154,11 +149,6 @@ class BackendBehaviors private static function setDefaultPref(): array { - // nullsafe - if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) { - return []; - } - if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterPostsItems')) { dcCore::app()->auth->user_prefs->get('dashboard')->put( 'topWriterPostsItems', diff --git a/src/Frontend.php b/src/Frontend.php index 6e10052..2a64b6b 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -15,20 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\topWriter; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; -class Frontend extends dcNsProcess +class Frontend extends Process { public static function init(): bool { - static::$init = true; - - return static::$init; + return self::status(My::checkContext(My::FRONTEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } diff --git a/src/My.php b/src/My.php new file mode 100644 index 0000000..f1ae0e5 --- /dev/null +++ b/src/My.php @@ -0,0 +1,21 @@ +