phpBB

Code Changes

File: viewforum.php

  Unmodified   Added   Modified   Removed
Line 47Line 47
	trigger_error('NO_FORUM');
}


	trigger_error('NO_FORUM');
}


$sql_from = FORUMS_TABLE . ' f';








$sql_ary = [
'SELECT' => 'f.*',
'FROM' => [
FORUMS_TABLE => 'f',
],
'WHERE' => 'f.forum_id = ' . $forum_id,
];


$lastread_select = '';

// Grab appropriate forum data
if ($config['load_db_lastread'] && $user->data['is_registered'])
{

$lastread_select = '';

// Grab appropriate forum data
if ($config['load_db_lastread'] && $user->data['is_registered'])
{

	$sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
AND ft.forum_id = f.forum_id)';
$lastread_select .= ', ft.mark_time';



	$sql_ary['LEFT_JOIN'][] = [
'FROM' => [FORUMS_TRACK_TABLE => 'ft'],
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id',
];
$sql_ary['SELECT'] .= ', ft.mark_time';

}

if ($user->data['is_registered'])
{

}

if ($user->data['is_registered'])
{

	$sql_from .= ' LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ')';
$lastread_select .= ', fw.notify_status';




	$sql_ary['LEFT_JOIN'][] = [
'FROM' => [FORUMS_WATCH_TABLE => 'fw'],
'ON' => 'fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'],
];
$sql_ary['SELECT'] .= ', fw.notify_status';

}


}


$sql = "SELECT f.* $lastread_select
FROM $sql_from
WHERE f.forum_id = $forum_id";
$result = $db->sql_query($sql);







/**
* You can use this event to modify the sql that selects the forum on the viewforum page.
*
* @event core.viewforum_modify_sql
* @var array sql_ary The SQL array to get the data for a forum
* @since 3.3.14-RC1
*/
$vars = ['sql_ary'];
extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_sql', compact($vars)));
$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));

$forum_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);


$forum_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);


Line 244Line 262

if ($task->is_ready())
{


if ($task->is_ready())
{

		$url = $task->get_url();
$template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');

		$cron_task_tag = $task->get_html_tag();
$template->assign_var('RUN_CRON_TASK', $cron_task_tag);

	}
else
{

	}
else
{

Line 255Line 273

if ($task->is_ready())
{


if ($task->is_ready())
{

			$url = $task->get_url();
$template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');

			$cron_task_tag = $task->get_html_tag();
$template->assign_var('RUN_CRON_TASK', $cron_task_tag);

		}
}
}

		}
}
}

Line 433Line 451
	'U_VIEW_FORUM'		=> append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($start == 0) ? '' : "&amp;start=$start")),
'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewforum.$phpEx", "f=$forum_id" . (($start) ? "&amp;start=$start" : ''), true, ''),
'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&amp;f=$forum_id&amp;mark=topics&amp;mark_time=" . time()) : '',

	'U_VIEW_FORUM'		=> append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($start == 0) ? '' : "&amp;start=$start")),
'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewforum.$phpEx", "f=$forum_id" . (($start) ? "&amp;start=$start" : ''), true, ''),
'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&amp;f=$forum_id&amp;mark=topics&amp;mark_time=" . time()) : '',

 
	'U_SEARCH_FORUM'	=> append_sid("{$phpbb_root_path}search.$phpEx", 'fid%5B%5D=' . $forum_id),

));

// Grab icons

));

// Grab icons

Line 710Line 729
		'SELECT'		=> $sql_array['SELECT'],
'FROM' => $sql_array['FROM'],
'LEFT_JOIN' => $sql_array['LEFT_JOIN'],

		'SELECT'		=> $sql_array['SELECT'],
'FROM' => $sql_array['FROM'],
'LEFT_JOIN' => $sql_array['LEFT_JOIN'],



 
		'WHERE'			=> $db->sql_in_set('t.topic_id', $topic_list),
);

		'WHERE'			=> $db->sql_in_set('t.topic_id', $topic_list),
);

 

/**
* Event to modify the SQL query before obtaining topics/stickies
*
* @event core.viewforum_modify_topic_list_sql
* @var int forum_id The forum ID
* @var array forum_data Data about the forum
* @var array topic_list Topic ids array
* @var array sql_array SQL query array for obtaining topics/stickies
*
* @since 3.2.10-RC1
* @since 3.3.1-RC1
*/
$vars = [
'forum_id',
'forum_data',
'topic_list',
'sql_array',
];
extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topic_list_sql', compact($vars)));


// If store_reverse, then first obtain topics, then stickies, else the other way around...
// Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because


// If store_reverse, then first obtain topics, then stickies, else the other way around...
// Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because

Line 920Line 958
		topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);

// Generate all the URIs ...

		topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);

// Generate all the URIs ...

		$view_topic_url_params = 'f=' . $row['forum_id'] . '&amp;t=' . $topic_id;

		$view_topic_url_params = 't=' . $topic_id;

		$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']));

		$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']));

Line 979Line 1017
			'S_TOPIC_MOVED'			=> ($row['topic_status'] == ITEM_MOVED) ? true : false,

'U_NEWEST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&amp;view=unread') . '#unread' : false,

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

'U_NEWEST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&amp;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 . '&amp;p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'] : false,

			'U_LAST_POST'			=> $auth->acl_get('f_read', $forum_id)  ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", '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_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),

			'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_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),

			'U_MCP_REPORT'			=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports&amp;f=' . $row['forum_id'] . '&amp;t=' . $topic_id, true, $user->session_id),

			'U_MCP_REPORT'			=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports&amp;t=' . $topic_id, true, $user->session_id),

			'U_MCP_QUEUE'			=> $u_mcp_queue,

'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test,

			'U_MCP_QUEUE'			=> $u_mcp_queue,

'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test,

Line 1007Line 1045

$template->assign_block_vars('topicrow', $topic_row);



$template->assign_block_vars('topicrow', $topic_row);


		$pagination->generate_template_pagination($view_topic_url, 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);

		$pagination->generate_template_pagination($topic_row['U_VIEW_TOPIC'], 'topicrow.pagination', 'start', (int) $topic_row['REPLIES'] + 1, $config['posts_per_page'], 1, true, true);


$s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;



$s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;