More XMLRPC updates from Joseph Scott.

git-svn-id: https://develop.svn.wordpress.org/trunk@4862 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2007-02-02 07:43:59 +00:00
parent 8143eac144
commit 10550fe0cd
2 changed files with 42 additions and 7 deletions

View File

@@ -227,7 +227,8 @@ class wp_xmlrpc_server extends IXR_Server {
"wp_page_parent_id" => $page->post_parent,
"wp_page_parent_title" => $parent_title,
"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);
@@ -947,6 +948,23 @@ class wp_xmlrpc_server extends IXR_Server {
// If an author id was provided then use it instead.
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"];
}
@@ -1079,6 +1097,23 @@ class wp_xmlrpc_server extends IXR_Server {
// Only set the post_author if one is set.
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"];
}
@@ -1199,8 +1234,8 @@ class wp_xmlrpc_server extends IXR_Server {
'mt_allow_pings' => $allow_pings,
'wp_slug' => $postdata['post_name'],
'wp_password' => $postdata['post_password'],
'wp_author' => $author->display_name,
'wp_author_username' => $author->user_login
'wp_author_id' => $author->ID,
'wp_author_display_name' => $author->display_name
);
return $resp;
@@ -1266,8 +1301,8 @@ class wp_xmlrpc_server extends IXR_Server {
'mt_allow_pings' => $allow_pings,
'wp_slug' => $entry['post_name'],
'wp_password' => $entry['post_password'],
'wp_author' => $author->display_name,
'wp_author_username' => $author->user_login
'wp_author_id' => $author->ID,
'wp_author_display_name' => $author->display_name
);
}