diff --git a/README.md b/README.md index 27a354d..ebc3f7f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Adds a page listing currently banned users. ## Requirements -- phpBB 3.3.0 or later +- phpBB 3.3.19 or later - PHP 8.0 or later ## Installation diff --git a/composer.json b/composer.json index dc0c173..31f301a 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "extra": { "display-name": "Ban List", "soft-require": { - "phpbb/phpbb": ">=3.3.0,<4.0.0@dev" + "phpbb/phpbb": ">=3.3.19,<4.0.0@dev" } } } diff --git a/ext.php b/ext.php index 9082efa..a81b818 100644 --- a/ext.php +++ b/ext.php @@ -19,16 +19,45 @@ class ext extends \phpbb\extension\base { /** - * Check whether or not the extension can be enabled. + * Check whether the extension can be enabled. * The current phpBB version should meet or exceed * the minimum version required by this extension. * - * Requires phpBB 3.3.0 and PHP 8.0.0 + * @return bool|array + * @access public */ public function is_enableable() { - $config = $this->container->get('config'); + $enableable = $this->check_phpbb_version() && $this->check_php_version(); - return phpbb_version_compare($config['version'], '3.3.0', '>=') && version_compare(PHP_VERSION, '8.0.0', '>='); + if (!$enableable) + { + $language = $this->container->get('language'); + $language->add_lang('install_banlist', 'phpbbmodders/banlist'); + + return $language->lang('BANLIST_NOT_ENABLEABLE'); + } + + return $enableable; + } + + /** + * Require phpBB 3.3.19 + * + * @return bool + */ + public function check_phpbb_version() + { + return phpbb_version_compare(PHPBB_VERSION, '3.3.19', '>='); + } + + /** + * Require PHP 8.0 + * + * @return bool + */ + public function check_php_version() + { + return PHP_VERSION_ID >= 80000; } } diff --git a/language/en/install_banlist.php b/language/en/install_banlist.php new file mode 100644 index 0000000..dd6ccb5 --- /dev/null +++ b/language/en/install_banlist.php @@ -0,0 +1,42 @@ + 'Ban List could not be enabled. The minimum requirements of phpBB 3.3.19 and/or PHP 8.0.0 were not satisfied.', +]);