diff options
Diffstat (limited to 'phpBB/viewtopic.php')
| -rw-r--r-- | phpBB/viewtopic.php | 57 | 
1 files changed, 37 insertions, 20 deletions
| diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 103fc7f108..3f117eef6b 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -27,34 +27,35 @@ $user->session_begin();  $auth->acl($user->data);  // Initial var setup -$forum_id	= request_var('f', 0); -$topic_id	= request_var('t', 0); -$post_id	= request_var('p', 0); -$voted_id	= request_var('vote_id', array('' => 0)); +$forum_id	= $request->variable('f', 0); +$topic_id	= $request->variable('t', 0); +$post_id	= $request->variable('p', 0); +$voted_id	= $request->variable('vote_id', array('' => 0));  $voted_id = (sizeof($voted_id) > 1) ? array_unique($voted_id) : $voted_id; -$start		= request_var('start', 0); -$view		= request_var('view', ''); +$start		= $request->variable('start', 0); +$view		= $request->variable('view', '');  $default_sort_days	= (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0;  $default_sort_key	= (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't';  $default_sort_dir	= (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a'; -$sort_days	= request_var('st', $default_sort_days); -$sort_key	= request_var('sk', $default_sort_key); -$sort_dir	= request_var('sd', $default_sort_dir); +$sort_days	= $request->variable('st', $default_sort_days); +$sort_key	= $request->variable('sk', $default_sort_key); +$sort_dir	= $request->variable('sd', $default_sort_dir); -$update		= request_var('update', false); +$update		= $request->variable('update', false); +/* @var $pagination \phpbb\pagination */  $pagination = $phpbb_container->get('pagination');  $s_can_vote = false;  /**  * @todo normalize?  */ -$hilit_words	= request_var('hilit', '', true); +$hilit_words	= $request->variable('hilit', '', true);  // Do we have a topic or post id?  if (!$topic_id && !$post_id) @@ -62,6 +63,7 @@ if (!$topic_id && !$post_id)  	trigger_error('NO_TOPIC');  } +/* @var $phpbb_content_visibility \phpbb\content_visibility */  $phpbb_content_visibility = $phpbb_container->get('content.visibility');  // Find topic id if user requested a newer or older topic @@ -261,6 +263,10 @@ if (!$topic_data)  $forum_id = (int) $topic_data['forum_id']; +// If the request is missing the f parameter, the forum id in the user session data is 0 at the moment. +// Let's fix that now so that the user can't hide from the forum's Who Is Online list. +$user->page['forum'] = $forum_id; +  // Now we know the forum_id and can check the permissions  if ($topic_data['topic_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_approve', $forum_id))  { @@ -321,8 +327,8 @@ if ($post_id)  $topic_id = (int) $topic_data['topic_id'];  $topic_replies = $phpbb_content_visibility->get_count('topic_posts', $topic_data, $forum_id) - 1; -// Check sticky/announcement time limit -if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == POST_ANNOUNCE) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time()) +// Check sticky/announcement/global  time limit +if (($topic_data['topic_type'] != POST_NORMAL) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time())  {  	$sql = 'UPDATE ' . TOPICS_TABLE . '  		SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0 @@ -374,6 +380,7 @@ if (!$overrides_f_read_check && !$auth->acl_get('f_read', $forum_id))  {  	if ($user->data['user_id'] != ANONYMOUS)  	{ +		send_status_line(403, 'Forbidden');  		trigger_error('SORRY_AUTH_READ');  	} @@ -518,9 +525,9 @@ $vars = array(  extract($phpbb_dispatcher->trigger_event('core.viewtopic_highlight_modify', compact($vars)));  // Bookmarks -if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0)) +if ($config['allow_bookmarks'] && $user->data['is_registered'] && $request->variable('bookmark', 0))  { -	if (check_link_hash(request_var('hash', ''), "topic_$topic_id")) +	if (check_link_hash($request->variable('hash', ''), "topic_$topic_id"))  	{  		if (!$topic_data['bookmarked'])  		{ @@ -603,10 +610,10 @@ $quickmod_array = array(  	'merge'					=> array('MERGE_POSTS', $auth->acl_get('m_merge', $forum_id)),  	'merge_topic'		=> array('MERGE_TOPIC', $auth->acl_get('m_merge', $forum_id)),  	'fork'					=> array('FORK_TOPIC', $auth->acl_get('m_move', $forum_id)), -	'make_normal'		=> array('MAKE_NORMAL', ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL)), +	'make_normal'		=> array('MAKE_NORMAL', ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $forum_id) && $topic_data['topic_type'] != POST_NORMAL)),  	'make_sticky'		=> array('MAKE_STICKY', ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY)),  	'make_announce'	=> array('MAKE_ANNOUNCE', ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE)), -	'make_global'		=> array('MAKE_GLOBAL', ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL)), +	'make_global'		=> array('MAKE_GLOBAL', ($allow_change_type && $auth->acl_get('f_announce_global', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL)),  	'topic_logs'			=> array('VIEW_TOPIC_LOGS', $auth->acl_get('m_', $forum_id)),  ); @@ -1452,6 +1459,7 @@ $db->sql_freeresult($result);  // Load custom profile fields  if ($config['load_cpf_viewtopic'])  { +	/* @var $cp \phpbb\profilefields\manager */  	$cp = $phpbb_container->get('profilefields.manager');  	// Grab all profile fields from users in id cache for later use - similar to the poster cache @@ -1642,6 +1650,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)  	{  		$parse_flags = ($user_cache[$poster_id]['sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;  		$user_cache[$poster_id]['sig'] = generate_text_for_display($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield'],  $parse_flags, true); +		$user_cache[$poster_id]['sig_parsed'] = true;  	}  	// Parse the message and subject @@ -1942,6 +1951,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)  		'POST_ICON_IMG'			=> ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '',  		'POST_ICON_IMG_WIDTH'	=> ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '',  		'POST_ICON_IMG_HEIGHT'	=> ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '', +		'POST_ICON_IMG_ALT' 	=> ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['alt'] : '',  		'ONLINE_IMG'			=> ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? '' : (($user_cache[$poster_id]['online']) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),  		'S_ONLINE'				=> ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false), @@ -1956,7 +1966,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)  		'U_JABBER'		=> $user_cache[$poster_id]['jabber'],  		'U_APPROVE_ACTION'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p={$row['post_id']}&f=$forum_id&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url . '&p=' . $row['post_id'] . '#p' . $row['post_id']))), -		'U_REPORT'			=> ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', +		'U_REPORT'			=> ($auth->acl_get('f_report', $forum_id)) ? $phpbb_container->get('controller.helper')->route('phpbb_report_post_controller', array('id' => $row['post_id'])) : '',  		'U_MCP_REPORT'		=> ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',  		'U_MCP_APPROVE'		=> ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',  		'U_MCP_RESTORE'		=> ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_data['topic_visibility'] != ITEM_DELETED) ? 'deleted_posts' : 'deleted_topics') . '&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', @@ -1969,6 +1979,8 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)  		'POST_ID'			=> $row['post_id'],  		'POST_NUMBER'		=> $i + $start + 1,  		'POSTER_ID'			=> $poster_id, +		'MINI_POST'			=> ($post_unread) ? $user->lang['UNREAD_POST'] : $user->lang['POST'], +  		'S_HAS_ATTACHMENTS'	=> (!empty($attachments[$row['post_id']])) ? true : false,  		'S_MULTIPLE_ATTACHMENTS'	=> !empty($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]) > 1, @@ -2009,10 +2021,13 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)  	* @var	array	user_poster_data	Poster's data from user cache  	* @var	array	post_row			Template block array of the post  	* @var	array	topic_data			Array with topic data +	* @var	array	user_cache			Array with cached user data +	* @var	array	post_edit_list		Array with post edited list  	* @since 3.1.0-a1  	* @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 +	* @changed 3.2.2-RC1 Added user_cache and post_edit_list  	*/  	$vars = array(  		'start', @@ -2026,6 +2041,8 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)  		'user_poster_data',  		'post_row',  		'topic_data', +		'user_cache', +		'post_edit_list',  	);  	extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars))); @@ -2250,13 +2267,13 @@ if ($s_can_vote || $s_quick_reply)  // We overwrite $_REQUEST['f'] if there is no forum specified  // to be able to display the correct online list.  // One downside is that the user currently viewing this topic/post is not taken into account. -if (!request_var('f', 0)) +if (!$request->variable('f', 0))  {  	$request->overwrite('f', $forum_id);  }  // We need to do the same with the topic_id. See #53025. -if (!request_var('t', 0) && !empty($topic_id)) +if (!$request->variable('t', 0) && !empty($topic_id))  {  	$request->overwrite('t', $topic_id);  } | 
