From 2c7c6cdc8ff65ec1be034a4018bed4f1e8920843 Mon Sep 17 00:00:00 2001 From: michelvaldrighi Date: Fri, 15 Oct 2004 16:20:25 +0000 Subject: [PATCH] added more user_can_* functions git-svn-id: http://svn.automattic.com/wordpress/trunk@1804 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions-post.php | 42 ++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index 48d5fc9ea5..eef65ef1ce 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -320,18 +320,22 @@ function trackback_url_list($tb_list, $post_id) { // query user capabilities +// rather simplistic. shall evolve with future permission system overhaul +// $blog_id and $category_id are there for future usage -/* returns true if a given $user_id can create a new post. - note: optional $blog_id and $category_id 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') { - // rather simplistic. shall evolve with future permission system overhaul $author_data = get_userdata($user_id); 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. - note: optional $blog_id for future usage? */ +/* returns true if $user_id can edit $post_id */ function user_can_edit_post($user_id, $post_id, $blog_id = 1) { $author_data = get_userdata($user_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. - note: optional $blog_id for future usage? */ +/* returns true if $user_id can delete $post_id */ function user_can_delete_post($user_id, $post_id, $blog_id = 1) { // right now if one can edit, one can delete 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) { global $wpdb; extract($commentdata);