PHP Code:
$number = $vbulletin->options['latest_x_threads_number'];
$conditions = array('1=1');
$excludearray = array(18);
$includeforums = array();
foreach ($vbulletin->userinfo['forumpermissions'] AS $forumid => $fperms)
{
if (
!($fperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR
!($fperms & $vbulletin->bf_ugp_forumpermissions['cansearch']) OR
!verify_forum_password($forumid, $forum['password'], false) OR
!($vbulletin->forumcache[$forumid]['options'] & $vbulletin->bf_misc_forumoptions['indexposts'])
)
{
$excludearray[] = $forumid;
}
else if (
(!$vbulletin->GPC['titleonly'] OR $vbulletin->GPC['showposts']) AND
!($fperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads'])
)
{
$excludearray[] = $forumid;
}
}
if (!empty($excludelist))
{
$conditions[] = 'forum.forumid NOT IN (' . implode(',', $excludearray) . ')';
}
if (!empty($includeforums))
{
$conditions[] = 'forum.forumid IN (' . implode(',', $includeforums) . ')';
}
$latestthreads = $db->query_read("
SELECT thread.*, thread.open AS open, forum.title as forumname, forum.forumid as forumid,
icon.iconpath AS iconpath, icon.iconid, IF (thread.iconid=0, 'images/icons/icon1.gif', icon.iconpath)as icon
FROM " . TABLE_PREFIX . "thread as thread
LEFT JOIN " . TABLE_PREFIX . "forum as forum ON (forum.forumid = thread.forumid)
LEFT JOIN " . TABLE_PREFIX . "icon as icon ON (icon.iconid = thread.iconid)
WHERE " . implode(' and ', $conditions) . "
ORDER BY thread.lastpost DESC
LIMIT 0,$number
");
while ($thread = $db->fetch_array($latestthreads))
{
if (
$thread['replycount'] >= $vbulletin->options['hotnumberposts'] OR
$thread['views'] >= $vbulletin->options['hotnumberviews']
)
{
$thread['statusicon'] = "_hot_new";
}
if (!$thread['open'])
{
$thread['statusicon'] = "_lock";
if (
$thread['replycount'] >= $vbulletin->options['hotnumberposts'] OR
$thread['views'] >= $vbulletin->options['hotnumberviews'])
{
$thread['statusicon'] = "_hot_lock";
}
}
eval('$latest_x_threads_bits .= "' . fetch_template('latest_x_threads_bits') . '";');
}
eval('$latest_x_threads = "' . fetch_template('latest_x_threads') . '";');