diff --git a/_define.php b/_define.php index 10fa218..48e746a 100644 --- a/_define.php +++ b/_define.php @@ -10,7 +10,7 @@ * @copyright Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html */ -if (!defined('DC_RC_PATH')) { +if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) { return null; } @@ -22,9 +22,9 @@ $this->registerModule( [ 'requires' => [['core', '2.26']], 'permissions' => dcCore::app()->auth->makePermissions([ - dcAuth::PERMISSION_USAGE, - dcAuth::PERMISSION_CONTENT_ADMIN, - dcAuth::PERMISSION_ADMIN, + dcCore::app()->auth::PERMISSION_USAGE, + dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, + dcCore::app()->auth::PERMISSION_ADMIN, ]), 'priority' => 2, 'type' => 'plugin', diff --git a/src/Frontend.php b/src/Frontend.php index 9597759..08e9516 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -37,7 +37,7 @@ class Frontend extends dcNsProcess return false; } - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::root(), 'default-templates', 'tpl'])); + dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', 'tpl'])); dcCore::app()->tpl->addBlock('activityReports', [Template::class, 'activityReports']); dcCore::app()->tpl->addValue('activityReportFeedID', [Template::class, 'activityReportFeedID']); diff --git a/src/My.php b/src/My.php index fec69aa..b1f9192 100644 --- a/src/My.php +++ b/src/My.php @@ -17,13 +17,10 @@ namespace Dotclear\Plugin\activityReport; use dcCore; /** - * Module definitions + * This module definitions. */ class My { - /** @var string Required php version */ - public const PHP_MIN = '8.1'; - /** @var string Activity database table name */ public const ACTIVITY_TABLE_NAME = 'activity'; @@ -33,6 +30,9 @@ class My /** @var int Incremental version by breaking changes */ public const COMPATIBILITY_VERSION = 3; + /** @var string Required php version */ + public const PHP_MIN = '7.4'; + /** * This module id. */ @@ -46,17 +46,27 @@ class My */ public static function name(): string { - return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name')); + $name = dcCore::app()->plugins->moduleInfo(self::id(), 'name'); + + return __(is_string($name) ? $name : self::id()); } /** - * This module root. + * This module path. */ - public static function root(): string + public static function path(): string { return dirname(__DIR__); } + /** + * Check this module PHP version compliant. + */ + public static function phpCompliant(): bool + { + return version_compare(phpversion(), self::PHP_MIN, '>='); + } + /** * Check is module is trully installed. * @@ -66,12 +76,4 @@ class My { return dcCore::app()->getVersion(self::id()) == dcCore::app()->plugins->moduleInfo(self::id(), 'version'); } - - /** - * Check php version. - */ - public static function phpCompliant(): bool - { - return version_compare(phpversion(), self::PHP_MIN, '>='); - } }