Make WordPress Core

Changeset 1804


Ignore:
Timestamp:
10/15/2004 04:20:25 PM (20 years ago)
Author:
michelvaldrighi
Message:

added more user_can_* functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions-post.php

    r1794 r1804  
    321321
    322322// query user capabilities
    323 
    324 /* returns true if a given $user_id can create a new post.
    325    note: optional $blog_id and $category_id for future usage? */
     323// rather simplistic. shall evolve with future permission system overhaul
     324// $blog_id and $category_id are there for future usage
     325
     326/* returns true if $user_id can create a new post */
    326327function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
    327     // rather simplistic. shall evolve with future permission system overhaul
    328328    $author_data = get_userdata($user_id);
    329329    return ($author_data->user_level > 1);
    330330}
    331331
    332 
    333 /* returns true if a given $user_id can edit a given $post_id.
    334    note: optional $blog_id for future usage?                   */
     332/* returns true if $user_id can create a new post */
     333function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
     334    $author_data = get_userdata($user_id);
     335    return ($author_data->user_level >= 1);
     336}
     337
     338/* returns true if $user_id can edit $post_id */
    335339function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
    336340    $author_data = get_userdata($user_id);
     
    346350}
    347351
    348 /* returns true if a given $user_id can delete a given $post_id.
    349    note: optional $blog_id for future usage?                   */
     352/* returns true if $user_id can delete $post_id */
    350353function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
    351354    // right now if one can edit, one can delete
    352355    return user_can_edit_post($user_id, $post_id, $blog_id);
    353356}
     357
     358/* returns true if $user_id can set new posts' dates on $blog_id */
     359function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
     360    $author_data = get_userdata($user_id);
     361    return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
     362}
     363
     364/* returns true if $user_id can edit $post_id's date */
     365function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
     366    $author_data = get_userdata($user_id);
     367    return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
     368}
     369
     370/* returns true if $user_id can edit $post_id's comments */
     371function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
     372    // right now if one can edit a post, one can edit comments made on it
     373    return user_can_edit_post($user_id, $post_id, $blog_id);
     374}
     375
     376/* returns true if $user_id can delete $post_id's comments */
     377function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
     378    // right now if one can edit comments, one can delete comments
     379    return user_can_edit_post_comments($user_id, $post_id, $blog_id);
     380}
     381
    354382
    355383function wp_new_comment($commentdata) {
Note: See TracChangeset for help on using the changeset viewer.