1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge pull request #2729 from Nicofuma/ticket/12847

[ticket/12847] Allow the extensions to say if they can be enabled

* Nicofuma/ticket/12847:
  [ticket/12847] Allow the extensions to say if they can be enabled
This commit is contained in:
Joas Schilling
2014-08-07 13:00:08 +02:00
9 changed files with 96 additions and 2 deletions

View File

@@ -137,6 +137,12 @@ class acp_extensions
trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$extension = $phpbb_extension_manager->get_extension($ext_name);
if (!$extension->is_enableable())
{
trigger_error($user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if ($phpbb_extension_manager->is_enabled($ext_name))
{
redirect($this->u_action);
@@ -162,6 +168,12 @@ class acp_extensions
trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$extension = $phpbb_extension_manager->get_extension($ext_name);
if (!$extension->is_enableable())
{
trigger_error($user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if ($phpbb_extension_manager->is_enabled($ext_name))
{
redirect($this->u_action);

View File

@@ -42,6 +42,7 @@ $lang = array_merge($lang, array(
'EXTENSION_INVALID_LIST' => 'The “%s” extension is not valid.<br />%s<br /><br />',
'EXTENSION_NOT_AVAILABLE' => 'The selected extension is not available for this board, please verify your phpBB and PHP versions are allowed (see the details page).',
'EXTENSION_DIR_INVALID' => 'The selected extension has an invalid directory structure and cannot be enabled.',
'EXTENSION_NOT_ENABLEABLE' => 'The selected extension cannot be enabled, please verify the extensions requirements.',
'DETAILS' => 'Details',

View File

@@ -54,6 +54,14 @@ class base implements \phpbb\extension\extension_interface
$this->extension_path = $extension_path;
}
/**
* {@inheritdoc}
*/
public function is_enableable()
{
return true;
}
/**
* Single enable step that installs any included migrations
*

View File

@@ -19,6 +19,13 @@ namespace phpbb\extension;
*/
interface extension_interface
{
/**
* Indicate whether or not the extension can be enabled.
*
* @return bool
*/
public function is_enableable();
/**
* enable_step is executed on enabling an extension until it returns false.
*

View File

@@ -178,6 +178,12 @@ class manager
$old_state = (isset($this->extensions[$name]['ext_state'])) ? unserialize($this->extensions[$name]['ext_state']) : false;
$extension = $this->get_extension($name);
if (!$extension->is_enableable())
{
return false;
}
$state = $extension->enable_step($old_state);
$active = ($state === false);