phpBB

Code Changes

File: viewforum.php

  Unmodified   Added   Modified   Removed
Line 146Line 146
	}
}


	}
}


 
// Is a forum specific topic count required?
if ($forum_data['forum_topics_per_page'])
{
$config['topics_per_page'] = $forum_data['forum_topics_per_page'];
}

/* @var $phpbb_content_visibility \phpbb\content_visibility */

$phpbb_content_visibility = $phpbb_container->get('content.visibility');

// Dump out the page header and load viewforum template

$phpbb_content_visibility = $phpbb_container->get('content.visibility');

// Dump out the page header and load viewforum template

Line 207Line 214
	}

trigger_error($user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>'));

	}

trigger_error($user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>'));

}

// Is a forum specific topic count required?
if ($forum_data['forum_topics_per_page'])
{
$config['topics_per_page'] = $forum_data['forum_topics_per_page'];

 
}

// Do the forum Prune thang - cron type job ...

}

// Do the forum Prune thang - cron type job ...

Line 264Line 265
$limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);

$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);

$limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);

$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);

$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 't.topic_title', 'v' => 't.topic_views');

$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 'LOWER(t.topic_title)', 'v' => 't.topic_views');


$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);


$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);

Line 274Line 275
{
$min_post_time = time() - ($sort_days * 86400);


{
$min_post_time = time() - ($sort_days * 86400);


	$sql = 'SELECT COUNT(topic_id) AS num_topics
FROM ' . TOPICS_TABLE . "
WHERE forum_id = $forum_id
AND (topic_last_post_time >= $min_post_time
OR topic_type = " . POST_ANNOUNCE . '
OR topic_type = ' . POST_GLOBAL . ')
AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id);
$result = $db->sql_query($sql);





























	$sql_array = array(
'SELECT' => 'COUNT(t.topic_id) AS num_topics',
'FROM' => array(
TOPICS_TABLE => 't',
),
'WHERE' => 't.forum_id = ' . $forum_id . '
AND (t.topic_last_post_time >= ' . $min_post_time . '
OR t.topic_type = ' . POST_ANNOUNCE . '
OR t.topic_type = ' . POST_GLOBAL . ')
AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'),
);

/**
* Modify the sort data SQL query for getting additional fields if needed
*
* @event core.viewforum_modify_sort_data_sql
* @var int forum_id The forum_id whose topics are being listed
* @var int start Variable containing start for pagination
* @var int sort_days The oldest topic displayable in elapsed days
* @var string sort_key The sorting by. It is one of the first character of (in low case):
* Author, Post time, Replies, Subject, Views
* @var string sort_dir Either "a" for ascending or "d" for descending
* @var array sql_array The SQL array to get the data of all topics
* @since 3.1.9-RC1
*/
$vars = array(
'forum_id',
'start',
'sort_days',
'sort_key',
'sort_dir',
'sql_array',
);
extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_sort_data_sql', compact($vars)));

$result = $db->sql_query($db->sql_build_query('SELECT', $sql_array));

	$topics_count = (int) $db->sql_fetchfield('num_topics');
$db->sql_freeresult($result);


	$topics_count = (int) $db->sql_fetchfield('num_topics');
$db->sql_freeresult($result);


Line 370Line 399
	'U_MCP'				=> ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;i=main&amp;mode=forum_view", true, $user->session_id) : '',
'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=post&amp;f=' . $forum_id) : '',
'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_MCP'				=> ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;i=main&amp;mode=forum_view", true, $user->session_id) : '',
'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=post&amp;f=' . $forum_id) : '',
'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" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($start) ? "&amp;start=$start" : ''), true, ''),

	'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_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()) : '',
));


Line 390Line 419

/**
* Event to modify the SQL query before the topic data is retrieved


/**
* Event to modify the SQL query before the topic data is retrieved

 
*
* It may also be used to override the above assigned template vars

*
* @event core.viewforum_get_topic_data
* @var array forum_data Array with forum data
* @var array sql_array The SQL array to get the data of all topics

*
* @event core.viewforum_get_topic_data
* @var array forum_data Array with forum data
* @var array sql_array The SQL array to get the data of all topics

 
* @var	int		forum_id			The forum_id whose topics are being listed
* @var int topics_count The total number of topics for display
* @var int sort_days The oldest topic displayable in elapsed days
* @var string sort_key The sorting by. It is one of the first character of (in low case):
* Author, Post time, Replies, Subject, Views
* @var string sort_dir Either "a" for ascending or "d" for descending

* @since 3.1.0-a1

* @since 3.1.0-a1

* @change 3.1.0-RC4 Added forum_data var 



* @changed 3.1.0-RC4 Added forum_data var
* @changed 3.1.4-RC1 Added forum_id, topics_count, sort_days, sort_key and sort_dir vars
* @changed 3.1.9-RC1 Fix types of properties

*/
$vars = array(
'forum_data',
'sql_array',

*/
$vars = array(
'forum_data',
'sql_array',

 
	'forum_id',
'topics_count',
'sort_days',
'sort_key',
'sort_dir',

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


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


Line 449Line 493

'ORDER_BY' => 't.topic_time DESC',
);


'ORDER_BY' => 't.topic_time DESC',
);

 

