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; }
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; }