コード例 #1
0
function fr_parse_conversation($message, $bbcode = false)
{
    $message_tree = vB_Api::instance('content_privatemessage')->getMessage($message['nodeid']);
    $new_posts = false;
    $message_ids = array();
    foreach ($message_tree['messages'] as $message) {
        if (!$message['msgread']) {
            $message_ids[] = $message['nodeid'];
            $new_posts = true;
        }
    }
    if ($new_posts) {
        vB_Api::instance('content_privatemessage')->setRead($message_ids, 0);
    }
    $message = $message_tree['message'];
    $out = array('conversation_id' => $message['nodeid'], 'title' => $message['title'] ? $message['title'] : remove_bbcode($message['pagetext']), 'new_posts' => $new_posts, 'total_messages' => count($message_tree['messages']));
    if ($message['lastcontentid'] > 0) {
        $lastcontent = $message_tree['messages'][$message['lastcontentid']];
        $out['userid'] = $message['lastauthorid'];
        $out['username'] = $message['lastauthorid'] > 0 ? $message['lastcontentauthor'] : (string) new vB_Phrase('global', 'guest');
        $out['preview'] = make_preview($lastcontent['rawtext']);
        $out['lastmessagetime'] = fr_date($message['lastcontent']);
    } else {
        $out['userid'] = $message['userid'];
        $out['username'] = $message['authorname'];
        $out['preview'] = make_preview($message['rawtext']);
        $out['lastmessagetime'] = fr_date($message['publishdate']);
    }
    return $out;
}
コード例 #2
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;
}