Now, for the xThreads part, bear with me in the process as I didn't test this.
Find:
$query = $db->simple_select("threads", "tid,fid,subject,dateline,replies,lastpost,lastposter,lastposteruid,prefix,closed", "visible = 1". $tids . $forum_select ." ORDER BY `tid` DESC LIMIT ". $start .", ". $per_page);
Replace with:
$threadfield_cache = xthreads_gettfcache();
$xt_fields = '';
if(!empty($threadfield_cache))
{
$fids = empty($fids) ? false : array_map('intval', explode(',', $fids));
$all_fids = empty($fids);
$xt_fields = '';
foreach($threadfield_cache as $k => &$v) {
$available = (!$v['forums']) || $all_fids;
if(!$available)
foreach(explode(',', $v['forums']) as $fid) {
if(isset($fids[$fid])) {
$available = true;
break;
}
}
if($available)
$xt_fields .= ', tfd.`'.$v['field'].'` AS `xthreads_'.$v['field'].'`';
}
}
$query = $db->simple_select("threads t LEFT JOIN {$db->table_prefix}threadfields_data tfd ON (tfd.tid=t.tid) LEFT JOIN {$db->table_prefix}users lu ON (lu.uid=t.lastposteruid)", "t.*{$xt_fields},lu.uid AS lastposter_uid,lu.usergroup AS lastposter_usergroup,lu.displaygroup AS lastposter_displaygroup", "t.visible=1". str_replace('tid', 't.tid', $tids) . str_replace('fid', 't.fid', $forum_select ) , array('limit' => $per_page, 'limit_start' => $start, 'order_by' => 't.tid', 'order_dir' => 'desc'));
$xt_tids = '';
!$threadfield_cache || $xt_tids = '0,'.$topics;
Find:
$page_total++;
Add after:
$threadfields = array();
if(!empty($threadfield_cache)) {
xthreads_set_threadforum_urlvars('thread', $thread['tid']);
xthreads_set_threadforum_urlvars('forum', $thread['fid']);
foreach($threadfield_cache as $k => &$v) {
if($v['forums'] && strpos(','.$v['forums'].',', ','.$thread['fid'].',') === false)
continue;
xthreads_get_xta_cache($v, $xt_tids);
$threadfields[$k] =& $thread['xthreads_'.$k];
xthreads_sanitize_disp($threadfields[$k], $v, ($thread['username'] !== '' ? $thread['username'] : $thread['threadusername']));
}
}
Then cross your fingers and try to use the
{$threadfields}
array in the
threadlog_row
template.
Find:
$thread_latest_poster = "<a href=\"{$mybb->settings['bburl']}/member.php?action=profile&uid=". $thread['lastposteruid'] ."\">". $thread['lastposter'] ."</a>";
Replace with:
$thread_latest_poster = htmlspecialchars_uni($thread['lastposter']);
if($thread['lastposter_uid'])
{
$thread_latest_poster = build_profile_link(format_name($thread_latest_poster, $thread['lastposter_usergroup'], $thread['lastposter_displaygroup']), $thread['lastposter_uid']);
}