Make WordPress Core

Ticket #2301: 2301.diff

File 2301.diff, 4.0 KB (added by davidhouse, 19 years ago)
  • wp-admin/inline-uploading.php

     
    120120        $current_3 = ' class="current"';
    121121}
    122122
    123 if (! current_user_can('edit_others_posts') )
    124         $and_user = "AND post_author = " . $user_ID;
     123if ( !current_user_can('edit_others_posts') && !current_user_can('edit_others_pages') )
     124        $and_user = "AND post_author = $user_ID";
     125elseif (! current_user_can('edit_others_posts') )
     126        $and_user = "AND (post_author = $user_ID OR post_status != 'static')";
     127elseif (! current_user_can('edit_others_pages') )
     128        $and_user = "AND (post_author = $user_ID OR post_status = 'static')";
    125129
    126130if ( $last )
    127131        $start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment' $and_user $and_post") - $num;
  • wp-admin/admin-functions.php

     
    2222                        $_POST['post_author'] = (int) $_POST['user_ID'];
    2323                }
    2424
    25         if (($_POST['post_author'] != $_POST['user_ID']) && !current_user_can('edit_others_posts'))
    26                 die(__('You cannot post as this user.'));
    27 
    2825        // What to do based on which button they pressed
    2926        if ('' != $_POST['saveasdraft'])
    3027                $_POST['post_status'] = 'draft';
     
    3936
    4037        if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
    4138                $_POST['post_status'] = 'draft';
     39               
     40        if (($_POST['post_author'] != $_POST['user_ID'])) { //its not their post/page
     41                if (($_POST['post_status'] != 'static' && !current_user_can('edit_others_posts')) ||
     42                        ($_POST['post_status'] == 'static' && !current_user_can('edit_others_pages')))
     43                        die(__('You cannot post as this user.'));
     44        }
    4245
    4346        if ('static' == $_POST['post_status'] && !current_user_can('edit_pages'))
    4447                die(__('This user cannot edit pages.'));
     
    142145                        $_POST['post_author'] = (int) $_POST['user_ID'];
    143146                }
    144147
    145         if (($_POST['post_author'] != $_POST['user_ID']) && !current_user_can('edit_others_posts'))
    146                 die(__('You cannot post as this user.'));
    147 
    148148        // What to do based on which button they pressed
    149149        if ('' != $_POST['saveasdraft'])
    150150                $_POST['post_status'] = 'draft';
     
    159159
    160160        if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
    161161                $_POST['post_status'] = 'draft';
     162               
     163        if (($_POST['post_author'] != $_POST['user_ID'])) { //its not their post/page
     164                if (($_POST['post_status'] != 'static' && !current_user_can('edit_others_posts')) ||
     165                        ($_POST['post_status'] == 'static' && !current_user_can('edit_others_pages')))
     166                        die(__('You cannot post as this user.'));
     167        }
    162168
    163169        if ('static' == $_POST['post_status'] && !current_user_can('edit_pages'))
    164170                die(__('This user cannot edit pages.'));
  • wp-admin/admin-db.php

     
    4545       
    4646        $user = new WP_User( $user_id );
    4747       
    48         if ( ! $user->has_cap('edit_others_posts') ) {
     48        if ( ! $user->has_cap('edit_others_posts') && !$user->has_cap('edit_others_pages') ) {
    4949                if ( $user->has_cap('edit_posts') || $exclude_zeros == false )
    5050                        return array($user->id);
    5151                else
  • wp-admin/upgrade-schema.php

     
    274274        $role->add_cap('unfiltered_html');
    275275        $role->add_cap('edit_posts');
    276276        $role->add_cap('edit_others_posts');
     277        $role->add_cap('edit_others_pages');
    277278        $role->add_cap('edit_published_posts');
    278279        $role->add_cap('publish_posts');
    279280        $role->add_cap('edit_pages');
     
    299300        $role->add_cap('unfiltered_html');
    300301        $role->add_cap('edit_posts');
    301302        $role->add_cap('edit_others_posts');
     303        $role->add_cap('edit_others_pages');
    302304        $role->add_cap('edit_published_posts');
    303305        $role->add_cap('publish_posts');
    304306        $role->add_cap('edit_pages');