phpBB

Code Changes

File: viewtopic.php

  Unmodified   Added   Modified   Removed
Line 335Line 335

// Setup look and feel
$user->setup('viewtopic', $topic_data['forum_style']);


// 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


// 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)
{

{
if ($user->data['user_id'] != ANONYMOUS)
{

Line 349Line 382

// Forum is passworded ... check whether access has been granted to this
// user this session, if not show login box


// 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);
}

{
login_forum_box($topic_data);
}

Line 555Line 588
	'topic_logs'			=> array('VIEW_TOPIC_LOGS', $auth->acl_get('m_', $forum_id)),
);


	'topic_logs'			=> array('VIEW_TOPIC_LOGS', $auth->acl_get('m_', $forum_id)),
);


foreach($quickmod_array as $option => $qm_ary)




























/**
* Event to modify data in the quickmod_array before it gets sent to the
* phpbb_add_quickmod_option function.
*
* @event core.viewtopic_add_quickmod_option_before
* @var int forum_id Forum ID
* @var int post_id Post ID
* @var array quickmod_array Array with quick moderation options data
* @var array topic_data Array with topic data
* @var int topic_id Topic ID
* @var array topic_tracking_info Array with topic tracking data
* @var string viewtopic_url URL to the topic page
* @var bool allow_change_type Topic change permissions check
* @since 3.1.9-RC1
*/
$vars = array(
'forum_id',
'post_id',
'quickmod_array',
'topic_data',
'topic_id',
'topic_tracking_info',
'viewtopic_url',
'allow_change_type',
);
extract($phpbb_dispatcher->trigger_event('core.viewtopic_add_quickmod_option_before', compact($vars)));

foreach ($quickmod_array as $option => $qm_ary)

