Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,45 @@
class ext extends \phpbb\extension\base
{
/**
* 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');
$allowed = (phpbb_version_compare($config['version'], '3.3', '>=')) ? true : false;
return $allowed;
$enableable = $this->check_phpbb_version() && $this->check_php_version();

if (!$enableable)
{
$language = $this->container->get('language');
$language->add_lang('requirereason_install', 'rmcgirr83/requirereason');

return $language->lang('REQUIREREASON_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;
}
}
20 changes: 20 additions & 0 deletions language/en/requirereason_install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* Extension enablement requirements [English].
*
* @license GNU General Public License, version 2 (GPL-2.0)
*/

if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

$lang = array_merge($lang, array(
'REQUIREREASON_NOT_ENABLEABLE' => 'Require Reason could not be enabled. It requires phpBB 3.3.19 or later and PHP 8.3.36 or later.',
));
Loading