コード例 #1
0
ファイル: profile.php プロジェクト: cedwards-reisys/nexus-web
function do_get_profile()
{
    global $vbulletin;
    $userinfo = vB_Api::instance('user')->fetchUserInfo();
    $cleaned = vB::getCleaner()->cleanArray($_REQUEST, array('userid' => vB_Cleaner::TYPE_UINT));
    if (!$userinfo['userid'] && !$cleaned['userid']) {
        return json_error(ERR_INVALID_LOGGEDIN, RV_NOT_LOGGED_IN);
    }
    if (!$cleaned['userid']) {
        $cleaned['userid'] = $userinfo['userid'];
    }
    $profile = vB_Api::instance('user')->fetchProfileInfo($cleaned['userid']);
    if (empty($profile)) {
        return json_error(ERR_NO_PERMISSION);
    }
    $values = array();
    foreach ($profile['customFields']['default'] as $name => $value) {
        $value = $value['val'];
        if ($value === null) {
            $value = '';
        }
        $values[] = array('name' => (string) new vB_Phrase('cprofilefield', $name), 'value' => $value);
    }
    $groups = array();
    $groups[] = array('name' => 'about', 'values' => $values);
    $out = array('username' => prepare_utf8_string($profile['username']), 'joindate' => prepare_utf8_string(fr_date($profile['joindate'])), 'posts' => $profile['posts'], 'online' => fr_get_user_online($profile['lastactivity']), 'avatar_upload' => $profile['canuseavatar'] ? true : false, 'groups' => $groups);
    $avatarurl = vB_Library::instance('vb4_functions')->avatarUrl($cleaned['userid']);
    if ($avatarurl) {
        $out['avatarurl'] = $avatarurl;
    }
    cache_moderators();
    cache_permissions($vbulletin->userinfo);
    $canbanuser = ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] or can_moderate(0, 'canbanusers'));
    if ($canbanuser) {
        $out['ban'] = true;
    }
    return $out;
}
コード例 #2
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;
}
コード例 #3
0
ファイル: pms.php プロジェクト: cedwards-reisys/nexus-web
function fr_parse_pm($message, $bbcode = false)
{
    $participants = vB_Api::instance('content_privatemessage')->fetchParticipants($message['nodeid']);
    $users = array();
    if (!empty($participants)) {
        foreach ($participants as $recipient) {
            $users[] = $recipient['username'];
        }
    }
    $message_text = $message['rawtext'];
    if ($bbcode) {
        $message_text = fr_parse_pm_bbcode($message_text);
    } else {
        $message_text = strip_bbcode($message_text);
    }
    $out = array('id' => $message['nodeid'], 'username' => $message['username'], 'to_usernames' => implode('; ', $users), 'message' => $message_text, 'pm_timestamp' => fr_date($message['publishdate']), 'title' => $message['title'] ? $message['title'] : $message['previewtext'], 'new_pm' => $message['msgread'] ? false : true);
    if ($avatarurl = fr_find_avatarurl($message)) {
        $out['avatarurl'] = $avatarurl;
    }
    return $out;
}
コード例 #4
0
function fr_parse_post($node, $signature = true, $html = true)
{
    $userinfo = vB_Api::instance('user')->fetchUserinfo($node['userid']);
    $options = vB::get_datastore()->get_value('options');
    $post = array('post_id' => $node['nodeid'], 'thread_id' => $node['starter'], 'post_timestamp' => fr_date($node['created']), 'forum_id' => $node['content']['channelid'], 'forum_title' => html_entity_decode($node['content']['channeltitle']), 'title' => html_entity_decode($node['title']), 'username' => $node['userid'] > 0 ? $node['authorname'] : (string) new vB_Phrase('global', 'guest'), 'userid' => $node['userid'], 'joindate' => fr_date($userinfo['joindate']), 'usertitle' => $userinfo['usertitle'], 'numposts' => $userinfo['posts'], 'online' => fr_get_user_online($userinfo['lastactivity']), 'text' => strip_bbcode($node['content']['rawtext']), 'quotable' => $node['content']['rawtext'], 'edittext' => $node['content']['rawtext'], 'canedit' => $node['content']['permissions']['canedit'], 'candelete' => $node['content']['permissions']['canmoderate'], 'canlike' => $node['content']['permissions']['canuserep'] > 0, 'likes' => $node['content']['nodeVoted'] ? true : false);
    if (!empty($node['deleteuserid'])) {
        $post['deleted'] = true;
        $del_userinfo = vB_Api::instance('user')->fetchUserInfo($node['deleteuserid']);
        $post['del_username'] = $del_userinfo['username'];
        $post['del_reason'] = $node['deletereason'];
    }
    if ($avatarurl = fr_find_avatarurl($node)) {
        $post['avatarurl'] = $options['bburl'] . '/' . $avatarurl;
    }
    $inline_images = array();
    if ($signature || $html) {
        $bbcode = fr_post_to_bbcode($node, $html);
        if ($signature) {
            $post['signature'] = $bbcode['signature'];
        }
        if ($html) {
            $post['text'] = $bbcode['html'];
            $post['html'] = $bbcode['html'];
        }
        $inline_images = $bbcode['images'];
    }
    if (!empty($node['content']['attach'])) {
        $fr_images = array();
        foreach ($node['content']['attach'] as $attachment) {
            if ($attachment['visible'] > 0) {
                $image = fr_base_url() . 'filedata/fetch?id=' . $attachment['nodeid'];
                $fr_images[] = array('img' => $image);
                if (!in_array($image, $inline_images)) {
                    $post['text'] .= "<img src=\"{$image}\"/>";
                    $post['html'] .= "<img src=\"{$image}\"/>";
                }
            }
        }
        $post['fr_images'] = $fr_images;
    }
    return $post;
}