Recent topics does not respect message limit

Current Version: 1.0.6
Released: 09.01.10
Forum rules
Before creating a new support thread, please take a look in the board3 Portal FAQ and use the search!
Many questions have already been answered.
Locked

Topic author
clarifix
Active Member
Posts: 2
Joined: 4. May 2009 19:16

Recent topics does not respect message limit

Post by clarifix »

Your Portal Version: 1.0.0RC3
Your phpBB Type: Standard phpBB3
MODs installed: No
Your knowledge: Basic Knowledge
Boardlink: http://www.clarify.net/

What have you done before the problem was there?
nothing

What have you already tryed to solve the problem?
looked at the code

Description and Message
Hi there,
Please have a look at the code in recent.php (root/portal/block).

Code: Select all

// Recent announcements
//
$sql = 'SELECT topic_title, forum_id, topic_id
	FROM ' . TOPICS_TABLE . '
	WHERE topic_status <> ' . FORUM_LINK . '
		AND topic_approved = 1 
		AND ( topic_type = ' . POST_ANNOUNCE . ' OR topic_type = ' . POST_GLOBAL . ' )
		AND topic_moved_id = 0
		' . $sql_where . '
	ORDER BY topic_time DESC';

$result = $db->sql_query_limit($sql, $portal_config['portal_max_topics']);

while( ($row = $db->sql_fetchrow($result)) && ($row['topic_title']) )
{
	// auto auth
	if ( ($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0') )
	{
		$template->assign_block_vars('latest_announcements', array(
			'TITLE'	 		=> character_limit($row['topic_title'], $portal_config['portal_recent_title_limit']),
			'FULL_TITLE'	=> censor_text($row['topic_title']),
			'U_VIEW_TOPIC'	=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . ( ($row['forum_id'] == 0) ? $g_forum_id : $row['forum_id'] ) . '&t=' . $row['topic_id'])
		));
	}
}
You limit the query for the recent topics to the config limit, and then you loop through the records and skip those posts where people do not have access for. This results in rather short lists if the standard users do not have privileges on forums with a high post count.
Can you tell me how to patch this code so the number of recent topics is always the one in $portal_config['portal_max_topics'], regardless of forum privileges? Thanks![/i]

Topic author
clarifix
Active Member
Posts: 2
Joined: 4. May 2009 19:16

Re: Recent topics does not respect message limit

Post by clarifix »

Never mind. I managed to patch the code myself. Not a very high quality thing, but it helps me out. I hardcoded a maximum and keep track with a counter. Still maybe something to fix in future releases.

Code: Select all

$sql = 'SELECT topic_title, forum_id, topic_id
	FROM ' . TOPICS_TABLE . '
	WHERE topic_status <> ' . ITEM_MOVED . '
		AND topic_approved = 1 
		AND topic_type = ' . POST_NORMAL . '
		AND topic_moved_id = 0
		' . $sql_where . '
	ORDER BY topic_time DESC';

$maxRows = 100 ;
$result = $db->sql_query_limit($sql, $maxRows);

$configMax = $portal_config['portal_max_topics'] ;
$counter = 1 ;

while( ($row = $db->sql_fetchrow($result)) && ($row['topic_title']) && ( $counter <= $configMax ) )
{
	// auto auth
	if ( ($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0') )
	{
		$counter = $counter + 1 ;
		$template->assign_block_vars('latest_topics', array(...
Locked

Return to “board3 Portal 1.0.x - English Support”