recent.php: f=0 fix, wrong constant

functions.php: use a constant
This commit is contained in:
Ice
2008-08-12 00:30:57 +00:00
parent 336a4ef10e
commit 5ffd76aa65
2 changed files with 20 additions and 4 deletions

View File

@@ -36,6 +36,22 @@ if ($portal_config['portal_exclude_forums'])
} }
} }
// Get a list of forums the user cannot read
$forum_ary = array_unique(array_keys($auth->acl_getf('!f_read', true)));
// Determine first forum the user is able to read (must not be a category)
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST;
if (sizeof($forum_ary))
{
$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true);
}
$result = $db->sql_query_limit($sql, 1);
$g_forum_id = (int) $db->sql_fetchfield('forum_id');
// //
// Recent announcements // Recent announcements
// //
@@ -58,7 +74,7 @@ while( ($row = $db->sql_fetchrow($result)) && ($row['topic_title']) )
$template->assign_block_vars('latest_announcements', array( $template->assign_block_vars('latest_announcements', array(
'TITLE' => character_limit($row['topic_title'], $portal_config['portal_recent_title_limit']), 'TITLE' => character_limit($row['topic_title'], $portal_config['portal_recent_title_limit']),
'FULL_TITLE' => censor_text($row['topic_title']), 'FULL_TITLE' => censor_text($row['topic_title']),
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']) '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'])
)); ));
} }
} }
@@ -85,7 +101,7 @@ while( ($row = $db->sql_fetchrow($result)) && ($row['topic_title']) )
$template->assign_block_vars('latest_hot_topics', array( $template->assign_block_vars('latest_hot_topics', array(
'TITLE' => character_limit($row['topic_title'], $portal_config['portal_recent_title_limit']), 'TITLE' => character_limit($row['topic_title'], $portal_config['portal_recent_title_limit']),
'FULL_TITLE' => censor_text($row['topic_title']), 'FULL_TITLE' => censor_text($row['topic_title']),
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']) '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'])
)); ));
} }
} }
@@ -96,7 +112,7 @@ $db->sql_freeresult($result);
// //
$sql = 'SELECT topic_title, forum_id, topic_id $sql = 'SELECT topic_title, forum_id, topic_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE topic_status <> ' . FORUM_LINK . ' WHERE topic_status <> ' . ITEM_MOVED . '
AND topic_approved = 1 AND topic_approved = 1
AND topic_type = ' . POST_NORMAL . ' AND topic_type = ' . POST_NORMAL . '
AND topic_moved_id = 0 AND topic_moved_id = 0

View File

@@ -224,7 +224,7 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
'WHERE' => $topic_type . ' 'WHERE' => $topic_type . '
' . $post_time . ' ' . $post_time . '
AND t.topic_status <> 2 AND t.topic_status <> ' . ITEM_MOVED . '
AND t.topic_approved = 1 AND t.topic_approved = 1
AND t.topic_moved_id = 0 AND t.topic_moved_id = 0
' . $str_where, ' . $str_where,