From 0d0e69ccc34f698530c789edd3c2a6bacdc0d562 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 12 Aug 2023 18:20:12 +0200 Subject: [PATCH] upgrade to Dotclear 2.27 --- src/Backend.php | 10 ++++------ src/BackendBehaviors.php | 5 ----- src/Frontend.php | 12 +++++------- src/My.php | 21 +++++++++++++++++++++ 4 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 src/My.php diff --git a/src/Backend.php b/src/Backend.php index 01c9001..2bd4c10 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -15,20 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\emailNotification; 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 8ed0441..6e870c8 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -26,11 +26,6 @@ class BackendBehaviors { public static function adminUserForm(): void { - // nullsafe PHP < 8.0 - if (is_null(dcCore::app()->auth)) { - return; - } - $options = dcCore::app()->auth->getOptions(); echo diff --git a/src/Frontend.php b/src/Frontend.php index fecbe1d..c3dbb4b 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -17,7 +17,7 @@ namespace Dotclear\Plugin\emailNotification; use dcAuth; use dcBlog; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; use Dotclear\Database\{ Cursor, MetaRecord @@ -30,24 +30,22 @@ use Dotclear\Helper\Html\Html; use Dotclear\Helper\Network\Mail\Mail; use rsExtUser; -class Frontend extends dcNsProcess +class Frontend extends Process { public static function init(): bool { - static::$init = defined('DC_RC_PATH'); - - return static::$init; + return self::status(My::checkContext(My::FRONTEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } dcCore::app()->addBehavior('publicAfterCommentCreate', function (Cursor $cur, ?int $comment_id): void { // nullsafe PHP < 8.0 - if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog)) { + if (is_null(dcCore::app()->blog)) { return; } diff --git a/src/My.php b/src/My.php new file mode 100644 index 0000000..6ffabdc --- /dev/null +++ b/src/My.php @@ -0,0 +1,21 @@ +