Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
function fr_parse_conversation_reply($message, $conversation_id)
{
    $userinfo = vB_Api::instance('user')->fetchUserinfo($message['userid']);
    list($parsed_text, , ) = parse_post($message['rawtext']);
    $out = array('post_id' => $message['nodeid'], 'thread_id' => $conversation_id, 'title' => $message['title'] ? $message['title'] : remove_bbcode($message['pagetext']), 'userid' => $message['userid'], 'username' => $message['authorname'], 'usertitle' => $userinfo['usertitle'], 'numposts' => $userinfo['posts'], 'joindate' => fr_date($userinfo['joindate']), 'online' => fr_get_user_online($userinfo['lastactivity']), 'text' => $parsed_text, 'quotable' => $message['rawtext']);
    return $out;
}
Ejemplo n.º 3
0
function fr_parse_pm_extra($message, $partial)
{
    $partial['pm_unread'] = $partial['new_pm'];
    unset($partial['new_pm']);
    $partial['userid'] = $message['userid'];
    $partial['quotable'] = $message['rawtext'];
    $userinfo = vB_Api::instance('user')->fetchUserInfo($message['userid']);
    $partial['online'] = fr_get_user_online($userinfo['lastactivity']);
    $partial['username'] = $userinfo['username'];
    // XXX: Pass fr_images here if they are ever implemented for PM's
    return $partial;
}
Ejemplo n.º 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;
}