diff --git a/ext.php b/ext.php index 10b1813..6d1a7b6 100644 --- a/ext.php +++ b/ext.php @@ -15,26 +15,48 @@ */ class ext extends \phpbb\extension\base { - /** @var string Require phpBB 3.2.0 */ - const PHPBB_MIN_VERSION = '3.3'; + /** @var string Require phpBB 3.3.19 */ + const PHPBB_MIN_VERSION = '3.3.19'; /** - * Enable extension if phpBB version requirement is met + * Check whether the extension can be enabled. + * The current phpBB and PHP version should meet or + * exceed the minimum version required by this extension: * - * @return bool + * @return bool|array * @access public */ public function is_enableable() { - $config = $this->container->get('config'); + $enableable = $this->check_phpbb_version() && $this->check_php_version(); - $enableable = (phpbb_version_compare($config['version'], self::PHPBB_MIN_VERSION, '>=')); if (!$enableable) { $language = $this->container->get('language'); - $language->add_lang('common', 'rmcgirr83/separateusersandbots'); - trigger_error($language->lang('EXTENSION_REQUIRES_32'), E_USER_WARNING); + $language->add_lang('separateusersandbots_install', 'rmcgirr83/separateusersandbots'); + + return $language->lang('SEPARATEUSERSANDBOTS_NOT_ENABLEABLE'); } return $enableable; } + + /** + * Require phpBB 3.3.19 due to several security fixes in the phpBB software. + * + * @return bool + */ + protected function check_phpbb_version() + { + return phpbb_version_compare(PHPBB_VERSION, '3.3.19', '>='); + } + + /** + * Requires PHP 8.3.36 due to security fixes. + * + * @return bool + */ + protected function check_php_version() + { + return PHP_VERSION_ID >= 80336; + } } diff --git a/language/en/separateusersandbots_install.php b/language/en/separateusersandbots_install.php new file mode 100644 index 0000000..d0be798 --- /dev/null +++ b/language/en/separateusersandbots_install.php @@ -0,0 +1,20 @@ + 'Separate Users and Bots could not be enabled. It requires phpBB 3.3.19 or later and PHP 8.3.36 or later.', +));