From fbdc956a1cc2352e3392a392e54a2125c297b78e Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 20 Aug 2012 11:52:06 -0400 Subject: [feature/add_events] Replaced current append_sid() hook with new event The new event, core.append_sid_override can either supplement or override the append_sid() function. PHPBB3-9550 --- phpBB/includes/functions.php | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ecec1e5e4a..584d88aaf6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2238,14 +2238,34 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) $params = false; } - // Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropriately. - // They could mimic most of what is within this function - if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id)) + $append_sid_override = false; + + /** + * This event can either supplement or override the append_sid() function + * + * To override this function, the event must set $append_sid_override to + * the new URL value, which will be returned following the event + * + * @event core.append_sid_override + * @var string url The url the session id needs to be + * appended to (can have params) + * @var mixed params String or array of additional url + * parameters + * @var bool is_amp Is url using & (true) or + * & (false) + * @var bool|string session_id Possibility to use a custom session + * id (string) instead of the global + * one (false) + * @var bool|string append_sid_override Overwrite function (string URL) + * or not (false) + * @since 3.1-A1 + */ + $vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_override'); + extract($phpbb_dispatcher->trigger_event('core.append_sid_override', compact($vars))); + + if ($append_sid_override) { - if ($phpbb_hook->hook_return(__FUNCTION__)) - { - return $phpbb_hook->hook_return_result(__FUNCTION__); - } + return $append_sid; } $params_is_array = is_array($params); -- cgit v1.2.1 From abc0ee753d4799270a20bfe756e1b7f9c302394d Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 20 Aug 2012 11:57:43 -0400 Subject: [feature/add_events] Return the correct variable PHPBB3-9550 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 584d88aaf6..8ca15a4908 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2265,7 +2265,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) if ($append_sid_override) { - return $append_sid; + return $append_sid_override; } $params_is_array = is_array($params); -- cgit v1.2.1 From 808af65819d447d35a8129c98fcc2feecb03e25e Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 20 Aug 2012 12:01:08 -0400 Subject: [feature/add_events] Globalize the event dispatcher object PHPBB3-9550 --- phpBB/includes/functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8ca15a4908..3c26337f91 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2231,6 +2231,7 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star function append_sid($url, $params = false, $is_amp = true, $session_id = false) { global $_SID, $_EXTRA_URL, $phpbb_hook; + global $phpbb_dispatcher; if ($params === '' || (is_array($params) && empty($params))) { -- cgit v1.2.1 From 0ba755f1bdc6329be1e58f6392b67e125abfbff5 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 20 Aug 2012 20:45:09 -0400 Subject: [feature/add_events] Rename core.append_sid_override to just core.append_sid Also, I added the hook back in below the event for backwards compatibility. PHPBB3-9550 --- phpBB/includes/functions.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3c26337f91..404288083b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2247,7 +2247,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) * To override this function, the event must set $append_sid_override to * the new URL value, which will be returned following the event * - * @event core.append_sid_override + * @event core.append_sid * @var string url The url the session id needs to be * appended to (can have params) * @var mixed params String or array of additional url @@ -2262,13 +2262,25 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) * @since 3.1-A1 */ $vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_override'); - extract($phpbb_dispatcher->trigger_event('core.append_sid_override', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.append_sid', compact($vars))); if ($append_sid_override) { return $append_sid_override; } + // The following hook remains for backwards compatibility, though use of + // the event above is preferred. + // Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropriately. + // They could mimic most of what is within this function + if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id)) + { + if ($phpbb_hook->hook_return(__FUNCTION__)) + { + return $phpbb_hook->hook_return_result(__FUNCTION__); + } + } + $params_is_array = is_array($params); // Get anchor -- cgit v1.2.1 From 6c6b179dd4b239030891fcc3b72472fbf4f78bc9 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Aug 2012 11:25:52 -0400 Subject: [feature/add_events] Rename override to overwrite, made docs 79 chars/line PHPBB3-9550 --- phpBB/includes/functions.php | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 404288083b..9f1172e61e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2239,38 +2239,39 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) $params = false; } - $append_sid_override = false; + $append_sid_overwrite = false; /** * This event can either supplement or override the append_sid() function * - * To override this function, the event must set $append_sid_override to + * To override this function, the event must set $append_sid_overwrite to * the new URL value, which will be returned following the event * * @event core.append_sid - * @var string url The url the session id needs to be - * appended to (can have params) - * @var mixed params String or array of additional url - * parameters - * @var bool is_amp Is url using & (true) or - * & (false) - * @var bool|string session_id Possibility to use a custom session - * id (string) instead of the global - * one (false) - * @var bool|string append_sid_override Overwrite function (string URL) - * or not (false) + * @var string url The url the session id needs + * to be appended to (can have + * params) + * @var mixed params String or array of additional + * url parameters + * @var bool is_amp Is url using & (true) or + * & (false) + * @var bool|string session_id Possibility to use a custom + * session id (string) instead of + * the global one (false) + * @var bool|string append_sid_overwrite Overwrite function (string + * URL) or not (false) * @since 3.1-A1 */ - $vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_override'); + $vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_overwrite'); extract($phpbb_dispatcher->trigger_event('core.append_sid', compact($vars))); - if ($append_sid_override) + if ($append_sid_overwrite) { - return $append_sid_override; + return $append_sid_overwrite; } // The following hook remains for backwards compatibility, though use of - // the event above is preferred. + // the event above is preferred. // Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropriately. // They could mimic most of what is within this function if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id)) -- cgit v1.2.1