function do_get_subscriptions() { $userinfo = vB_Api::instance('user')->fetchUserInfo(); if ($userinfo['userid'] < 1) { return json_error(ERR_NO_PERMISSION); } $cleaned = vB::getCleaner()->cleanArray($_REQUEST, array('page' => vB_Cleaner::TYPE_UINT, 'perpage' => vB_Cleaner::TYPE_UINT, 'previewtype' => vB_Cleaner::TYPE_UINT)); $cleaned['page'] = $cleaned['page'] ? $cleaned['page'] : 1; $cleaned['perpage'] = $cleaned['perpage'] ? $cleaned['perpage'] : 10; $cleaned['previewtype'] = $cleaned['previewtype'] ? $cleaned['previewtype'] : 1; $subscribed_nodes = vB_Api::instance('follow')->getFollowing($userinfo['userid'], vB_Api_Follow::FOLLOWTYPE_CONTENT, array(vB_Api_Follow::FOLLOWFILTERTYPE_SORT => vB_Api_Follow::FOLLOWFILTER_SORTALL, vB_Api_Follow::FOLLOWTYPE => vB_Api_Follow::FOLLOWTYPE_CONTENT), null, array('perpage' => $cleaned['perpage'], 'page' => $cleaned['page'])); if (empty($subscribed_nodes) || !empty($subscribed_nodes['errors'])) { return json_error(ERR_NO_PERMISSION); } $threads = array(); foreach ($subscribed_nodes['results'] as $result) { $node = vB_Api::instance('node')->getFullContentforNodes(array($result['keyval'])); if (empty($node)) { continue; } $threads[] = fr_parse_thread($node[0], $cleaned['previewtype']); } return array('total_threads' => $subscribed_nodes['totalcount'], 'threads' => $threads); }
function fr_search_results($searchid, $page, $perpage, $previewtype = 1, $showposts = false) { $result = vB_Api::instance('search')->getMoreNodes($searchid, $perpage, $page); if (empty($result) || !empty($result['error'])) { return json_error(ERR_NO_PERMISSION); } $complete_starters = array(); $threads = array(); foreach ($result['nodeIds'] as $nodeid) { $node = vB_Api::instance('node')->getFullContentforNodes(array($nodeid)); if (empty($node) || !empty($node['errors'])) { continue; } $node = $node[0]; if (!$showposts) { if ($node['nodeid'] != $node['starter'] && !in_array($node['starter'], $complete_starters)) { $node = vB_Api::instance('node')->getFullContentforNodes(array($node['starter'])); $node = $node[0]; $complete_starters[] = $node['starter']; } } $threads[] = fr_parse_thread($node, $previewtype); } $out = array('threads' => $threads, 'total_threads' => $result['totalRecords'], 'searchid' => $searchid); return $out; }
function fr_get_threads_for_forum($forumid, $pagenumber, $perpage, $previewtype = 1) { $topics = array(); $topics_sticky = array(); $total_threads = 0; $search = array("channel" => $forumid); $search['view'] = vB_Api_Search::FILTER_VIEW_TOPIC; $search['depth'] = 1; $search['include_sticky'] = true; $search['sort']['lastcontent'] = 'desc'; $topic_search = vB_Api::instanceInternal('search')->getInitialResults($search, $perpage, $pagenumber, true); if (!isset($topic_search['errors']) and !empty($topic_search['results'])) { foreach ($topic_search['results'] as $key => $node) { if ($node['content']['contenttypeclass'] == 'Text' && $node['content']['starter'] == $node['content']['nodeid']) { $topic = fr_parse_thread($node, $previewtype); if ($node['sticky']) { $topics_sticky[] = $topic; } else { $topics[] = $topic; } } } $total_threads = $topic_search['totalRecords'] - count($topics_sticky); } return array('threads' => $topics, 'stickies' => $topics_sticky, 'total_threads' => $total_threads); }