From a0287a62c105df121c46f827c71d8c3808f67964 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 13 Dec 2014 18:36:14 +0000 Subject: [PATCH 01/12] [ticket/13160] Viewtopic; before viewing permissions event An event before the f_Read permissions check in viewtopic PHPBB3-13160 --- phpBB/viewtopic.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 5f897e8d94..82f091b1cf 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -336,6 +336,27 @@ if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == PO // Setup look and feel $user->setup('viewtopic', $topic_data['forum_style']); +/** +* Event to apply extra permissions and to override original phpBB's f_read permission and forum password check +* on viewtopic access +* +* @event core.viewtopic_before_f_read_check +* @var int forum_id The forum id from where the topic belongs +* @var int topic_id The id of the topic the user tries to access +* @var int post_id The id of the post the user tries to start viewing at. It may be 0 for none given. +* @var string topic_data All the information from the topic and forum tables for this topic +* It includes posts information if post_id is not 0 +* +* @since 3.1.3-RC1 +*/ +$vars = array( + 'forum_id', + 'topic_id', + 'post_id', + 'topic_data', +); +extract($phpbb_dispatcher->trigger_event('core.viewtopic_before_f_read_check', compact($vars))); + // Start auth check if (!$auth->acl_get('f_read', $forum_id)) { From a5a6855a0d9f198f43184f36fe997cb85e24777a Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 13 Dec 2014 18:48:53 +0000 Subject: [PATCH 02/12] [ticket/13160] Allow override f_read and forum password Adds a couple of variables to the event that allows extension authors to bypass the f_read and forum password checks as if the user had those permissions whether or not he actually has them. PHPBB3-13160 --- phpBB/viewtopic.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 82f091b1cf..269d2fed04 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -336,6 +336,8 @@ if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == PO // Setup look and feel $user->setup('viewtopic', $topic_data['forum_style']); +$overrides_f_read = false; +$overrides_forum_password = false; /** * Event to apply extra permissions and to override original phpBB's f_read permission and forum password check * on viewtopic access @@ -346,6 +348,8 @@ $user->setup('viewtopic', $topic_data['forum_style']); * @var int post_id The id of the post the user tries to start viewing at. It may be 0 for none given. * @var string topic_data All the information from the topic and forum tables for this topic * It includes posts information if post_id is not 0 +* @var array overrides_f_read Set true to remove f_read check afterwards +* @var array overrides_forum_password Set true to remove forum_password check afterwards * * @since 3.1.3-RC1 */ @@ -354,11 +358,13 @@ $vars = array( 'topic_id', 'post_id', 'topic_data', + 'overrides_f_read', + 'overrides_forum_password', ); extract($phpbb_dispatcher->trigger_event('core.viewtopic_before_f_read_check', compact($vars))); // Start auth check -if (!$auth->acl_get('f_read', $forum_id)) +if (!$overrides_f_read && !$auth->acl_get('f_read', $forum_id)) { if ($user->data['user_id'] != ANONYMOUS) { @@ -370,7 +376,7 @@ if (!$auth->acl_get('f_read', $forum_id)) // Forum is passworded ... check whether access has been granted to this // user this session, if not show login box -if ($topic_data['forum_password']) +if (!$overrides_forum_password && $topic_data['forum_password']) { login_forum_box($topic_data); } From 11269fe62a8307b1d57411a62d333645dd0c5825 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 13 Dec 2014 18:50:06 +0000 Subject: [PATCH 03/12] [ticket/13160] Allow override topic_tracking_info PHPBB3-13160 --- phpBB/viewtopic.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 269d2fed04..078046f262 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -338,6 +338,7 @@ $user->setup('viewtopic', $topic_data['forum_style']); $overrides_f_read = false; $overrides_forum_password = false; +$topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : NULL; /** * Event to apply extra permissions and to override original phpBB's f_read permission and forum password check * on viewtopic access @@ -350,6 +351,9 @@ $overrides_forum_password = false; * It includes posts information if post_id is not 0 * @var array overrides_f_read Set true to remove f_read check afterwards * @var array overrides_forum_password Set true to remove forum_password check afterwards +* @var array topic_tracking_info Information upon calling get_topic_tracking() +* Make it NULL to allow auto-filling later. +* Make it an array to override original data. * * @since 3.1.3-RC1 */ @@ -360,6 +364,7 @@ $vars = array( 'topic_data', 'overrides_f_read', 'overrides_forum_password', + 'topic_tracking_info', ); extract($phpbb_dispatcher->trigger_event('core.viewtopic_before_f_read_check', compact($vars))); From ffb7d618ac9ab63c7ea909683a53c410fd49068e Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 13 Dec 2014 19:20:53 +0000 Subject: [PATCH 04/12] [ticket/13160] Removed an unwanted tab char. PHPBB3-13160 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 078046f262..83fdcdd2ac 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -355,7 +355,7 @@ $topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : NULL * Make it NULL to allow auto-filling later. * Make it an array to override original data. * -* @since 3.1.3-RC1 +* @since 3.1.3-RC1 */ $vars = array( 'forum_id', From 3d8aaf6aaf63cd7fcbfc53aa6fdab6bdab0b0057 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 13 Dec 2014 20:49:50 +0000 Subject: [PATCH 05/12] [ticket/13160] Wrong variable types fixed PHPBB3-13160 --- phpBB/viewtopic.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 83fdcdd2ac..4c6520b6f5 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -347,10 +347,10 @@ $topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : NULL * @var int forum_id The forum id from where the topic belongs * @var int topic_id The id of the topic the user tries to access * @var int post_id The id of the post the user tries to start viewing at. It may be 0 for none given. -* @var string topic_data All the information from the topic and forum tables for this topic +* @var array topic_data All the information from the topic and forum tables for this topic * It includes posts information if post_id is not 0 -* @var array overrides_f_read Set true to remove f_read check afterwards -* @var array overrides_forum_password Set true to remove forum_password check afterwards +* @var bool overrides_f_read Set true to remove f_read check afterwards +* @var bool overrides_forum_password Set true to remove forum_password check afterwards * @var array topic_tracking_info Information upon calling get_topic_tracking() * Make it NULL to allow auto-filling later. * Make it an array to override original data. From f02e3a407629e2fc50a9a15a562e095defe793fb Mon Sep 17 00:00:00 2001 From: brunoais Date: Mon, 15 Dec 2014 21:50:33 +0000 Subject: [PATCH 06/12] [ticket/13160] lowercase null PHPBB3-13160 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 4c6520b6f5..920ec48611 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -338,7 +338,7 @@ $user->setup('viewtopic', $topic_data['forum_style']); $overrides_f_read = false; $overrides_forum_password = false; -$topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : NULL; +$topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : null; /** * Event to apply extra permissions and to override original phpBB's f_read permission and forum password check * on viewtopic access From fce1be26845f2e93df286a8b24790b54309138f8 Mon Sep 17 00:00:00 2001 From: brunoais Date: Mon, 15 Dec 2014 22:22:55 +0000 Subject: [PATCH 07/12] [ticket/13160] Appending "_check" to override variable names PHPBB3-13160 --- phpBB/viewtopic.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 920ec48611..4f63b6de71 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -336,24 +336,24 @@ if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == PO // Setup look and feel $user->setup('viewtopic', $topic_data['forum_style']); -$overrides_f_read = false; -$overrides_forum_password = false; +$overrides_f_read_check = false; +$overrides_forum_password_check = false; $topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : null; /** * Event to apply extra permissions and to override original phpBB's f_read permission and forum password check * on viewtopic access * * @event core.viewtopic_before_f_read_check -* @var int forum_id The forum id from where the topic belongs -* @var int topic_id The id of the topic the user tries to access -* @var int post_id The id of the post the user tries to start viewing at. It may be 0 for none given. -* @var array topic_data All the information from the topic and forum tables for this topic -* It includes posts information if post_id is not 0 -* @var bool overrides_f_read Set true to remove f_read check afterwards -* @var bool overrides_forum_password Set true to remove forum_password check afterwards -* @var array topic_tracking_info Information upon calling get_topic_tracking() -* Make it NULL to allow auto-filling later. -* Make it an array to override original data. +* @var int forum_id The forum id from where the topic belongs +* @var int topic_id The id of the topic the user tries to access +* @var int post_id The id of the post the user tries to start viewing at. It may be 0 for none given. +* @var array topic_data All the information from the topic and forum tables for this topic +* It includes posts information if post_id is not 0 +* @var bool overrides_f_read_check Set true to remove f_read check afterwards +* @var bool overrides_forum_password_check Set true to remove forum_password check afterwards +* @var array topic_tracking_info Information upon calling get_topic_tracking() +* Make it NULL to allow auto-filling later. +* Make it an array to override original data. * * @since 3.1.3-RC1 */ @@ -362,14 +362,14 @@ $vars = array( 'topic_id', 'post_id', 'topic_data', - 'overrides_f_read', - 'overrides_forum_password', + 'overrides_f_read_check', + 'overrides_forum_password_check', 'topic_tracking_info', ); extract($phpbb_dispatcher->trigger_event('core.viewtopic_before_f_read_check', compact($vars))); // Start auth check -if (!$overrides_f_read && !$auth->acl_get('f_read', $forum_id)) +if (!$overrides_f_read_check && !$auth->acl_get('f_read', $forum_id)) { if ($user->data['user_id'] != ANONYMOUS) { @@ -381,7 +381,7 @@ if (!$overrides_f_read && !$auth->acl_get('f_read', $forum_id)) // Forum is passworded ... check whether access has been granted to this // user this session, if not show login box -if (!$overrides_forum_password && $topic_data['forum_password']) +if (!$overrides_forum_password_check && $topic_data['forum_password']) { login_forum_box($topic_data); } From 9cbb9b42538f046368b9516a610a17449334d244 Mon Sep 17 00:00:00 2001 From: brunoais Date: Tue, 6 Jan 2015 12:37:00 +0000 Subject: [PATCH 08/12] [ticket/13146] Fixed wrong tab + space into only tab PHPBB3-13146 --- phpBB/viewtopic.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 4f63b6de71..90918228a5 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -345,13 +345,13 @@ $topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : null * * @event core.viewtopic_before_f_read_check * @var int forum_id The forum id from where the topic belongs -* @var int topic_id The id of the topic the user tries to access -* @var int post_id The id of the post the user tries to start viewing at. It may be 0 for none given. +* @var int topic_id The id of the topic the user tries to access +* @var int post_id The id of the post the user tries to start viewing at. It may be 0 for none given. * @var array topic_data All the information from the topic and forum tables for this topic * It includes posts information if post_id is not 0 -* @var bool overrides_f_read_check Set true to remove f_read check afterwards -* @var bool overrides_forum_password_check Set true to remove forum_password check afterwards -* @var array topic_tracking_info Information upon calling get_topic_tracking() +* @var bool overrides_f_read_check Set true to remove f_read check afterwards +* @var bool overrides_forum_password_check Set true to remove forum_password check afterwards +* @var array topic_tracking_info Information upon calling get_topic_tracking() * Make it NULL to allow auto-filling later. * Make it an array to override original data. * From 6d3fca9a41c6868211714b3f4d5e2236ef95ebb0 Mon Sep 17 00:00:00 2001 From: brunoais Date: Tue, 6 Jan 2015 12:37:53 +0000 Subject: [PATCH 09/12] [ticket/13146] Forced line feed on long line PHPBB3-13146 --- phpBB/viewtopic.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 90918228a5..20861434bd 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -346,7 +346,8 @@ $topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : null * @event core.viewtopic_before_f_read_check * @var int forum_id The forum id from where the topic belongs * @var int topic_id The id of the topic the user tries to access -* @var int post_id The id of the post the user tries to start viewing at. It may be 0 for none given. +* @var int post_id The id of the post the user tries to start viewing at. +* It may be 0 for none given. * @var array topic_data All the information from the topic and forum tables for this topic * It includes posts information if post_id is not 0 * @var bool overrides_f_read_check Set true to remove f_read check afterwards From ec749a2b39c910a5aaff769e22a6f0cf1093051f Mon Sep 17 00:00:00 2001 From: brunoais Date: Tue, 6 Jan 2015 12:38:36 +0000 Subject: [PATCH 10/12] [ticket/13146] "Make it" -> "Set it to" PHPBB3-13146 --- phpBB/viewtopic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 20861434bd..71828a3fc7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -353,8 +353,8 @@ $topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : null * @var bool overrides_f_read_check Set true to remove f_read check afterwards * @var bool overrides_forum_password_check Set true to remove forum_password check afterwards * @var array topic_tracking_info Information upon calling get_topic_tracking() -* Make it NULL to allow auto-filling later. -* Make it an array to override original data. +* Set it to NULL to allow auto-filling later. +* Set it to an array to override original data. * * @since 3.1.3-RC1 */ From 9cc4d60b88d9f64ec8ea83d54031ab182e381a56 Mon Sep 17 00:00:00 2001 From: brunoais Date: Tue, 6 Jan 2015 12:39:04 +0000 Subject: [PATCH 11/12] [ticket/13146] Remove empty line PHPBB3-13146 --- phpBB/viewtopic.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 71828a3fc7..0d2cd9ae5a 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -355,7 +355,6 @@ $topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : null * @var array topic_tracking_info Information upon calling get_topic_tracking() * Set it to NULL to allow auto-filling later. * Set it to an array to override original data. -* * @since 3.1.3-RC1 */ $vars = array( From 1d49ccd9205c349b2db2ac978654174b9e57956c Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 11 Jan 2015 19:12:08 +0000 Subject: [PATCH 12/12] [ticket/13160] New line before comment block PHPBB3-13160 --- phpBB/viewtopic.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 0d2cd9ae5a..981941cea0 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -339,6 +339,7 @@ $user->setup('viewtopic', $topic_data['forum_style']); $overrides_f_read_check = false; $overrides_forum_password_check = false; $topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : null; + /** * Event to apply extra permissions and to override original phpBB's f_read permission and forum password check * on viewtopic access