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
This commit is contained in:
ryan 2010-01-26 20:15:43 +00:00
parent e6b0d64b4e
commit 9b79d3d516
3 changed files with 34 additions and 36 deletions

View File

@ -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 );

View File

@ -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');

View File

@ -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 . "<!--more-->" . $post_more;
$to_ping = $content_struct['mt_tb_ping_urls'];
if ( is_array($to_ping) )
$to_ping = implode(' ', $to_ping);