From 9b79d3d5161db44a80b72a96d736f72b08039e48 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 26 Jan 2010 20:15:43 +0000 Subject: [PATCH] Integrate wpmu_blogger_getUsersBlogs() directly into xmlrpc.php. see #11644 git-svn-id: http://svn.automattic.com/wordpress/trunk@12852 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-default-filters.php | 1 - wp-includes/ms-functions.php | 32 -------------------------- xmlrpc.php | 37 +++++++++++++++++++++++++++--- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/wp-includes/ms-default-filters.php b/wp-includes/ms-default-filters.php index 857ea9ea76..d574c88820 100644 --- a/wp-includes/ms-default-filters.php +++ b/wp-includes/ms-default-filters.php @@ -2,7 +2,6 @@ // Users add_filter ( 'wpmu_validate_user_signup', 'signup_nonce_check' ); add_action ( 'init', 'maybe_add_existing_user_to_blog' ); -add_filter ( 'xmlrpc_methods', 'attach_wpmu_xmlrpc' ); add_filter ( 'wp_authenticate_user', 'wordpressmu_authenticate_siteadmin', 10, 2 ); add_action ( 'wpmu_new_user', 'newuser_notify_siteadmin' ); add_action ( 'wpmu_activate_user', 'add_new_user_to_blog', 10, 3 ); diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 7c9b1b52c4..a56fcdc0fe 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -1789,38 +1789,6 @@ function wordpressmu_wp_mail_from( $email ) { return $email; } -/* -XMLRPC getUsersBlogs() for a multiblog environment -http://trac.mu.wordpress.org/attachment/ticket/551/xmlrpc-mu.php -*/ -function wpmu_blogger_getUsersBlogs( $args ) { - global $current_blog; - $domain = $current_blog->domain; - $path = $current_blog->path . 'xmlrpc.php'; - - $rpc = new IXR_Client("http://{$domain}{$path}"); - $rpc->query('wp.getUsersBlogs', $args[1], $args[2]); - $blogs = $rpc->getResponse(); - - if ( isset($blogs['faultCode']) ) - return new IXR_Error($blogs['faultCode'], $blogs['faultString']); - - if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) { - return $blogs; - } else { - foreach ( (array) $blogs as $blog ) { - if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) ) - return array($blog); - } - return array(); - } -} - -function attach_wpmu_xmlrpc( $methods ) { - $methods['blogger.getUsersBlogs'] = 'wpmu_blogger_getUsersBlogs'; - return $methods; -} - function mu_locale( $locale ) { if ( defined('WP_INSTALLING') == false ) { $mu_locale = get_option('WPLANG'); diff --git a/xmlrpc.php b/xmlrpc.php index 7528f81882..0c7846d51e 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -452,9 +452,9 @@ class wp_xmlrpc_server extends IXR_Server { $username = $args[0]; $password = $args[1]; - if ( !$user = $this->login($username, $password) ) { + if ( !$user = $this->login($username, $password) ) return $this->error; - } + do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); @@ -1546,6 +1546,8 @@ class wp_xmlrpc_server extends IXR_Server { * @return array */ function blogger_getUsersBlogs($args) { + if ( is_multisite() ) + return _multisite_getUsersBlogs($args); $this->escape($args); @@ -1570,6 +1572,35 @@ class wp_xmlrpc_server extends IXR_Server { return array($struct); } + /** + * Private function for retrieving a users blogs for multisite setups + * + * @access protected + */ + function _multisite_getUsersBlogs($args) { + global $current_blog; + $domain = $current_blog->domain; + $path = $current_blog->path . 'xmlrpc.php'; + $protocol = is_ssl() ? 'https' : 'http'; + + $rpc = new IXR_Client("$protocol://{$domain}{$path}"); + $rpc->query('wp.getUsersBlogs', $args[1], $args[2]); + $blogs = $rpc->getResponse(); + + if ( isset($blogs['faultCode']) ) + return new IXR_Error($blogs['faultCode'], $blogs['faultString']); + + if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) { + return $blogs; + } else { + foreach ( (array) $blogs as $blog ) { + if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) ) + return array($blog); + } + return array(); + } + } + /** * Retrieve user's data. * @@ -2106,7 +2137,7 @@ class wp_xmlrpc_server extends IXR_Server { if ( $post_more ) $post_content = $post_content . "" . $post_more; - + $to_ping = $content_struct['mt_tb_ping_urls']; if ( is_array($to_ping) ) $to_ping = implode(' ', $to_ping);