aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/acp/acp_extensions.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/acp/acp_extensions.php')
-rw-r--r--phpBB/includes/acp/acp_extensions.php89
1 files changed, 58 insertions, 31 deletions
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
index 1bf0c23718..9e72ab83f8 100644
--- a/phpBB/includes/acp/acp_extensions.php
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -59,21 +59,6 @@ class acp_extensions
$safe_time_limit = (ini_get('max_execution_time') / 2);
$start_time = time();
- /**
- * Event to run a specific action on extension
- *
- * @event core.acp_extensions_run_action
- * @var string action Action to run
- * @var string u_action Url we are at
- * @var string ext_name Extension name from request
- * @var int safe_time_limit Safe limit of execution time
- * @var int start_time Start time
- * @since 3.1.11-RC1
- */
- $u_action = $this->u_action;
- $vars = array('action', 'u_action', 'ext_name', 'safe_time_limit', 'start_time');
- extract($this->phpbb_dispatcher->trigger_event('core.acp_extensions_run_action', compact($vars)));
-
// Cancel action
if ($this->request->is_set_post('cancel'))
{
@@ -86,6 +71,28 @@ class acp_extensions
trigger_error('FORM_INVALID', E_USER_WARNING);
}
+ /**
+ * Event to run a specific action on extension
+ *
+ * @event core.acp_extensions_run_action_before
+ * @var string action Action to run; if the event completes execution of the action, should be set to 'none'
+ * @var string u_action Url we are at
+ * @var string ext_name Extension name from request
+ * @var int safe_time_limit Safe limit of execution time
+ * @var int start_time Start time
+ * @var string tpl_name Template file to load
+ * @since 3.1.11-RC1
+ * @changed 3.2.1-RC1 Renamed to core.acp_extensions_run_action_before, added tpl_name, added action 'none'
+ */
+ $u_action = $this->u_action;
+ $tpl_name = '';
+ $vars = array('action', 'u_action', 'ext_name', 'safe_time_limit', 'start_time', 'tpl_name');
+ extract($this->phpbb_dispatcher->trigger_event('core.acp_extensions_run_action_before', compact($vars)));
+
+ // In case they have been updated by the event
+ $this->u_action = $u_action;
+ $this->tpl_name = $tpl_name;
+
// If they've specified an extension, let's load the metadata manager and validate it.
if ($ext_name)
{
@@ -104,6 +111,10 @@ class acp_extensions
// What are we doing?
switch ($action)
{
+ case 'none':
+ // Intentionally empty, used by extensions that execute additional actions in the prior event
+ break;
+
case 'set_config_version_check_force_unstable':
$force_unstable = $this->request->variable('force_unstable', false);
@@ -144,14 +155,13 @@ class acp_extensions
break;
case 'enable_pre':
- if (!$md_manager->validate_dir())
+ try
{
- trigger_error($this->user->lang['EXTENSION_DIR_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
+ $md_manager->validate_enable();
}
-
- if (!$md_manager->validate_enable())
+ catch (\phpbb\extension\exception $e)
{
- trigger_error($this->user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
+ trigger_error($e . adm_back_link($this->u_action), E_USER_WARNING);
}
$extension = $this->ext_manager->get_extension($ext_name);
@@ -175,14 +185,13 @@ class acp_extensions
break;
case 'enable':
- if (!$md_manager->validate_dir())
+ try
{
- trigger_error($this->user->lang['EXTENSION_DIR_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
+ $md_manager->validate_enable();
}
-
- if (!$md_manager->validate_enable())
+ catch (\phpbb\extension\exception $e)
{
- trigger_error($this->user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
+ trigger_error($e . adm_back_link($this->u_action), E_USER_WARNING);
}
$extension = $this->ext_manager->get_extension($ext_name);
@@ -317,10 +326,7 @@ class acp_extensions
'UP_TO_DATE_MSG' => $this->user->lang(empty($updates_available) ? 'UP_TO_DATE' : 'NOT_UP_TO_DATE', $md_manager->get_metadata('display-name')),
));
- foreach ($updates_available as $branch => $version_data)
- {
- $this->template->assign_block_vars('updates_available', $version_data);
- }
+ $this->template->assign_block_vars('updates_available', $updates_available);
}
catch (\RuntimeException $e)
{
@@ -338,6 +344,27 @@ class acp_extensions
$this->tpl_name = 'acp_ext_details';
break;
}
+
+ /**
+ * Event to run after a specific action on extension has completed
+ *
+ * @event core.acp_extensions_run_action_after
+ * @var string action Action that has run
+ * @var string u_action Url we are at
+ * @var string ext_name Extension name from request
+ * @var int safe_time_limit Safe limit of execution time
+ * @var int start_time Start time
+ * @var string tpl_name Template file to load
+ * @since 3.1.11-RC1
+ */
+ $u_action = $this->u_action;
+ $tpl_name = $this->tpl_name;
+ $vars = array('action', 'u_action', 'ext_name', 'safe_time_limit', 'start_time', 'tpl_name');
+ extract($this->phpbb_dispatcher->trigger_event('core.acp_extensions_run_action_after', compact($vars)));
+
+ // In case they have been updated by the event
+ $this->u_action = $u_action;
+ $this->tpl_name = $tpl_name;
}
/**
@@ -535,7 +562,7 @@ class acp_extensions
* @param \phpbb\extension\metadata_manager $md_manager The metadata manager for the version to check.
* @param bool $force_update Ignores cached data. Defaults to false.
* @param bool $force_cache Force the use of the cache. Override $force_update.
- * @return string
+ * @return array
* @throws RuntimeException
*/
protected function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false)
@@ -554,7 +581,7 @@ class acp_extensions
$version_helper->set_file_location($version_check['host'], $version_check['directory'], $version_check['filename'], isset($version_check['ssl']) ? $version_check['ssl'] : false);
$version_helper->force_stability($this->config['extension_force_unstable'] ? 'unstable' : null);
- return $updates = $version_helper->get_suggested_updates($force_update, $force_cache);
+ return $version_helper->get_ext_update_on_branch($force_update, $force_cache);
}
/**