{
if (!empty($qm_ary[1]))
{

{
if (!empty($qm_ary[1]))
{

Line 616Line 676
* @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	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

* @since 3.1.0-RC4

 
* @change 3.1.2-RC1 Added viewtopic_url

*/
$vars = array(
'base_url',

*/
$vars = array(
'base_url',

Line 628Line 690
	'topic_id',
'topic_tracking_info',
'total_posts',

	'topic_id',
'topic_tracking_info',
'total_posts',

 
	'viewtopic_url',

);
extract($phpbb_dispatcher->trigger_event('core.viewtopic_assign_template_vars_before', compact($vars)));


);
extract($phpbb_dispatcher->trigger_event('core.viewtopic_assign_template_vars_before', compact($vars)));


Line 689Line 752
	'U_TOPIC'				=> "{$server_path}viewtopic.$phpEx?f=$forum_id&t=$topic_id",
'U_FORUM' => $server_path,
'U_VIEW_TOPIC' => $viewtopic_url,

	'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"),

	'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"),

Line 767Line 830
		(!sizeof($cur_voted_id) ||
($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false;
$s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false;

		(!sizeof($cur_voted_id) ||
($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false;
$s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false;

 

/**
* Event to manipulate the poll data
*
* @event core.viewtopic_modify_poll_data
* @var array cur_voted_id Array with options' IDs current user has voted for
* @var int forum_id The topic's forum id
* @var array poll_info Array with the poll information
* @var bool s_can_vote Flag indicating if a user can vote
* @var bool s_display_results Flag indicating if results or poll options should be displayed
* @var int topic_id The id of the topic the user tries to access
* @var array topic_data All the information from the topic and forum tables for this topic
* @var string viewtopic_url URL to the topic page
* @var array vote_counts Array with the vote counts for every poll option
* @var array voted_id Array with updated options' IDs current user is voting for
* @since 3.1.5-RC1
*/
$vars = array(
'cur_voted_id',
'forum_id',
'poll_info',
's_can_vote',
's_display_results',
'topic_id',
'topic_data',
'viewtopic_url',
'vote_counts',
'voted_id',
);
extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_data', compact($vars)));


if ($update && $s_can_vote)
{


if ($update && $s_can_vote)
{

Line 901Line 994

$topic_data['poll_title'] = generate_text_for_display($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield'], $parse_flags, true);



$topic_data['poll_title'] = generate_text_for_display($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield'], $parse_flags, true);


 
	$poll_template_data = $poll_options_template_data = array();

	foreach ($poll_info as $poll_option)
{
$option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;

	foreach ($poll_info as $poll_option)
{
$option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;

Line 909Line 1003
		$option_pct_rel_txt = sprintf("%.1d%%", round($option_pct_rel * 100));
$option_most_votes = ($poll_option['poll_option_total'] > 0 && $poll_option['poll_option_total'] == $poll_most) ? true : false;


		$option_pct_rel_txt = sprintf("%.1d%%", round($option_pct_rel * 100));
$option_most_votes = ($poll_option['poll_option_total'] > 0 && $poll_option['poll_option_total'] == $poll_most) ? true : false;


		$template->assign_block_vars('poll_option', array(

		$poll_options_template_data[] = array(

			'POLL_OPTION_ID' 			=> $poll_option['poll_option_id'],
'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'],
'POLL_OPTION_RESULT' => $poll_option['poll_option_total'],

			'POLL_OPTION_ID' 			=> $poll_option['poll_option_id'],
'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'],
'POLL_OPTION_RESULT' => $poll_option['poll_option_total'],

Line 919Line 1013
			'POLL_OPTION_WIDTH'     	=> round($option_pct * 250),
'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false,
'POLL_OPTION_MOST_VOTES' => $option_most_votes,

			'POLL_OPTION_WIDTH'     	=> round($option_pct * 250),
'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false,
'POLL_OPTION_MOST_VOTES' => $option_most_votes,

		));

		);

	}

$poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];


	}

$poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];


	$template->assign_vars(array(

	$poll_template_data = array(

		'POLL_QUESTION'		=> $topic_data['poll_title'],
'TOTAL_VOTES' => $poll_total,
'POLL_LEFT_CAP_IMG' => $user->img('poll_left'),

		'POLL_QUESTION'		=> $topic_data['poll_title'],
'TOTAL_VOTES' => $poll_total,
'POLL_LEFT_CAP_IMG' => $user->img('poll_left'),

Line 940Line 1034
		'S_POLL_ACTION'		=> $viewtopic_url,

'U_VIEW_RESULTS' => $viewtopic_url . '&view=viewpoll',

		'S_POLL_ACTION'		=> $viewtopic_url,

'U_VIEW_RESULTS' => $viewtopic_url . '&view=viewpoll',

	));





































	);

/**
* Event to add/modify poll template data
*
* @event core.viewtopic_modify_poll_template_data
* @var array cur_voted_id Array with options' IDs current user has voted for
* @var int poll_end The poll end time
* @var array poll_info Array with the poll information
* @var array poll_options_template_data Array with the poll options template data
* @var array poll_template_data Array with the common poll template data
* @var int poll_total Total poll votes count
* @var int poll_most Mostly voted option votes count
* @var array topic_data All the information from the topic and forum tables for this topic
* @var string viewtopic_url URL to the topic page
* @var array vote_counts Array with the vote counts for every poll option
* @var array voted_id Array with updated options' IDs current user is voting for
* @since 3.1.5-RC1
*/
$vars = array(
'cur_voted_id',
'poll_end',
'poll_info',
'poll_options_template_data',
'poll_template_data',
'poll_total',
'poll_most',
'topic_data',
'viewtopic_url',
'vote_counts',
'voted_id',
);
extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_template_data', compact($vars)));

$template->assign_block_vars_array('poll_option', $poll_options_template_data);

$template->assign_vars($poll_template_data);





	unset($poll_end, $poll_info, $voted_id);

	unset($poll_end, $poll_info, $poll_options_template_data, $poll_template_data, $voted_id);

}

// If the user is trying to reach the second half of the topic, fetch it starting from the end

}

// If the user is trying to reach the second half of the topic, fetch it starting from the end

Line 979Line 1109
// 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;

// 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

$i = $i_total = 0;

// Go ahead and pull all data for this topic

Line 1144Line 1273
	extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_rowset_data', compact($vars)));

$rowset[$row['post_id']] = $rowset_data;

	extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_rowset_data', compact($vars)));

$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


// Cache various user specific data ... so we don't have to recompute
// this each time the same user appears on this page

Line 1247Line 1367
				'contact_user' 		=> $user->lang('CONTACT_USER', get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['username'])),

'online' => false,

				'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") : '',

				'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']),

				'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']),

Line 1359Line 1479
			FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
AND in_message = 0

			FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
AND in_message = 0

			ORDER BY filetime DESC, post_msg_id ASC';

			ORDER BY attach_id DESC, post_msg_id ASC';

		$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))

		$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))

