From aae6341989f479d13f3ead0bf5126335444bcf35 Mon Sep 17 00:00:00 2001 From: javiexin Date: Sun, 11 Dec 2016 21:15:30 +0100 Subject: [PATCH 1/5] [ticket/14849] Add core.acp_extensions_run_action Moved the event to a slightly modified position to perform common checks before calling the event, added an extra variable to allow execution control, honor the extension modified value of u_action (if any) PHPBB-14849 --- phpBB/includes/acp/acp_extensions.php | 42 +++++++++++++++++---------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 5a2ded91e2..4d00279474 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -56,21 +56,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 ($request->is_set_post('cancel')) { @@ -83,6 +68,33 @@ class acp_extensions trigger_error('FORM_INVALID', E_USER_WARNING); } + /** + * 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 + * @var string tpl_name Template file to load; leave empty to continue execution, filled in if ready to finish + * @since 3.1.11-RC1 + */ + $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', compact($vars))); + + // In case they have been updated by the event + $this->u_action = $u_action; + $this->tpl_name = $tpl_name; + + // If tpl_name was set by the prior event, we are done + if ($tpl_name) + { + return; + } + // If they've specified an extension, let's load the metadata manager and validate it. if ($ext_name) { From 620d033e0669a5a019f6c08a06c69d91ebe15f2b Mon Sep 17 00:00:00 2001 From: javiexin Date: Fri, 16 Dec 2016 15:05:22 +0100 Subject: [PATCH 2/5] [ticket/14849] Add core.acp_extensions_run_action_after Additional event to be run after the execution of the action in ACP PHPBB-14849 --- phpBB/includes/acp/acp_extensions.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 4d00279474..67222b43a4 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -347,6 +347,26 @@ 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; + $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; } /** From aad13389cedf2569e4eb2b15a7baa96ce9d6954a Mon Sep 17 00:00:00 2001 From: javiexin Date: Fri, 16 Dec 2016 20:40:28 +0100 Subject: [PATCH 3/5] [ticket/14849] Add core.acp_extensions_run_action_after Additional event to be run after the execution of the action in ACP. Adding missing var as input to event. PHPBB-14849 --- phpBB/includes/acp/acp_extensions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 67222b43a4..d41b94b026 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -361,6 +361,7 @@ class acp_extensions * @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))); From d6771d6a7f12067c64f83ca3e249c7fb4084cc90 Mon Sep 17 00:00:00 2001 From: javiexin Date: Fri, 30 Dec 2016 21:43:15 +0100 Subject: [PATCH 4/5] [ticket/14849] Add core.acp_extensions_run_action Moved the event to a slightly modified position. Added an extra variable to the event. Additional event to be run after the execution of the action in ACP. Added a new action to allow for extension execution control. PHPBB-14849 --- phpBB/includes/acp/acp_extensions.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index d41b94b026..2befe57399 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -72,12 +72,12 @@ class acp_extensions * Event to run a specific action on extension * * @event core.acp_extensions_run_action - * @var string action Action to run + * @var string action Action to run; if the event executes completely 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; leave empty to continue execution, filled in if ready to finish + * @var string tpl_name Template file to load * @since 3.1.11-RC1 */ $u_action = $this->u_action; @@ -89,12 +89,6 @@ class acp_extensions $this->u_action = $u_action; $this->tpl_name = $tpl_name; - // If tpl_name was set by the prior event, we are done - if ($tpl_name) - { - return; - } - // If they've specified an extension, let's load the metadata manager and validate it. if ($ext_name) { @@ -113,6 +107,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); From cdca848018571f2725aed207ead751823970a014 Mon Sep 17 00:00:00 2001 From: javiexin Date: Sun, 19 Feb 2017 22:01:02 +0100 Subject: [PATCH 5/5] [ticket/14849] Add core.acp_extensions_run_action Rename event to core.acp_extensions_run_action_before PHPBB-14849 --- phpBB/includes/acp/acp_extensions.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 2befe57399..52282fbe6b 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -71,19 +71,20 @@ class acp_extensions /** * Event to run a specific action on extension * - * @event core.acp_extensions_run_action - * @var string action Action to run; if the event executes completely the action, should be set to 'none' + * @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', compact($vars))); + 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;