示例#1
0
function fr_parse_thread($node, $previewtype = 1)
{
    $userinfo = vB_Api::instance('user')->fetchUserInfo();
    $options = vB::get_datastore()->get_value('options');
    $topic = array('thread_id' => $node['nodeid'], 'thread_title' => html_entity_decode($node['title']), 'forum_id' => $node['parentid'], 'forum_title' => $node['content']['channeltitle'], 'post_username' => $node['userid'] > 0 ? $node['authorname'] : (string) new vB_Phrase('global', 'guest'), 'post_userid' => $node['userid'], 'post_lastposttime' => fr_date($node['lastupdate']), 'total_posts' => $node['textcount']);
    $did_lastcontent = false;
    if ($node['lastcontentid'] > 0 && $node['lastcontentid'] != $node['nodeid'] && $previewtype == 2) {
        $lastcontent = vB_Api::instance('node')->getFullContentforNodes(array($node['lastcontentid']));
        $lastcontent = $lastcontent[0];
        if ($lastcontent['parentid'] == $lastcontent['starter']) {
            if (in_array($lastcontent['content']['contenttypeclass'], array('Text', 'Photo', 'Link', 'Video'))) {
                $topic['post_userid'] = $node['lastauthorid'];
                $topic['post_username'] = $node['lastauthorid'] > 0 ? $node['lastcontentauthor'] : (string) new vB_Phrase('global', 'guest');
                $topic['thread_preview'] = make_preview($lastcontent['content']['rawtext']);
                if ($avatarurl = fr_find_avatarurl($lastcontent)) {
                    $topic['avatarurl'] = $options['bburl'] . '/' . $avatarurl;
                }
                $did_lastcontent = true;
            }
        }
    }
    if (!$did_lastcontent) {
        $topic['thread_preview'] = make_preview($node['content']['rawtext']);
        if ($avatarurl = fr_find_avatarurl($node)) {
            $topic['avatarurl'] = $options['bburl'] . '/' . $avatarurl;
        }
    }
    if ($options['threadmarking'] and $userinfo['userid']) {
        $userlastvisit = !empty($node['readtime']) ? $node['readtime'] : vB::getRequest()->getTimeNow() - $options['markinglimit'] * 86400;
    } else {
        $lastvisit = vB5_Cookie::get('lastvisit', vB5_Cookie::TYPE_UINT);
        $forumview = fr_fetch_bbarray_cookie('discussion-view', $node['nodeid']);
        //use which one produces the highest value, most likely cookie
        $userlastvisit = $forumview > $lastvisit ? $forumview : $lastvisit;
    }
    if (!empty($node['content']['prefix_plain'])) {
        $topic['prefix'] = $node['content']['prefix_plain'];
    }
    $topic['new_posts'] = 0;
    if ($node['lastupdate'] and $userlastvisit < $node['lastupdate']) {
        $topic['new_posts'] = 1;
    }
    return $topic;
}
示例#2
0
function fr_get_and_parse_forum($forumid, $foruminfo = false)
{
    $userinfo = vB_Api::instance('user')->fetchUserInfo();
    $options = vB::get_datastore()->get_value('options');
    if (!$foruminfo) {
        $foruminfo = vB_Api::instance('node')->getFullContentforNodes(array($forumid));
        if (empty($foruminfo)) {
            return null;
        }
        $foruminfo = $foruminfo[0];
    }
    if (!$foruminfo) {
        return null;
    }
    $type = 'old';
    if ($options['threadmarking'] and $userinfo['userid']) {
        $userlastvisit = !empty($foruminfo['readtime']) ? $foruminfo['readtime'] : vB::getRequest()->getTimeNow() - $options['markinglimit'] * 86400;
    } else {
        $lastvisit = vB5_Cookie::get('lastvisit', vB5_Cookie::TYPE_UINT);
        $forumview = fr_fetch_bbarray_cookie('channel_view', $foruminfo['nodeid']);
        //use which one produces the highest value, most likely cookie
        $userlastvisit = $forumview > $lastvisit ? $forumview : $lastvisit;
    }
    if ($foruminfo['lastcontent'] and $userlastvisit < $foruminfo['lastcontent']) {
        $type = 'new';
    } else {
        $type = 'old';
    }
    $out = array('id' => $foruminfo['nodeid'], 'new' => $type == 'new' ? true : false, 'name' => html_entity_decode(strip_tags($foruminfo['title'])), 'password' => false);
    $icon = fr_get_forum_icon($foruminfo['nodeid'], $foruminfo == 'new');
    if ($icon) {
        $out['icon'] = $icon;
    }
    if ($foruminfo['description'] != '') {
        $desc = strip_tags($foruminfo['description']);
        if (strlen($desc) > 0) {
            $out['desc'] = $desc;
        }
    }
    return $out;
}