'.(time()-(int)$max_age*86400).') AND ';
$forum = new e107forum;
$forumList = implode(',', $forum->getForumPermList('view'));
//TODO: Use query from forum class to get thread list
$qry = "
SELECT
p.post_user, p.post_id, p.post_datestamp, p.post_user_anon, p.post_entry,
t.thread_id, t.thread_datestamp, t.thread_name, u.user_name
FROM `#forum_post` as p
LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.post_thread
LEFT JOIN `#user` AS u ON u.user_id = p.post_user
WHERE {$maxage} p.post_forum IN ({$forumList})
ORDER BY p.post_datestamp DESC LIMIT 0, ".$menu_pref['newforumposts_display'];
// Get forum plugin preferences.
$plugForumPrefs = e107::getPlugConfig('forum')->getPref();
// New MySQL class instantiation to avoid overrides.
$db = new e_db_mysql();
// TODO: cache menu.
if($results = $sql->gen($qry))
{
$text = "
";
while($row = $sql->fetch(MYSQL_ASSOC))
{
$datestamp = $gen->convert_date($row['post_datestamp'], 'relative');
$id = $row['thread_id'];
$topic = ($row['thread_datestamp'] == $row['post_datestamp'] ? '' : 'Re:');
$topic .= strip_tags($tp->toHTML($row['thread_name'], true, 'emotes_off, no_make_clickable, parse_bb', '', $pref['menu_wordwrap']));
if($row['post_user_anon'])
{
$poster = $row['post_user_anon'];
}
else
{
if($row['user_name'])
{
$poster = " $row['user_name'], 'id' => $row['post_user']))."'>{$row['user_name']}";
}
else
{
$poster = '[deleted]';
}
}
$post = strip_tags($tp->toHTML($row['post_entry'], true, 'emotes_off, no_make_clickable', '', $pref['menu_wordwrap']));
$post = $tp->text_truncate($post, $menu_pref['newforumposts_characters'], $menu_pref['newforumposts_postfix']);
// Count previous posts for calculating proper (topic) page number for the current post.
$postNum = $db->count('forum_post', '(*)', "WHERE post_id <= " . $row['post_id'] . " AND post_thread = " . $row['thread_id'] . " ORDER BY post_id ASC");
// Calculate (topic) page number for the current post.
$postPage = ceil($postNum / vartrue($plugForumPrefs['postspage'], 10));
// Load thread for passing it to e107::url().
$thread = $db->retrieve('forum_thread', '*', 'thread_id = ' . $row['thread_id']);
// Create URL for post.
// like: e107_plugins/forum/forum_viewtopic.php?id=1&p=2#post-55
$url = e107::url('forum', 'topic', $thread, array(
'query' => array(
'p' => $postPage, // proper page number
),
'fragment' => 'post-' . $row['post_id'], // jump page to post
));
$text .= "- ";
if ($menu_pref['newforumposts_title'])
{
$text .= "{$topic}
{$post}
".LAN_FORUM_MENU_001." {$poster} {$datestamp}";
}
else
{
$text .= "".LAN_FORUM_MENU_001." {$poster} {$datestamp}
{$post}
";
}
$text .= " ";
}
$text .= "
";
}
else
{
$text = LAN_FORUM_MENU_002;
}
e107::getRender()->tablerender($menu_pref['newforumposts_caption'], $text, 'nfp_menu');