/**
* Widget with last active threads list
*
*/
public function widget_LastActiveThreads()
{
global $db, $lang, $mybb, $templates, $theme, $topStats;
require_once MYBB_ROOT."inc/functions_search.php";
$permsql = "";
$onlyusfids = array();
$group_permissions = forum_permissions();
foreach($group_permissions as $fid => $forum_permissions)
{
if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)
{
$onlyusfids[] = $fid;
}
}
if(!empty($onlyusfids))
{
$permsql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))";
}
$unsearchforums = get_unsearchable_forums();
if($unsearchforums)
{
$permsql .= " AND t.fid NOT IN ($unsearchforums)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{
$permsql .= " AND t.fid NOT IN ($inactiveforums)";
}
$tpl['ignore_forums'] = '';
if(!empty($mybb->settings['topStats_IgnoreForums_LastActiveThreads']))
{
$tpl['ignore_forums'] = "AND t.fid NOT IN ({$mybb->settings['topStats_IgnoreForums_LastActiveThreads']})";
}
$tpl['row'] = '';
$sql = "SELECT t.lastposteruid, t.tid, t.subject, t.lastpost, t.fid, u.usergroup, u.displaygroup, u.avatar, u.avatardimensions, u.username, u.uid
FROM ".TABLE_PREFIX."threads t
INNER JOIN ".TABLE_PREFIX."users u ON (u.uid=t.lastposteruid)
WHERE 1=1 {$tpl['ignore_forums']} {$unapproved_where} {$permsql} AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
ORDER BY t.lastpost DESC LIMIT ". (int)$this->getConfig('Limit_LastActiveThreads') ."";
$result = $db->query($sql);
while ($row = $db->fetch_array($result))
{
$tpl['subject'] = (my_strlen($row['subject']) > 30) ? my_substr($row['subject'], 0, 30) . "..." : $row['subject'];
$tpl['username'] = format_name($row['username'], $row['usergroup'], $row['displaygroup']);
$tpl['profilelink'] = build_profile_link($tpl['username'], $row['uid']);
$tpl['date'] = my_date('relative', $row['lastpost']);
$tpl['subjectlink'] = get_thread_link($row['tid']);
$useravatar = format_avatar(htmlspecialchars_uni($row['avatar']), $row['avatardimensions'], my_strtolower($this->getConfig('AvatarWidth')));
(!$this->getConfig('Status_Avatar')) ? '' : eval("\$tpl['avatar'] = \"".$templates->get("topStats_LastActiveThreadsAvatar")."\";");
eval("\$tpl['row'] .= \"" . $templates->get("topStats_LastActiveThreadsRow") . "\";");
}
eval("\$topStats['LastActiveThreads'] = \"" . $templates->get("topStats_LastActiveThreads") . "\";");