/** * Returns the topics which are tagged with the given tag * * @since 1.0 * @return integer|object The topic data 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 string $args[2] The tag name or slug * @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 the latest 10 topics tagged with the tag "apples" * <methodCall> * <methodName>bb.getTopicTag</methodName> * <params> * <param><value><string>joeblow</string></value></param> * <param><value><string>123password</string></value></param> * <param><value><string>apples</string></value></param> * <param><value><string>10</string></value></param> * </params> * </methodCall> */ function bb_getTopicTag($args) { do_action('bb_xmlrpc_call', 'bb.getTopicTag'); // 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.getTopicTag'); // If an error was raised by authentication or by an action then return it if ($this->error) { return $this->error; } // Can only be a string $tag_id = isset($args[2]) ? (string) $args[2] : false; // Check for bad data if (!$tag_id) { $this->error = new IXR_Error(400, __('The tag id is invalid.')); return $this->error; } // Check the requested topic exists if (!($tag = bb_get_tag($tag_id))) { $this->error = new IXR_Error(400, __('No tag found.')); return $this->error; } // Get the numeric tag id $tag_id = (int) $tag->tag_id; // Setup an array to store arguments to pass to get_tagged_topics() function $get_topics_args = array('tag_id' => false, 'number' => false, 'page' => false); // 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; } // Now get the topics if (!($topics = get_tagged_topics($tag_id))) { $this->error = new IXR_Error(500, __('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.getTopicTag'); // Return the topics return $_topics; }
<?php require_once './bb-load.php'; bb_repermalink(); // Temporary, refactor this! if (!$tag && $tag_name) { bb_die(__('Tag not found')); } if ($tag_name && $tag) { if ($topics = get_tagged_topics($tag->tag_id, $page)) { bb_cache_last_posts($topics); } bb_load_template('tag-single.php', array('tag', 'tag_name', 'topics'), $tag->tag_id); } else { bb_load_template('tags.php'); }
} if (!$user) { die; } if (!($posts = get_user_favorites($user->ID))) { die; } $title = esc_html(sprintf(__('%1$s » User Favorites: %2$s'), bb_get_option('name'), $user->user_login)); $link = bb_get_profile_link($feed_id); $link_self = get_favorites_rss_link($feed_id); break; case 'tag-topics': if (!($tag = bb_get_tag($feed_id))) { die; } if (!($topics = get_tagged_topics(array('tag_id' => $tag->tag_id, 'page' => 0)))) { die; } $posts = array(); foreach ($topics as $topic) { $posts[] = bb_get_first_post($topic->topic_id); } $title = esc_html(sprintf(__('%1$s » Tag: %2$s - Recent Topics'), bb_get_option('name'), bb_get_tag_name())); $link = bb_get_tag_link($feed_id); $link_self = bb_get_tag_topics_rss_link($feed_id); break; case 'tag-posts': if (!($tag = bb_get_tag($feed_id))) { die; } if (!($posts = get_tagged_topic_posts(array('tag_id' => $tag->tag_id, 'page' => 0)))) {