[ticket/15286] Add event to allow redirects

PHPBB3-15286
This commit is contained in:
Rubén Calvo 2017-08-20 21:44:40 +02:00
parent 3c295abd66
commit 6bd01d1506

View file

@ -266,6 +266,8 @@ else
$display_cat = ATTACHMENT_CATEGORY_NONE; $display_cat = ATTACHMENT_CATEGORY_NONE;
} }
$redirect = '';
/** /**
* Event to modify data before sending file to browser * Event to modify data before sending file to browser
* *
@ -278,6 +280,7 @@ else
* @var bool thumbnail Flag indicating if the file is a thumbnail * @var bool thumbnail Flag indicating if the file is a thumbnail
* @since 3.1.6-RC1 * @since 3.1.6-RC1
* @changed 3.1.7-RC1 Fixing wrong name of a variable (replacing "extension" by "extensions") * @changed 3.1.7-RC1 Fixing wrong name of a variable (replacing "extension" by "extensions")
* @changed 3.3.0-a1 Add redirect variable
*/ */
$vars = array( $vars = array(
'attach_id', 'attach_id',
@ -286,6 +289,7 @@ else
'extensions', 'extensions',
'mode', 'mode',
'thumbnail', 'thumbnail',
'redirect',
); );
extract($phpbb_dispatcher->trigger_event('core.download_file_send_to_browser_before', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.download_file_send_to_browser_before', compact($vars)));
@ -306,7 +310,14 @@ else
} }
else else
{ {
send_file_to_browser($attachment, $display_cat); if (!empty($redirect))
{
redirect($redirect, false, true);
}
else {
send_file_to_browser($attachment, $display_cat);
}
file_gc(); file_gc();
} }
} }