Line 1425Line 1545
	{
$display_notice = true;
}

	{
$display_notice = true;
}

}

// 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

}

// Get the list of users who can receive private messages

Line 1733Line 1847
	$quote_allowed = $auth->acl_get('m_edit', $forum_id) || ($topic_data['topic_status'] != ITEM_LOCKED &&
($user->data['user_id'] == ANONYMOUS || $auth->acl_get('f_reply', $forum_id))
);

	$quote_allowed = $auth->acl_get('m_edit', $forum_id) || ($topic_data['topic_status'] != ITEM_LOCKED &&
($user->data['user_id'] == ANONYMOUS || $auth->acl_get('f_reply', $forum_id))
);

 

// Only display the quote button if the post is quotable. Posts not approved are not quotable.
$quote_allowed = ($quote_allowed && $row['post_visibility'] == ITEM_APPROVED) ? true : false;


$delete_allowed = $force_delete_allowed || ($user->data['is_registered'] && (
($auth->acl_get('m_delete', $forum_id) || ($auth->acl_get('m_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) ||
(!$s_cannot_delete && !$s_cannot_delete_lastpost && !$s_cannot_delete_time && !$s_cannot_delete_locked)
));


$delete_allowed = $force_delete_allowed || ($user->data['is_registered'] && (
($auth->acl_get('m_delete', $forum_id) || ($auth->acl_get('m_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) ||
(!$s_cannot_delete && !$s_cannot_delete_lastpost && !$s_cannot_delete_time && !$s_cannot_delete_locked)
));

 

$softdelete_allowed = ($auth->acl_get('m_softdelete', $forum_id) ||
($auth->acl_get('f_softdelete', $forum_id) && $user->data['user_id'] == $poster_id)) && ($row['post_visibility'] != ITEM_DELETED);

$permanent_delete_allowed = ($auth->acl_get('m_delete', $forum_id) ||
($auth->acl_get('f_delete', $forum_id) && $user->data['user_id'] == $poster_id));


// Can this user receive a Private Message?
$can_receive_pm = (


// Can this user receive a Private Message?
$can_receive_pm = (

Line 1801Line 1924
		'U_EDIT'			=> ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f=$forum_id&p={$row['post_id']}") : '',
'U_QUOTE' => ($quote_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&f=$forum_id&p={$row['post_id']}") : '',
'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&f=$forum_id&p=" . $row['post_id'], true, $user->session_id) : '',

		'U_EDIT'			=> ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f=$forum_id&p={$row['post_id']}") : '',
'U_QUOTE' => ($quote_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&f=$forum_id&p={$row['post_id']}") : '',
'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&f=$forum_id&p=" . $row['post_id'], true, $user->session_id) : '',

		'U_DELETE'			=> ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&f=$forum_id&p={$row['post_id']}") : '',

		'U_DELETE'			=> ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=' . (($softdelete_allowed) ? 'soft_delete' : 'delete') . "&f=$forum_id&p={$row['post_id']}") : '',


'U_SEARCH' => $user_cache[$poster_id]['search'],
'U_PM' => $u_pm,


'U_SEARCH' => $user_cache[$poster_id]['search'],
'U_PM' => $u_pm,

Line 1840Line 1963
		'L_IGNORE_POST'		=> ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '',
'S_POST_HIDDEN' => $row['hide_post'],
'L_POST_DISPLAY' => ($row['hide_post']) ? $user->lang('POST_DISPLAY', '<a class="display_post" data-post-id="' . $row['post_id'] . '" href="' . $viewtopic_url . "&amp;p={$row['post_id']}&amp;view=show#p{$row['post_id']}" . '">', '</a>') : '',

		'L_IGNORE_POST'		=> ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '',
'S_POST_HIDDEN' => $row['hide_post'],
'L_POST_DISPLAY' => ($row['hide_post']) ? $user->lang('POST_DISPLAY', '<a class="display_post" data-post-id="' . $row['post_id'] . '" href="' . $viewtopic_url . "&amp;p={$row['post_id']}&amp;view=show#p{$row['post_id']}" . '">', '</a>') : '',

 
		'S_DELETE_PERMANENT'	=> $permanent_delete_allowed,

	);

$user_poster_data = $user_cache[$poster_id];

	);

$user_poster_data = $user_cache[$poster_id];