diff --git a/README.md b/README.md index 8d72a37..6858d37 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Loads the Iconify icon script on every page so Iconify icons can be used in temp ## Requirements -- phpBB 3.3.0 or later +- phpBB 3.3.19 or later - PHP 7.4 or later ## Installation diff --git a/composer.json b/composer.json index 9f5942f..adfdf13 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "extra": { "display-name": "Insert Iconify Script", "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 5dc522a..8209d49 100644 --- a/ext.php +++ b/ext.php @@ -21,13 +21,23 @@ class ext extends \phpbb\extension\base const OLD_EXT_NAME = 'modders/inserticonifyscript'; /** + * Refuse to enable below the minimum phpBB and PHP versions. + * * Refuse to enable while the old copy is still enabled, otherwise both * would load the Iconify script twice. * - * @return bool|array True if enableable, otherwise an array of reasons + * @return bool|string|array True if enableable, otherwise a reason string or array of reasons */ public function is_enableable() { + if (!$this->check_phpbb_version() || !$this->check_php_version()) + { + $language = $this->container->get('language'); + $language->add_lang('install_inserticonifyscript', 'phpbbmodders/inserticonifyscript'); + + return $language->lang('INSERTICONIFYSCRIPT_NOT_ENABLEABLE'); + } + $ext_manager = $this->container->get('ext.manager'); if ($ext_manager->is_enabled(self::OLD_EXT_NAME)) @@ -38,6 +48,26 @@ public function is_enableable() return true; } + /** + * Require phpBB 3.3.19 + * + * @return bool + */ + public function check_phpbb_version() + { + return phpbb_version_compare(PHPBB_VERSION, '3.3.19', '>='); + } + + /** + * Require PHP 7.4 + * + * @return bool + */ + public function check_php_version() + { + return PHP_VERSION_ID >= 70400; + } + /** * Remove the disabled old "modders/inserticonifyscript" record so it doesn't linger in * the extension list after the rename, then enable as usual. diff --git a/language/en/install_inserticonifyscript.php b/language/en/install_inserticonifyscript.php new file mode 100644 index 0000000..a78cce9 --- /dev/null +++ b/language/en/install_inserticonifyscript.php @@ -0,0 +1,42 @@ + 'Insert Iconify Script could not be enabled. The minimum requirements of phpBB 3.3.19 and/or PHP 7.4.0 were not satisfied.', +]);