Make WordPress Core

Changeset 8075 for trunk/xmlrpc.php


Ignore:
Timestamp:
06/12/2008 09:41:18 PM (16 years ago)
Author:
ryan
Message:

wp.getUsersBlogs from josephscott. fixes #7130

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r7991 r8075  
    111111        $this->methods = array(
    112112            // WordPress API
     113            'wp.getUsersBlogs'      => 'this:wp_getUsersBlogs',
    113114            'wp.getPage'            => 'this:wp_getPage',
    114115            'wp.getPages'           => 'this:wp_getPages',
     
    253254            }
    254255        }
     256    }
     257
     258    /**
     259     * WordPress XML-RPC API
     260     * wp_getUsersBlogs
     261     */
     262    function wp_getUsersBlogs( $args ) {
     263        // If this isn't on WPMU then just use blogger_getUsersBlogs
     264        if( !function_exists( 'is_site_admin' ) ) {
     265            array_unshift( $args, 1 );
     266            return $this->blogger_getUsersBlogs( $args );
     267        }
     268
     269        $this->escape( $args );
     270
     271        $username = $args[0];
     272        $password = $args[1];
     273
     274        if( !$this->login_pass_ok( $username, $password ) )
     275            return $this->error;
     276
     277        do_action( 'xmlrpc_call', 'wp.getUsersBlogs' );
     278
     279        $user = set_current_user( 0, $username );
     280
     281        $blogs = (array) get_blogs_of_user( $user->ID );
     282        $struct = array( );
     283
     284        foreach( $blogs as $blog ) {
     285            // Don't include blogs that aren't hosted at this site
     286            if( $blog->site_id != 1 )
     287                continue;
     288
     289            $blog_id = $blog->userblog_id;
     290            switch_to_blog($blog_id);
     291            $is_admin = current_user_can('level_8');
     292
     293            $struct[] = array(
     294                'isAdmin'       => $is_admin,
     295                'url'           => get_option( 'home' ) . '/',
     296                'blogid'        => $blog_id,
     297                'blogName'      => get_option( 'blogname' ),
     298                'xmlrpc'        => get_option( 'home' ) . '/xmlrpc.php'
     299            );
     300        }
     301
     302        return $struct;
    255303    }
    256304
     
    842890            'url'      => get_option('home') . '/',
    843891            'blogid'   => '1',
    844             'blogName' => get_option('blogname')
     892            'blogName' => get_option('blogname'),
     893            'xmlrpc'   => get_option('home') . '/xmlrpc.php',
    845894        );
    846895
Note: See TracChangeset for help on using the changeset viewer.