/**
* Event to modify the SQL query before the announcement topic ids data is retrieved
*
* @event core.viewforum_get_announcement_topic_ids_data
* @var array forum_data Data about the forum
* @var array g_forum_ary Global announcement forums array
* @var array sql_anounce_array SQL announcement array
* @var array sql_ary SQL query array to get the announcement topic ids data
* @var int forum_id The forum ID
*
* @since 3.1.10-RC1
*/
$vars = array(
'forum_data',
'g_forum_ary',
'sql_anounce_array',
'sql_ary',
'forum_id',
);
extract($phpbb_dispatcher->trigger_event('core.viewforum_get_announcement_topic_ids_data', compact($vars)));


	$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);


	$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);


Line 504Line 570
	// 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);
$sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count);

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

}
else
{

}
else
{

Line 554Line 620
* Event to modify the SQL query before the topic ids data is retrieved
*
* @event core.viewforum_get_topic_ids_data

* Event to modify the SQL query before the topic ids data is retrieved
*
* @event core.viewforum_get_topic_ids_data

 
* @var	array	forum_data		Data about the forum

* @var	array	sql_ary			SQL query array to get the topic ids data
* @var string sql_approved Topic visibility SQL string
* @var int sql_limit Number of records to select

* @var	array	sql_ary			SQL query array to get the topic ids data
* @var string sql_approved Topic visibility SQL string
* @var int sql_limit Number of records to select

Line 564Line 631
* @var	bool	store_reverse	Flag indicating if we select from the late pages
*
* @since 3.1.0-RC4

* @var	bool	store_reverse	Flag indicating if we select from the late pages
*
* @since 3.1.0-RC4

 
*
* @changed 3.1.3 Added forum_data

*/
$vars = array(

*/
$vars = array(

 
	'forum_data',

	'sql_ary',
'sql_approved',
'sql_limit',

	'sql_ary',
'sql_approved',
'sql_limit',

Line 694Line 764

// 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($global_announce_forums);

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


$base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''));


$base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''));

$pagination->generate_template_pagination($base_url, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start);

$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_topic_count, $config['topics_per_page'], $start);


$template->assign_vars(array(
'TOTAL_TOPICS' => ($s_display_active) ? false : $user->lang('VIEW_FORUM_TOPICS', (int) $total_topic_count),


$template->assign_vars(array(
'TOTAL_TOPICS' => ($s_display_active) ? false : $user->lang('VIEW_FORUM_TOPICS', (int) $total_topic_count),

Line 713Line 783
* @var	array	topic_list			Array with current viewforum page topic ids
* @var array rowset Array with topics data (in topic_id => topic_data format)
* @var int total_topic_count Forum's total topic count

* @var	array	topic_list			Array with current viewforum page topic ids
* @var array rowset Array with topics data (in topic_id => topic_data format)
* @var int total_topic_count Forum's total topic count

 
* @var	int		forum_id			Forum identifier

* @since 3.1.0-b3

* @since 3.1.0-b3

 
* @changed 3.1.11-RC1 Added forum_id

*/

*/

$vars = array('topic_list', 'rowset', 'total_topic_count');

$vars = array('topic_list', 'rowset', 'total_topic_count', 'forum_id');

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

Line 870Line 942
		* Modify the topic data before it is assigned to the template
*
* @event core.viewforum_modify_topicrow

		* Modify the topic data before it is assigned to the template
*
* @event core.viewforum_modify_topicrow

		* @var	array	row			Array with topic data
* @var array topic_row Template array with topic data



		* @var	array	row					Array with topic data
* @var array topic_row Template array with topic data
* @var bool s_type_switch Flag indicating if the topic type is [global] announcement
* @var bool s_type_switch_test Flag indicating if the test topic type is [global] announcement

		* @since 3.1.0-a1

		* @since 3.1.0-a1

 
		*
* @changed 3.1.10-RC1 Added s_type_switch, s_type_switch_test

		*/

		*/

		$vars = array('row', 'topic_row');

		$vars = array('row', 'topic_row', 's_type_switch', 's_type_switch_test');

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

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

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

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

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

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

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

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

 

/**
* Event after the topic data has been assigned to the template
*
* @event core.viewforum_topic_row_after
* @var array row Array with the topic data
* @var array rowset Array with topics data (in topic_id => topic_data format)
* @var bool s_type_switch Flag indicating if the topic type is [global] announcement
* @var int topic_id The topic ID
* @var array topic_list Array with current viewforum page topic ids
* @var array topic_row Template array with topic data
* @since 3.1.3-RC1
*/
$vars = array(
'row',
'rowset',
's_type_switch',
'topic_id',
'topic_list',
'topic_row',
);
extract($phpbb_dispatcher->trigger_event('core.viewforum_topic_row_after', compact($vars)));


if ($unread_topic)
{


if ($unread_topic)
{