if ($excludeForums != '')
{
// remove trailing comma
$excludeForums = rtrim($excludeForums, ',');
$nodeIds = explode(',', $excludeForums);
// create whereclause1 of excluded forums
$whereclause2 = 'AND (xf_thread.node_id = ' . implode(' OR xf_thread.node_id <> ', $nodeIds);
$whereclause2 = $whereclause2 . ')';
}else{
$whereclause2 = $whereclause1;
}
// get database
$db = XenForo_Application::get('db');
// run query
$recentPosts = $db->fetchAll("
SELECT xf_thread.thread_id,
xf_thread.title,
xf_node.node_id,
xf_node.title AS nodeTitle,
xf_post.message,
xf_user.avatar_date,
xf_user.user_id
FROM xf_thread
INNER JOIN xf_node ON xf_node.node_id = xf_thread.node_id
INNER JOIN xf_user ON xf_user.user_id = xf_thread.user_id
INNER JOIN xf_post ON xf_post.post_id = xf_thread.first_post_id
LEFT JOIN xf_thread_redirect ON xf_thread_redirect.thread_id = xf_thread.thread_id
WHERE xf_thread.discussion_state = 'visible'
AND xf_thread_redirect.thread_id IS NULL
$whereclause2
ORDER BY xf_thread.last_post_date DESC
LIMIT " . $limit . "
");