phpBB

Code Changes

File: viewtopic.php

  Unmodified   Added   Modified   Removed
Line 494Line 494
		watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0);
}
}

		watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0);
}
}

 

/**
* Event to modify highlight.
*
* @event core.viewtopic_highlight_modify
* @var string highlight String to be highlighted
* @var string highlight_match Highlight string to be used in preg_replace
* @var array topic_data Topic data
* @var int start Pagination start
* @var int total_posts Number of posts
* @var string viewtopic_url Current viewtopic URL
* @since 3.1.11-RC1
*/
$vars = array(
'highlight',
'highlight_match',
'topic_data',
'start',
'total_posts',
'viewtopic_url',
);
extract($phpbb_dispatcher->trigger_event('core.viewtopic_highlight_modify', compact($vars)));


// Bookmarks
if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0))


// Bookmarks
if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0))

Line 588Line 610
	'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 651Line 700
* @var	int		total_posts			Topic total posts count
* @var string viewtopic_url URL to the topic page
* @since 3.1.0-RC4

* @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

* @changed 3.1.2-RC1 Added viewtopic_url

*/
$vars = array(
'base_url',

*/
$vars = array(
'base_url',

Line 803Line 852
		(!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 937Line 1016

$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 945Line 1025
		$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 955Line 1035
			'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 976Line 1056
		'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 1015Line 1131
// 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 1085Line 1200
* @var	int		start		Pagination information
* @var array sql_ary The SQL array to get the data of posts and posters
* @since 3.1.0-a1

* @var	int		start		Pagination information
* @var array sql_ary The SQL array to get the data of posts and posters
* @since 3.1.0-a1

* @change 3.1.0-a2 Added vars forum_id, topic_id, topic_data, post_list, sort_days, sort_key, sort_dir, start

* @changed 3.1.0-a2 Added vars forum_id, topic_id, topic_data, post_list, sort_days, sort_key, sort_dir, start

*/
$vars = array(
'forum_id',

*/
$vars = array(
'forum_id',

Line 1180Line 1295
	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 1210Line 1316
				'rank_title'		=> '',
'rank_image' => '',
'rank_image_src' => '',

				'rank_title'		=> '',
'rank_image' => '',
'rank_image_src' => '',

				'sig'				=> '',

 
				'pm'				=> '',
'email' => '',
'jabber' => '',

				'pm'				=> '',
'email' => '',
'jabber' => '',

Line 1395Line 1500
			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 1461Line 1566
	{
$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 1713Line 1812
		$s_first_unread = $first_unread = true;
}


		$s_first_unread = $first_unread = true;
}


	$force_edit_allowed = $force_delete_allowed = false;

	$force_edit_allowed = $force_delete_allowed = $force_softdelete_allowed = false;


$s_cannot_edit = !$auth->acl_get('f_edit', $forum_id) || $user->data['user_id'] != $poster_id;
$s_cannot_edit_time = $config['edit_time'] && $row['post_time'] <= time() - ($config['edit_time'] * 60);


$s_cannot_edit = !$auth->acl_get('f_edit', $forum_id) || $user->data['user_id'] != $poster_id;
$s_cannot_edit_time = $config['edit_time'] && $row['post_time'] <= time() - ($config['edit_time'] * 60);

Line 1743Line 1842
	* @var	bool	s_cannot_delete_lastpost	User can not delete the post because it's not the last post of the topic
* @var bool s_cannot_delete_locked User can not delete the post because it's locked
* @var bool s_cannot_delete_time User can not delete the post because edit_time has passed

	* @var	bool	s_cannot_delete_lastpost	User can not delete the post because it's not the last post of the topic
* @var bool s_cannot_delete_locked User can not delete the post because it's locked
* @var bool s_cannot_delete_time User can not delete the post because edit_time has passed

 
	* @var	bool	force_softdelete_allowed	Allow the user to —čoftdelete the post (all permissions and conditions are ignored)

	* @since 3.1.0-b4

	* @since 3.1.0-b4

 
	* @changed 3.1.11-RC1 Added force_softdelete_allowed var

	*/
$vars = array(
'row',

	*/
$vars = array(
'row',

Line 1757Line 1858
		's_cannot_delete_lastpost',
's_cannot_delete_locked',
's_cannot_delete_time',

		's_cannot_delete_lastpost',
's_cannot_delete_locked',
's_cannot_delete_time',

 
		'force_softdelete_allowed',

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


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


Line 1769Line 1871
	$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 = $force_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 = $force_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 1837Line 1948
		'U_EDIT'			=> ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&amp;f=$forum_id&amp;p={$row['post_id']}") : '',
'U_QUOTE' => ($quote_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&amp;f=$forum_id&amp;p={$row['post_id']}") : '',
'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=post_details&amp;f=$forum_id&amp;p=" . $row['post_id'], true, $user->session_id) : '',

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

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

		'U_DELETE'			=> ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=' . (($softdelete_allowed) ? 'soft_delete' : 'delete') . "&amp;f=$forum_id&amp;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 1876Line 1987
		'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];

Line 1898Line 2010
	* @var	array	post_row			Template block array of the post
* @var array topic_data Array with topic data
* @since 3.1.0-a1

	* @var	array	post_row			Template block array of the post
* @var array topic_data Array with topic data
* @since 3.1.0-a1

	* @change 3.1.0-a3 Added vars start, current_row_number, end, attachments
* @change 3.1.0-b3 Added topic_data array, total_posts
* @change 3.1.0-RC3 Added poster_id

	* @changed 3.1.0-a3 Added vars start, current_row_number, end, attachments
* @changed 3.1.0-b3 Added topic_data array, total_posts
* @changed 3.1.0-RC3 Added poster_id

	*/
$vars = array(
'start',

	*/
$vars = array(
'start',

Line 1998Line 2110
	* @var	array	post_row			Template block array of the post
* @var array topic_data Array with topic data
* @since 3.1.0-a3

	* @var	array	post_row			Template block array of the post
* @var array topic_data Array with topic data
* @since 3.1.0-a3

	* @change 3.1.0-b3 Added topic_data array, total_posts

	* @changed 3.1.0-b3 Added topic_data array, total_posts

	*/
$vars = array(
'start',

	*/
$vars = array(
'start',

Line 2161Line 2273
* @var	int		start			Start offset used to calculate the page
* @var array post_list Array with post_ids we are going to display
* @since 3.1.0-a1

* @var	int		start			Start offset used to calculate the page
* @var array post_list Array with post_ids we are going to display
* @since 3.1.0-a1

* @change 3.1.0-RC4 Added post_list var

* @changed 3.1.0-RC4 Added post_list var

*/
$vars = array('page_title', 'topic_data', 'forum_id', 'start', 'post_list');
extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars)));

*/
$vars = array('page_title', 'topic_data', 'forum_id', 'start', 'post_list');
extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars)));