<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12852] trunk: Integrate wpmu_blogger_getUsersBlogs() directly into xmlrpc.
 php.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12852">12852</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-01-26 20:15:43 +0000 (Tue, 26 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Integrate wpmu_blogger_getUsersBlogs() directly into xmlrpc.php. see <a href="http://trac.wordpress.org/ticket/11644">#11644</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesmsdefaultfiltersphp">trunk/wp-includes/ms-default-filters.php</a></li>
<li><a href="#trunkwpincludesmsfunctionsphp">trunk/wp-includes/ms-functions.php</a></li>
<li><a href="#trunkxmlrpcphp">trunk/xmlrpc.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesmsdefaultfiltersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-default-filters.php (12851 => 12852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-default-filters.php        2010-01-26 20:02:11 UTC (rev 12851)
+++ trunk/wp-includes/ms-default-filters.php        2010-01-26 20:15:43 UTC (rev 12852)
</span><span class="lines">@@ -2,7 +2,6 @@
</span><span class="cx"> // Users
</span><span class="cx"> add_filter ( 'wpmu_validate_user_signup', 'signup_nonce_check' );
</span><span class="cx"> add_action ( 'init', 'maybe_add_existing_user_to_blog' );
</span><del>-add_filter ( 'xmlrpc_methods', 'attach_wpmu_xmlrpc' );
</del><span class="cx"> add_filter ( 'wp_authenticate_user', 'wordpressmu_authenticate_siteadmin', 10, 2 );
</span><span class="cx"> add_action ( 'wpmu_new_user', 'newuser_notify_siteadmin' );
</span><span class="cx"> add_action ( 'wpmu_activate_user', 'add_new_user_to_blog', 10, 3 );
</span></span></pre></div>
<a id="trunkwpincludesmsfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-functions.php (12851 => 12852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-functions.php        2010-01-26 20:02:11 UTC (rev 12851)
+++ trunk/wp-includes/ms-functions.php        2010-01-26 20:15:43 UTC (rev 12852)
</span><span class="lines">@@ -1789,38 +1789,6 @@
</span><span class="cx">         return $email;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-/*
-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-&gt;domain;
-        $path = $current_blog-&gt;path . 'xmlrpc.php';
-
-        $rpc = new IXR_Client(&quot;http://{$domain}{$path}&quot;);
-        $rpc-&gt;query('wp.getUsersBlogs', $args[1], $args[2]);
-        $blogs = $rpc-&gt;getResponse();
-
-        if ( isset($blogs['faultCode']) )
-                return new IXR_Error($blogs['faultCode'], $blogs['faultString']);
-
-        if ( $_SERVER['HTTP_HOST'] == $domain &amp;&amp; $_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;
-}
-
</del><span class="cx"> function mu_locale( $locale ) {
</span><span class="cx">         if ( defined('WP_INSTALLING') == false ) {
</span><span class="cx">                 $mu_locale = get_option('WPLANG');
</span></span></pre></div>
<a id="trunkxmlrpcphp"></a>
<div class="modfile"><h4>Modified: trunk/xmlrpc.php (12851 => 12852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/xmlrpc.php        2010-01-26 20:02:11 UTC (rev 12851)
+++ trunk/xmlrpc.php        2010-01-26 20:15:43 UTC (rev 12852)
</span><span class="lines">@@ -452,10 +452,10 @@
</span><span class="cx">                 $username = $args[0];
</span><span class="cx">                 $password = $args[1];
</span><span class="cx"> 
</span><del>-                if ( !$user = $this-&gt;login($username, $password) ) {
</del><ins>+                if ( !$user = $this-&gt;login($username, $password) )
</ins><span class="cx">                         return $this-&gt;error;
</span><del>-                }
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">                 do_action( 'xmlrpc_call', 'wp.getUsersBlogs' );
</span><span class="cx"> 
</span><span class="cx">                 $blogs = (array) get_blogs_of_user( $user-&gt;ID );
</span><span class="lines">@@ -1546,6 +1546,8 @@
</span><span class="cx">          * @return array
</span><span class="cx">          */
</span><span class="cx">         function blogger_getUsersBlogs($args) {
</span><ins>+                if ( is_multisite() )
+                        return _multisite_getUsersBlogs($args);
</ins><span class="cx"> 
</span><span class="cx">                 $this-&gt;escape($args);
</span><span class="cx"> 
</span><span class="lines">@@ -1571,6 +1573,35 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><ins>+         * Private function for retrieving a users blogs for multisite setups
+         *
+         * @access protected
+         */
+        function _multisite_getUsersBlogs($args) {
+                global $current_blog;
+                $domain = $current_blog-&gt;domain;
+                $path = $current_blog-&gt;path . 'xmlrpc.php';
+                $protocol = is_ssl() ? 'https' : 'http';
+
+                $rpc = new IXR_Client(&quot;$protocol://{$domain}{$path}&quot;);
+                $rpc-&gt;query('wp.getUsersBlogs', $args[1], $args[2]);
+                $blogs = $rpc-&gt;getResponse();
+
+                if ( isset($blogs['faultCode']) )
+                        return new IXR_Error($blogs['faultCode'], $blogs['faultString']);
+
+                if ( $_SERVER['HTTP_HOST'] == $domain &amp;&amp; $_SERVER['REQUEST_URI'] == $path ) {
+                        return $blogs;
+                } else {
+                        foreach ( (array) $blogs as $blog ) {
+                                if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) )
+                                        return array($blog);
+                        }
+                        return array();
+                }
+        }
+
+        /**
</ins><span class="cx">          * Retrieve user's data.
</span><span class="cx">          *
</span><span class="cx">          * Gives your client some info about you, so you don't have to.
</span><span class="lines">@@ -2106,7 +2137,7 @@
</span><span class="cx"> 
</span><span class="cx">                 if ( $post_more )
</span><span class="cx">                         $post_content = $post_content . &quot;&lt;!--more--&gt;&quot; . $post_more;
</span><del>- 
</del><ins>+
</ins><span class="cx">                 $to_ping = $content_struct['mt_tb_ping_urls'];
</span><span class="cx">                 if ( is_array($to_ping) )
</span><span class="cx">                         $to_ping = implode(' ', $to_ping);
</span></span></pre>
</div>
</div>

</body>
</html>