<?php require './bb-load.php'; bb_repermalink(); $bb_db_override = false; do_action('bb_index.php_pre_db'); if (isset($_GET['new']) && '1' == $_GET['new']) { $forums = false; } elseif (!$bb_db_override) { $forums = bb_get_forums(); // Comment to hide forums if ($topics = get_latest_topics(false, $page)) { bb_cache_last_posts($topics); } if ($super_stickies = get_sticky_topics()) { bb_cache_last_posts($super_stickies); } } bb_load_template('front-page.php', array('bb_db_override', 'super_stickies'));
/** * Returns details of the latest topics * * @since 1.0 * @return array|object The topics when successfully executed or an IXR_Error object on failure * @param array $args Arguments passed by the XML-RPC call * @param string $args[0] The username for authentication * @param string $args[1] The password for authentication * @param integer|string $args[2] The forum id or slug (optional) * @param integer $args[3] The number of topics to return (optional) * @param integer $args[4] The number of the page to return (optional) * * XML-RPC request to get all topics in the bbPress instance * <methodCall> * <methodName>bb.getTopics</methodName> * <params> * <param><value><string>joeblow</string></value></param> * <param><value><string>123password</string></value></param> * </params> * </methodCall> * * XML-RPC request to get all topics in the forum with id number 34 * <methodCall> * <methodName>bb.getTopics</methodName> * <params> * <param><value><string>joeblow</string></value></param> * <param><value><string>123password</string></value></param> * <param><value><int>34</int></value></param> * </params> * </methodCall> * * XML-RPC request to get topics 6 to 10 in the forum with slug "first-forum" * <methodCall> * <methodName>bb.getTopics</methodName> * <params> * <param><value><string>joeblow</string></value></param> * <param><value><string>123password</string></value></param> * <param><value><string>first-forum</string></value></param> * <param><value><int>5</int></value></param> * <param><value><int>2</int></value></param> * </params> * </methodCall> */ function bb_getTopics($args) { do_action('bb_xmlrpc_call', 'bb.getTopics'); // Escape args $this->escape($args); // Get the login credentials $username = $args[0]; $password = (string) $args[1]; // Check the user is valid if ($this->auth_readonly) { $user = $this->authenticate($username, $password); } do_action('bb_xmlrpc_call_authenticated', 'bb.getTopics'); // If an error was raised by authentication or by an action then return it if ($this->error) { return $this->error; } // Setup an array to store arguments to pass to get_topics() function $get_topics_args = array('forum' => false, 'number' => false, 'page' => false); // Can be numeric id or slug if (isset($args[2]) && ($forum_id = $args[2])) { // Check for bad data if (!is_string($forum_id) && !is_integer($forum_id)) { $this->error = new IXR_Error(400, __('The forum id is invalid.')); return $this->error; } // Check the requested forum exists if (!($forum = bb_get_forum($forum_id))) { $this->error = new IXR_Error(400, __('The forum does not exist.')); return $this->error; } // The forum id may have been a slug, so make sure it's an integer here $get_topics_args['forum'] = (int) $forum->forum_id; } // Can only be an integer if (isset($args[3]) && ($number = (int) $args[3])) { $get_topics_args['number'] = $number; } // Can only be an integer if (isset($args[4]) && ($page = (int) $args[4])) { $get_topics_args['page'] = $page; } // Get the topics if (!($topics = get_latest_topics($get_topics_args))) { $this->error = new IXR_Error(400, __('No topics found.')); return $this->error; } // Only include "safe" data in the array $_topics = array(); foreach ($topics as $topic) { $_topics[] = $this->prepare_topic($topic); } do_action('bb_xmlrpc_call_return', 'bb.getTopics'); // Return the topics return $_topics; }
$title = esc_html(sprintf(__('%1$s » Forum: %2$s - Recent Topics'), bb_get_option('name'), get_forum_name($feed_id))); $link = get_forum_link($feed_id); $link_self = bb_get_forum_topics_rss_link($feed_id); break; case 'forum-posts': if (!($posts = bb_get_latest_forum_posts($feed_id))) { die; } $title = esc_html(sprintf(__('%1$s » Forum: %2$s - Recent Posts'), bb_get_option('name'), get_forum_name($feed_id))); $link = get_forum_link($feed_id); $link_self = bb_get_forum_posts_rss_link($feed_id); break; // Get just the first post from the latest topics // Get just the first post from the latest topics case 'all-topics': if (!($topics = get_latest_topics())) { die; } $posts = array(); foreach ($topics as $topic) { $posts[] = bb_get_first_post($topic->topic_id); } $title = esc_html(sprintf(__('%1$s » Recent Topics'), bb_get_option('name'))); $link = bb_get_uri(); $link_self = bb_get_topics_rss_link(); break; // Get latest posts by default // Get latest posts by default case 'all-posts': default: if (!($posts = bb_get_latest_posts(35))) {
<?php require_once './bb-load.php'; $forum_id = 0; bb_repermalink(); if (!$forum) { bb_die(__('Forum not found.')); } $bb_db_override = false; do_action('bb_forum.php_pre_db', $forum_id); if (!$bb_db_override) { if ($topics = get_latest_topics($forum_id, $page)) { bb_cache_last_posts($topics); } if ($stickies = get_sticky_topics($forum_id, $page)) { bb_cache_last_posts($stickies); } } bb_load_template('forum.php', array('bb_db_override', 'stickies'), $forum_id);
$posts[] = bb_get_first_post($topic->topic_id); } $title = sprintf(__('%1$s » Forum: %2$s - Recent Topics'), bb_get_option('name'), get_forum_name($feed_id)); $link = get_forum_link($feed_id); $link_self = bb_get_forum_topics_rss_link($feed_id); break; case 'forum-posts': $posts = bb_get_latest_forum_posts($feed_id); $title = sprintf(__('%1$s » Forum: %2$s - Recent Posts'), bb_get_option('name'), get_forum_name($feed_id)); $link = get_forum_link($feed_id); $link_self = bb_get_forum_posts_rss_link($feed_id); break; // Get just the first post from the latest topics // Get just the first post from the latest topics case 'all-topics': $topics = get_latest_topics(); $posts = array(); foreach ((array) $topics as $topic) { $posts[] = bb_get_first_post($topic->topic_id); } $title = sprintf(__('%1$s » Recent Topics'), bb_get_option('name')); $link = bb_get_uri(); $link_self = bb_get_topics_rss_link(); break; // Get latest posts by default // Get latest posts by default case 'all-posts': default: $posts = bb_get_latest_posts(35); $title = sprintf(__('%1$s » Recent Posts'), bb_get_option('name')); $link = bb_get_uri();
function bb_export() { global $bb; define('BB_EXPORTING', true); do_action('bb_pre_export'); $bb->use_cache = false; // Turn off hard cache $bb->page_topics = 100; echo "<forums-data version='0.75'>\n"; if (BB_EXPORT_LEVEL & BB_EXPORT_USERS) { $page = 1; while (($users = bb_user_search(array('page' => $page++))) && !is_nxt_error($users)) { foreach ($users as $user) { echo bb_export_user($user->ID); } } unset($users, $user, $page); } if (BB_EXPORT_LEVEL & BB_EXPORT_FORUMS) { $forums = bb_get_forums(); foreach ($forums as $forum) { echo bb_export_forum($forum->forum_id); } unset($forums, $forum); } if (BB_EXPORT_LEVEL & BB_EXPORT_TOPICS) { $page = 1; while ($topics = get_latest_topics(0, $page++)) { foreach ($topics as $topic) { echo bb_export_topic($topic->topic_id); } } unset($topics, $topic, $page); } do_action('bb_export'); echo '</forums-data>'; }