Don't treat a numeric user name as an id.
git-svn-id: http://svn.automattic.com/wordpress/trunk@3310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5a56fc2414
commit
d567007a42
|
@ -114,18 +114,22 @@ class WP_User {
|
||||||
var $roles = array();
|
var $roles = array();
|
||||||
var $allcaps = array();
|
var $allcaps = array();
|
||||||
|
|
||||||
function WP_User($id) {
|
function WP_User($id, $name = '') {
|
||||||
global $wp_roles, $table_prefix;
|
global $wp_roles, $table_prefix;
|
||||||
|
|
||||||
if ( empty($id) )
|
if ( empty($id) && empty($name) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( is_numeric($id) ) {
|
if ( ! is_numeric($id) ) {
|
||||||
$this->data = get_userdata($id);
|
$name = $id;
|
||||||
} else {
|
$id = 0;
|
||||||
$this->data = get_userdatabylogin($id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! empty($id) )
|
||||||
|
$this->data = get_userdata($id);
|
||||||
|
else
|
||||||
|
$this->data = get_userdatabylogin($name);
|
||||||
|
|
||||||
if ( empty($this->data->ID) )
|
if ( empty($this->data->ID) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ default:
|
||||||
do_action('wp_authenticate', array(&$user_login, &$user_pass));
|
do_action('wp_authenticate', array(&$user_login, &$user_pass));
|
||||||
|
|
||||||
if ( $_POST ) {
|
if ( $_POST ) {
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
|
|
||||||
// If the user can't edit posts, send them to their profile.
|
// If the user can't edit posts, send them to their profile.
|
||||||
if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) )
|
if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) )
|
||||||
|
|
22
xmlrpc.php
22
xmlrpc.php
|
@ -179,7 +179,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
$is_admin = $user->has_cap('level_8');
|
$is_admin = $user->has_cap('level_8');
|
||||||
|
|
||||||
$struct = array(
|
$struct = array(
|
||||||
|
@ -317,7 +317,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
if ( !$user->has_cap('edit_themes') ) {
|
if ( !$user->has_cap('edit_themes') ) {
|
||||||
return new IXR_Error(401, 'Sorry, this user can not edit the template.');
|
return new IXR_Error(401, 'Sorry, this user can not edit the template.');
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
if ( !$user->has_cap('edit_themes') ) {
|
if ( !$user->has_cap('edit_themes') ) {
|
||||||
return new IXR_Error(401, 'Sorry, this user can not edit the template.');
|
return new IXR_Error(401, 'Sorry, this user can not edit the template.');
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
||||||
|
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
if ( !$user->has_cap($cap) )
|
if ( !$user->has_cap($cap) )
|
||||||
return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
|
return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
$this->escape($actual_post);
|
$this->escape($actual_post);
|
||||||
|
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
if ( !$user->has_cap('edit_post', $post_ID) )
|
if ( !$user->has_cap('edit_post', $post_ID) )
|
||||||
return new IXR_Error(401, 'Sorry, you do not have the right to edit this post.');
|
return new IXR_Error(401, 'Sorry, you do not have the right to edit this post.');
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return new IXR_Error(404, 'Sorry, no such post.');
|
return new IXR_Error(404, 'Sorry, no such post.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
if ( !$user->has_cap('edit_post', $post_ID) )
|
if ( !$user->has_cap('edit_post', $post_ID) )
|
||||||
return new IXR_Error(401, 'Sorry, you do not have the right to delete this post.');
|
return new IXR_Error(401, 'Sorry, you do not have the right to delete this post.');
|
||||||
|
|
||||||
|
@ -525,7 +525,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
if ( !$user->has_cap('publish_posts') )
|
if ( !$user->has_cap('publish_posts') )
|
||||||
return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
|
return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
|
||||||
|
|
||||||
|
@ -605,7 +605,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
if ( !$user->has_cap('edit_post', $post_ID) )
|
if ( !$user->has_cap('edit_post', $post_ID) )
|
||||||
return new IXR_Error(401, 'Sorry, you can not edit this post.');
|
return new IXR_Error(401, 'Sorry, you can not edit this post.');
|
||||||
|
|
||||||
|
@ -844,7 +844,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
if ( !$this->login_pass_ok($user_login, $user_pass) )
|
if ( !$this->login_pass_ok($user_login, $user_pass) )
|
||||||
return $this->error;
|
return $this->error;
|
||||||
|
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
|
|
||||||
if ( !$user->has_cap('upload_files') ) {
|
if ( !$user->has_cap('upload_files') ) {
|
||||||
logIO('O', '(MW) User does not have upload_files capability');
|
logIO('O', '(MW) User does not have upload_files capability');
|
||||||
|
@ -984,7 +984,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
if ( !$user->has_cap('edit_post', $post_ID) )
|
if ( !$user->has_cap('edit_post', $post_ID) )
|
||||||
return new IXR_Error(401, 'Sorry, you can not edit this post.');
|
return new IXR_Error(401, 'Sorry, you can not edit this post.');
|
||||||
|
|
||||||
|
@ -1066,7 +1066,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new WP_User($user_login);
|
$user = new WP_User(0, $user_login);
|
||||||
if ( !$user->has_cap('edit_post', $post_ID) )
|
if ( !$user->has_cap('edit_post', $post_ID) )
|
||||||
return new IXR_Error(401, 'Sorry, you can not edit this post.');
|
return new IXR_Error(401, 'Sorry, you can not edit this post.');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue