More XMLRPC updates from Joseph Scott.
git-svn-id: http://svn.automattic.com/wordpress/trunk@4862 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cd7c0164e9
commit
16c4e7b986
|
@ -56,7 +56,7 @@ function get_users_of_blog( $id = '' ) {
|
||||||
global $wpdb, $blog_id;
|
global $wpdb, $blog_id;
|
||||||
if ( empty($id) )
|
if ( empty($id) )
|
||||||
$id = $blog_id;
|
$id = $blog_id;
|
||||||
$users = $wpdb->get_results( "SELECT user_id, user_login, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE " . $wpdb->users . ".ID = " . $wpdb->usermeta . ".user_id AND meta_key = '" . $wpdb->prefix . "_capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
|
$users = $wpdb->get_results( "SELECT user_id, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE " . $wpdb->users . ".ID = " . $wpdb->usermeta . ".user_id AND meta_key = '" . $wpdb->prefix . "capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
|
||||||
return $users;
|
return $users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,4 +178,4 @@ function setup_userdata($user_id = '') {
|
||||||
$user_identity = $user->display_name;
|
$user_identity = $user->display_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
45
xmlrpc.php
45
xmlrpc.php
|
@ -227,7 +227,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
"wp_page_parent_id" => $page->post_parent,
|
"wp_page_parent_id" => $page->post_parent,
|
||||||
"wp_page_parent_title" => $parent_title,
|
"wp_page_parent_title" => $parent_title,
|
||||||
"wp_page_order" => $page->menu_order,
|
"wp_page_order" => $page->menu_order,
|
||||||
"wp_author_username" => $author->user_login
|
"wp_author_id" => $author->ID,
|
||||||
|
"wp_author_display_username" => $author->display_name
|
||||||
);
|
);
|
||||||
|
|
||||||
return($page_struct);
|
return($page_struct);
|
||||||
|
@ -947,6 +948,23 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
// If an author id was provided then use it instead.
|
// If an author id was provided then use it instead.
|
||||||
if(!empty($content_struct["wp_author_id"])) {
|
if(!empty($content_struct["wp_author_id"])) {
|
||||||
|
switch($post_type) {
|
||||||
|
case "post":
|
||||||
|
if(!current_user_can("edit_others_posts")) {
|
||||||
|
return(new IXR_Error(401, "You are not allowed to " .
|
||||||
|
"post as this user"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "page":
|
||||||
|
if(!current_user_can("edit_others_pages")) {
|
||||||
|
return(new IXR_Error(401, "You are not allowed to " .
|
||||||
|
"create pages as this user"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return(new IXR_Error(401, "Invalid post type."));
|
||||||
|
break;
|
||||||
|
}
|
||||||
$post_author = $content_struct["wp_author_id"];
|
$post_author = $content_struct["wp_author_id"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1079,6 +1097,23 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
// Only set the post_author if one is set.
|
// Only set the post_author if one is set.
|
||||||
if(!empty($content_struct["wp_author_id"])) {
|
if(!empty($content_struct["wp_author_id"])) {
|
||||||
|
switch($post_type) {
|
||||||
|
case "post":
|
||||||
|
if(!current_user_can("edit_others_posts")) {
|
||||||
|
return(new IXR_Error(401, "You are not allowed to " .
|
||||||
|
"change the post author as this user."));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "page":
|
||||||
|
if(!current_user_can("edit_others_pages")) {
|
||||||
|
return(new IXR_Error(401, "You are not allowed to " .
|
||||||
|
"change the page author as this user."));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return(new IXR_Error(401, "Invalid post type."));
|
||||||
|
break;
|
||||||
|
}
|
||||||
$post_author = $content_struct["wp_author_id"];
|
$post_author = $content_struct["wp_author_id"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1199,8 +1234,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
'mt_allow_pings' => $allow_pings,
|
'mt_allow_pings' => $allow_pings,
|
||||||
'wp_slug' => $postdata['post_name'],
|
'wp_slug' => $postdata['post_name'],
|
||||||
'wp_password' => $postdata['post_password'],
|
'wp_password' => $postdata['post_password'],
|
||||||
'wp_author' => $author->display_name,
|
'wp_author_id' => $author->ID,
|
||||||
'wp_author_username' => $author->user_login
|
'wp_author_display_name' => $author->display_name
|
||||||
);
|
);
|
||||||
|
|
||||||
return $resp;
|
return $resp;
|
||||||
|
@ -1266,8 +1301,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
'mt_allow_pings' => $allow_pings,
|
'mt_allow_pings' => $allow_pings,
|
||||||
'wp_slug' => $entry['post_name'],
|
'wp_slug' => $entry['post_name'],
|
||||||
'wp_password' => $entry['post_password'],
|
'wp_password' => $entry['post_password'],
|
||||||
'wp_author' => $author->display_name,
|
'wp_author_id' => $author->ID,
|
||||||
'wp_author_username' => $author->user_login
|
'wp_author_display_name' => $author->display_name
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue