diff --git a/README.md b/README.md index 1a8786f..58af240 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ A simple dropdown navigation menu for your board; the links are edited by hand i ## 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 537a1ee..76ed3f7 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "extra": { "display-name": "phpBB Modders Menu", "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 ba4fd5a..47edd35 100644 --- a/ext.php +++ b/ext.php @@ -21,13 +21,23 @@ class ext extends \phpbb\extension\base const OLD_EXT_NAME = 'modders/menu'; /** + * Refuse to enable below the minimum phpBB and PHP versions. + * * Refuse to enable while the old copy is still enabled, otherwise both * would add the menu to every page. * - * @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_menu', 'phpbbmodders/menu'); + + return $language->lang('MENU_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/menu" record so it doesn't linger in * the extension list after the rename, then enable as usual. diff --git a/language/en/install_menu.php b/language/en/install_menu.php new file mode 100644 index 0000000..075bc43 --- /dev/null +++ b/language/en/install_menu.php @@ -0,0 +1,42 @@ + 'phpBB Modders Menu could not be enabled. The minimum requirements of phpBB 3.3.19 and/or PHP 7.4.0 were not satisfied.', +]);