aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/viewtopic.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/viewtopic.php')
-rw-r--r--phpBB/viewtopic.php72
1 files changed, 49 insertions, 23 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index f8b4a54f05..131230897f 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -336,8 +336,41 @@ 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_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_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()
+* 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(
+ 'forum_id',
+ 'topic_id',
+ 'post_id',
+ 'topic_data',
+ '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 (!$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)
{
@@ -349,7 +382,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_check && $topic_data['forum_password'])
{
login_forum_box($topic_data);
}
@@ -616,7 +649,9 @@ $base_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=
* @var int topic_id Topic ID
* @var array topic_tracking_info Array with topic tracking data
* @var int total_posts Topic total posts count
+* @var string viewtopic_url URL to the topic page
* @since 3.1.0-RC4
+* @change 3.1.2-RC1 Added viewtopic_url
*/
$vars = array(
'base_url',
@@ -628,6 +663,7 @@ $vars = array(
'topic_id',
'topic_tracking_info',
'total_posts',
+ 'viewtopic_url',
);
extract($phpbb_dispatcher->trigger_event('core.viewtopic_assign_template_vars_before', compact($vars)));
@@ -689,7 +725,7 @@ $template->assign_vars(array(
'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&t=$topic_id",
'U_FORUM' => $server_path,
'U_VIEW_TOPIC' => $viewtopic_url,
- 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewtopic.$phpEx", "t=$topic_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($start) ? "&start=$start" : ''), true, ''),
+ 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewtopic.$phpEx", "t=$topic_id" . (($start) ? "&start=$start" : ''), true, ''),
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=previous"),
'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=next"),
@@ -979,7 +1015,6 @@ else
// Container for user details, only process once
$post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = $post_delete_list = array();
$has_unapproved_attachments = $has_approved_attachments = $display_notice = false;
-$bbcode_bitfield = '';
$i = $i_total = 0;
// Go ahead and pull all data for this topic
@@ -1145,15 +1180,6 @@ while ($row = $db->sql_fetchrow($result))
$rowset[$row['post_id']] = $rowset_data;
- // Define the global bbcode bitfield, will be used to load bbcodes
- $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
-
- // Is a signature attached? Are we going to display it?
- if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
- {
- $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']);
- }
-
// Cache various user specific data ... so we don't have to recompute
// this each time the same user appears on this page
if (!isset($user_cache[$poster_id]))
@@ -1203,7 +1229,10 @@ while ($row = $db->sql_fetchrow($result))
$user_cache[$poster_id] = $user_cache_data;
- get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
+ $user_rank_data = phpbb_get_user_rank($row, false);
+ $user_cache[$poster_id]['rank_title'] = $user_rank_data['title'];
+ $user_cache[$poster_id]['rank_image'] = $user_rank_data['img'];
+ $user_cache[$poster_id]['rank_image_src'] = $user_rank_data['img_src'];
}
else
{
@@ -1244,8 +1273,8 @@ while ($row = $db->sql_fetchrow($result))
'contact_user' => $user->lang('CONTACT_USER', get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['username'])),
'online' => false,
- 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '',
- 'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '',
+ 'jabber' => ($config['jab_enable'] && $row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '',
+ 'search' => ($config['load_search'] && $auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '',
'author_full' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']),
'author_colour' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']),
@@ -1267,7 +1296,10 @@ while ($row = $db->sql_fetchrow($result))
$user_cache[$poster_id] = $user_cache_data;
- get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
+ $user_rank_data = phpbb_get_user_rank($row, $row['user_posts']);
+ $user_cache[$poster_id]['rank_title'] = $user_rank_data['title'];
+ $user_cache[$poster_id]['rank_image'] = $user_rank_data['img'];
+ $user_cache[$poster_id]['rank_image_src'] = $user_rank_data['img_src'];
if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
{
@@ -1421,12 +1453,6 @@ if (sizeof($attach_list))
}
}
-// Instantiate BBCode if need be
-if ($bbcode_bitfield !== '')
-{
- $bbcode = new bbcode(base64_encode($bbcode_bitfield));
-}
-
// Get the list of users who can receive private messages
$can_receive_pm_list = $auth->acl_get_list(array_keys($user_cache), 'u_readpm');
$can_receive_pm_list = (empty($can_receive_pm_list) || !isset($can_receive_pm_list[0]['u_readpm'])) ? array() : $can_receive_pm_list[0]['u_readpm'];