mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-01 08:37:55 +02:00
added more user_can_* functions
git-svn-id: http://svn.automattic.com/wordpress/trunk@1804 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
eb08740fc0
commit
2c7c6cdc8f
@ -320,18 +320,22 @@ function trackback_url_list($tb_list, $post_id) {
|
|||||||
|
|
||||||
|
|
||||||
// query user capabilities
|
// query user capabilities
|
||||||
|
|
||||||
/* returns true if a given $user_id can create a new post.
|
|
||||||
note: optional $blog_id and $category_id for future usage? */
|
|
||||||
function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
|
|
||||||
// rather simplistic. shall evolve with future permission system overhaul
|
// rather simplistic. shall evolve with future permission system overhaul
|
||||||
|
// $blog_id and $category_id are there for future usage
|
||||||
|
|
||||||
|
/* returns true if $user_id can create a new post */
|
||||||
|
function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
|
||||||
$author_data = get_userdata($user_id);
|
$author_data = get_userdata($user_id);
|
||||||
return ($author_data->user_level > 1);
|
return ($author_data->user_level > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* returns true if $user_id can create a new post */
|
||||||
|
function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
|
||||||
|
$author_data = get_userdata($user_id);
|
||||||
|
return ($author_data->user_level >= 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* returns true if a given $user_id can edit a given $post_id.
|
/* returns true if $user_id can edit $post_id */
|
||||||
note: optional $blog_id for future usage? */
|
|
||||||
function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
|
function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
|
||||||
$author_data = get_userdata($user_id);
|
$author_data = get_userdata($user_id);
|
||||||
$post_data = get_postdata($post_id);
|
$post_data = get_postdata($post_id);
|
||||||
@ -345,13 +349,37 @@ function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns true if a given $user_id can delete a given $post_id.
|
/* returns true if $user_id can delete $post_id */
|
||||||
note: optional $blog_id for future usage? */
|
|
||||||
function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
|
function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
|
||||||
// right now if one can edit, one can delete
|
// right now if one can edit, one can delete
|
||||||
return user_can_edit_post($user_id, $post_id, $blog_id);
|
return user_can_edit_post($user_id, $post_id, $blog_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* returns true if $user_id can set new posts' dates on $blog_id */
|
||||||
|
function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
|
||||||
|
$author_data = get_userdata($user_id);
|
||||||
|
return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returns true if $user_id can edit $post_id's date */
|
||||||
|
function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
|
||||||
|
$author_data = get_userdata($user_id);
|
||||||
|
return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returns true if $user_id can edit $post_id's comments */
|
||||||
|
function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
|
||||||
|
// right now if one can edit a post, one can edit comments made on it
|
||||||
|
return user_can_edit_post($user_id, $post_id, $blog_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returns true if $user_id can delete $post_id's comments */
|
||||||
|
function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
|
||||||
|
// right now if one can edit comments, one can delete comments
|
||||||
|
return user_can_edit_post_comments($user_id, $post_id, $blog_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function wp_new_comment($commentdata) {
|
function wp_new_comment($commentdata) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
extract($commentdata);
|
extract($commentdata);
|
||||||
|
Loading…
Reference in New Issue
Block a user