phpBB

Code Changes

File: viewforum.php

  Unmodified   Added   Modified   Removed
Line 87Line 87
}

// Permissions check

}

// Permissions check

if (!$auth->acl_gets('f_list', 'f_read', $forum_id) || ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id)))

if (!$auth->acl_gets('f_list', 'f_list_topics', 'f_read', $forum_id) || ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id)))

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

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

Line 161Line 161
$topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id);
$start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count);


$topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id);
$start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count);


page_header($forum_data['forum_name'] . ($start ? ' - ' . $user->lang('PAGE_TITLE_NUMBER', $pagination->get_on_page($config['topics_per_page'], $start)) : ''), true, $forum_id);
















$page_title = $forum_data['forum_name'] . ($start ? ' - ' . $user->lang('PAGE_TITLE_NUMBER', $pagination->get_on_page($config['topics_per_page'], $start)) : '');

/**
* You can use this event to modify the page title of the viewforum page
*
* @event core.viewforum_modify_page_title
* @var string page_title Title of the viewforum page
* @var array forum_data Array with forum data
* @var int forum_id The forum ID
* @var int start Start offset used to calculate the page
* @since 3.2.2-RC1
*/
$vars = array('page_title', 'forum_data', 'forum_id', 'start');
extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_page_title', compact($vars)));

page_header($page_title, true, $forum_id);


