From 03ba85d38ed895e7f61f7d39c671929378925784 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 18 Mar 2023 23:14:41 +0100 Subject: [PATCH] check php version --- src/Backend.php | 2 +- src/Config.php | 8 +++++--- src/Install.php | 5 ++++- src/Manage.php | 5 +++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Backend.php b/src/Backend.php index aa243fe..e9b4a52 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -35,7 +35,7 @@ class Backend extends dcNsProcess public static function init(): bool { if (defined('DC_CONTEXT_ADMIN')) { - self::$init = true; + self::$init = dcCore::app()->auth->isSuperAdmin() && version_compare(phpversion(), My::PHP_MIN, '>='); } return self::$init; diff --git a/src/Config.php b/src/Config.php index cf23682..9a51fdf 100644 --- a/src/Config.php +++ b/src/Config.php @@ -43,10 +43,12 @@ class Config extends dcNsProcess public static function init(): bool { if (defined('DC_CONTEXT_ADMIN')) { - dcPage::checkSuper(); - self::$init = true; + if (version_compare(phpversion(), My::PHP_MIN, '>=')) { + self::$init = dcCore::app()->auth->isSuperAdmin(); + } else { + dcCore::app()->error->add(sprintf(__('%s required php >= %s'), My::id(), My::PHP_MIN)); + } } - return self::$init; } diff --git a/src/Install.php b/src/Install.php index a873835..1201403 100644 --- a/src/Install.php +++ b/src/Install.php @@ -40,7 +40,10 @@ class Install extends dcNsProcess public static function init(): bool { - self::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version')); + if (defined('DC_CONTEXT_ADMIN')) { + self::$init = version_compare(phpversion(), My::PHP_MIN, '>=') + && dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version')); + } return self::$init; } diff --git a/src/Manage.php b/src/Manage.php index 182082e..f3fa2a2 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -51,13 +51,14 @@ class Manage extends dcNsProcess public static function init(): bool { if (defined('DC_CONTEXT_ADMIN')) { - dcPage::checkSuper(); + self::$init = dcCore::app()->auth->isSuperAdmin() && version_compare(phpversion(), My::PHP_MIN, '>='); + } + if (self::$init) { self::$improve = new Core(); self::$type = self::getType(); self::$module = self::getModule(); self::$action = self::getAction(); - self::$init = true; } return self::$init;