Exemplo n.º 1
0
/**
 * wp.getAuthors
 *
 * @see http://codex.wordpress.org/XML-RPC_wp#wp.getAuthors
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 blogid (int): Unique identifier of the blog.
 *					1 username (string): User login.
 *					2 password (string): Password for said username.
 */
function wp_getauthors($m)
{
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 1, 2))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET BLOG:
    /**
     * @var Blog
     */
    if (!($Blog =& xmlrpcs_get_Blog($m, 0))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    if (!$current_User->check_perm('users', 'view')) {
        return xmlrpcs_resperror(5, T_('You have no permission to view other users!'));
    }
    load_class('users/model/_userlist.class.php', 'UserList');
    $UserList = new UserList('', NULL, 'u_', array('join_group' => false, 'join_session' => false, 'join_country' => false, 'join_city' => false));
    // Run the query:
    $UserList->query();
    logIO('Found users: ' . $UserList->result_num_rows);
    $data = array();
    while ($User =& $UserList->get_next()) {
        $data[] = new xmlrpcval(array('user_id' => new xmlrpcval($User->ID, 'int'), 'user_login' => new xmlrpcval($User->login), 'display_name' => new xmlrpcval($User->get_preferred_name())), 'struct');
    }
    logIO('OK.');
    return new xmlrpcresp(new xmlrpcval($data, 'array'));
}