$template->set_filenames(array(
'body' => 'viewforum_body.html')


$template->set_filenames(array(
'body' => 'viewforum_body.html')

Line 181Line 196

// Ok, if someone has only list-access, we only display the forum list.
// We also make this circumstance available to the template in case we want to display a notice. ;)


// Ok, if someone has only list-access, we only display the forum list.
// We also make this circumstance available to the template in case we want to display a notice. ;)

if (!$auth->acl_get('f_read', $forum_id))

if (!$auth->acl_gets('f_read', 'f_list_topics', $forum_id))

{
$template->assign_vars(array(
'S_NO_READ_ACCESS' => true,

{
$template->assign_vars(array(
'S_NO_READ_ACCESS' => true,

Line 385Line 400
	'S_SELECT_SORT_DIR'		=> $s_sort_dir,
'S_SELECT_SORT_KEY' => $s_sort_key,
'S_SELECT_SORT_DAYS' => $s_limit_days,

	'S_SELECT_SORT_DIR'		=> $s_sort_dir,
'S_SELECT_SORT_KEY' => $s_sort_key,
'S_SELECT_SORT_DAYS' => $s_limit_days,

	'S_TOPIC_ICONS'			=> ($s_display_active && sizeof($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false),

	'S_TOPIC_ICONS'			=> ($s_display_active && count($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false),

	'U_WATCH_FORUM_LINK'	=> $s_watching_forum['link'],
'U_WATCH_FORUM_TOGGLE' => $s_watching_forum['link_toggle'],
'S_WATCH_FORUM_TITLE' => $s_watching_forum['title'],

	'U_WATCH_FORUM_LINK'	=> $s_watching_forum['link'],
'U_WATCH_FORUM_TOGGLE' => $s_watching_forum['link_toggle'],
'S_WATCH_FORUM_TITLE' => $s_watching_forum['title'],

Line 395Line 410
	'S_DISPLAY_SEARCHBOX'	=> ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx"),
'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields),

	'S_DISPLAY_SEARCHBOX'	=> ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx"),
'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields),

	'S_SINGLE_MODERATOR'	=> (!empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1) ? false : true,

	'S_SINGLE_MODERATOR'	=> (!empty($moderators[$forum_id]) && count($moderators[$forum_id]) > 1) ? false : true,

	'S_IS_LOCKED'			=> ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false,
'S_VIEWFORUM' => true,


	'S_IS_LOCKED'			=> ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false,
'S_VIEWFORUM' => true,


Line 465Line 480
		$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']);
$sql_array['SELECT'] .= ', tt.mark_time';


		$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']);
$sql_array['SELECT'] .= ', tt.mark_time';


		if ($s_display_active && sizeof($active_forum_ary))

		if ($s_display_active && count($active_forum_ary))

		{
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']);
$sql_array['SELECT'] .= ', ft.mark_time AS forum_mark_time';

		{
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']);
$sql_array['SELECT'] .= ', ft.mark_time AS forum_mark_time';

Line 523Line 538

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


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

		if ($row['topic_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_approve', $row['forum_id']))

		if (!$phpbb_content_visibility->is_visible('topic', $row['forum_id'], $row))

		{
// Do not display announcements that are waiting for approval or soft deleted.
continue;

		{
// Do not display announcements that are waiting for approval or soft deleted.
continue;

Line 573Line 588
	// Select the sort order
$direction = (($sort_dir == 'd') ? 'ASC' : 'DESC');


	// Select the sort order
$direction = (($sort_dir == 'd') ? 'ASC' : 'DESC');


	$sql_limit = $pagination->reverse_limit($start, $sql_limit, $topics_count - sizeof($announcement_list));
$sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count - sizeof($announcement_list));

	$sql_limit = $pagination->reverse_limit($start, $sql_limit, $topics_count - count($announcement_list));
$sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count - count($announcement_list));

}
else
{

}
else
{

Line 592Line 607
	$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
}


	$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
}


if ($forum_data['forum_type'] == FORUM_POST || !sizeof($active_forum_ary))

if ($forum_data['forum_type'] == FORUM_POST || !count($active_forum_ary))

{
$sql_where = 't.forum_id = ' . $forum_id;
}

{
$sql_where = 't.forum_id = ' . $forum_id;
}

Line 603Line 618
else
{
$get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']);

else
{
$get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']);

	$sql_where = (sizeof($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id;

	$sql_where = (count($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id;

}

// Grab just the sorted topic ids

}

// Grab just the sorted topic ids

Line 662Line 677
// For storing shadow topics
$shadow_topic_list = array();


// For storing shadow topics
$shadow_topic_list = array();


if (sizeof($topic_list))

if (count($topic_list))

{
// SQL array for obtaining topics/stickies
$sql_array = array(

{
// SQL array for obtaining topics/stickies
$sql_array = array(

Line 692Line 707
}

// If we have some shadow topics, update the rowset to reflect their topic information

}

// If we have some shadow topics, update the rowset to reflect their topic information

if (sizeof($shadow_topic_list))

if (count($shadow_topic_list))

{
// SQL array for obtaining shadow topics
$sql_array = array(

{
// SQL array for obtaining shadow topics
$sql_array = array(

Line 732Line 747
		}

// Do not include those topics the user has no permission to access

		}

// Do not include those topics the user has no permission to access

		if (!$auth->acl_get('f_read', $row['forum_id']))

		if (!$auth->acl_gets('f_read', 'f_list_topics', $row['forum_id']))

		{
// We need to remove any trace regarding this topic. :)
unset($rowset[$orig_topic_id]);

		{
// We need to remove any trace regarding this topic. :)
unset($rowset[$orig_topic_id]);

Line 767Line 782

// We need to remove the global announcements from the forums total topic count,
// otherwise the number is different from the one on the forum list


// We need to remove the global announcements from the forums total topic count,
// otherwise the number is different from the one on the forum list

$total_topic_count = $topics_count - sizeof($announcement_list);

$total_topic_count = $topics_count - count($announcement_list);


$base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : ''));
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_topic_count, $config['topics_per_page'], $start);


$base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : ''));
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_topic_count, $config['topics_per_page'], $start);

Line 794Line 809
extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topics_data', compact($vars)));

// Okay, lets dump out the page ...

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

// Okay, lets dump out the page ...

if (sizeof($topic_list))

if (count($topic_list))

{
$mark_forum_read = true;
$mark_time_forum = 0;

{
$mark_forum_read = true;
$mark_time_forum = 0;

Line 875Line 890

// Generate all the URIs ...
$view_topic_url_params = 'f=' . $row['forum_id'] . '&t=' . $topic_id;


// Generate all the URIs ...
$view_topic_url_params = 'f=' . $row['forum_id'] . '&t=' . $topic_id;

		$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);

		$view_topic_url = $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params) : false;


$topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id']));
$posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id']));


$topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id']));
$posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id']));

Line 929Line 944
			'S_TOPIC_LOCKED'		=> ($row['topic_status'] == ITEM_LOCKED) ? true : false,
'S_TOPIC_MOVED' => ($row['topic_status'] == ITEM_MOVED) ? true : false,


			'S_TOPIC_LOCKED'		=> ($row['topic_status'] == ITEM_LOCKED) ? true : false,
'S_TOPIC_MOVED' => ($row['topic_status'] == ITEM_MOVED) ? true : false,


			'U_NEWEST_POST'			=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread',
'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],

			'U_NEWEST_POST'			=> $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread' : false,
'U_LAST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'] : false,

			'U_LAST_POST_AUTHOR'	=> get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'U_VIEW_TOPIC' => $view_topic_url,

			'U_LAST_POST_AUTHOR'	=> get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'U_VIEW_TOPIC' => $view_topic_url,

Line 992Line 1007
		unset($rowset[$topic_id]);
}
}

		unset($rowset[$topic_id]);
}
}

 

/**
* This event is to perform additional actions on viewforum page
*
* @event core.viewforum_generate_page_after
* @var array forum_data Array with the forum data
* @since 3.2.2-RC1
*/
$vars = array('forum_data');
extract($phpbb_dispatcher->trigger_event('core.viewforum_generate_page_after', compact($vars)));


// This is rather a fudge but it's the best I can think of without requiring information
// on all topics (as we do in 2.0.x). It looks for unread or new topics, if it doesn't find
// any it updates the forum last read cookie. This requires that the user visit the forum
// after reading a topic


// This is rather a fudge but it's the best I can think of without requiring information
// on all topics (as we do in 2.0.x). It looks for unread or new topics, if it doesn't find
// any it updates the forum last read cookie. This requires that the user visit the forum
// after reading a topic

if ($forum_data['forum_type'] == FORUM_POST && sizeof($topic_list) && $mark_forum_read)

if ($forum_data['forum_type'] == FORUM_POST && count($topic_list) && $mark_forum_read)

{
update_forum_tracking_info($forum_id, $forum_data['forum_last_post_time'], false, $mark_time_forum);
}

{
update_forum_tracking_info($forum_id, $forum_data['forum_last_post_time'], false, $mark_time_forum);
}