А разве в 513 версии реализовано то что я хочу?
if (!$forum_id OR !$forum_data = @$forums['forum'][$forum_id])
{
bb_die($lang['FORUM_NOT_EXIST']);
}
$subforums = (isset($forums['f'][$forum_id]['subforums'])) ? $forums['f'][$forum_id]['subforums'] : '';
$sql = "
SELECT t.topic_id
FROM ". BB_TOPICS ." t
WHERE t.forum_id = $forum_id
$only_new_sql
$title_match_sql
$limit_topics_time_sql
$order_sql
LIMIT $start, $topics_per_page
";
$subforums_list = ($subforums) ? ',' . join(',', $subforums) : '';
$sql = "
SELECT t.topic_id
FROM ". BB_TOPICS ." t
WHERE t.forum_id IN ($forum_id$subforums_list)
$only_new_sql
$title_match_sql
$limit_topics_time_sql
$order_sql
LIMIT $start, $topics_per_page
";
unset($subforums, $subforums_list);
$subforums_sql = ($subforums) ? 'OR (t.forum_id IN ('. join(',', $subforums) .') AND t.topic_type = 0)' : '';
$sql = "
SELECT t.topic_id
FROM ". BB_TOPICS ." t
WHERE t.forum_id IN ($forum_id)
$subforums_sql
$only_new_sql
$title_match_sql
$limit_topics_time_sql
$order_sql
LIMIT $start, $topics_per_page
";
unset($subforums, $subforums_sql);