WordPress.org

Make WordPress Core

Changeset 3526


Ignore:
Timestamp:
02/14/2006 01:10:51 AM (12 years ago)
Author:
ryan
Message:

If requesting post caps for a page, redirect to equivalent page caps.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/capabilities.php

    r3517 r3526  
    258258        //echo "post ID: {$args[0]}<br/>";
    259259        $post = get_post($args[0]);
     260        if ( 'page' == $post->post_type ) {
     261            $args = array_merge(array('delete_page', $user_id), $args);
     262            return call_user_func_array('map_meta_cap', $args);
     263        }
    260264        $post_author_data = get_userdata($post->post_author);
    261265        //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
     
    304308        //echo "post ID: {$args[0]}<br/>";
    305309        $post = get_post($args[0]);
     310        if ( 'page' == $post->post_type ) {
     311            $args = array_merge(array('edit_page', $user_id), $args);
     312            return call_user_func_array('map_meta_cap', $args);
     313        }
    306314        $post_author_data = get_userdata($post->post_author);
    307315        //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
     
    346354    case 'read_post':
    347355        $post = get_post($args[0]);
     356        if ( 'page' == $post->post_type ) {
     357            $args = array_merge(array('read_page', $user_id), $args);
     358            return call_user_func_array('map_meta_cap', $args);
     359        }
    348360
    349361        if ( 'private' != $post->post_status ) {
     
    359371            $caps[] = 'read_private_posts';
    360372        break;
     373    case 'read_page':
     374        $page = get_page($args[0]);
     375
     376        if ( 'private' != $page->post_status ) {
     377            $caps[] = 'read';
     378            break;
     379        }
     380
     381        $author_data = get_userdata($user_id);
     382        $page_author_data = get_userdata($post->post_author);
     383        if ($user_id == $page_author_data->ID)
     384            $caps[] = 'read';
     385        else
     386            $caps[] = 'read_private_pages';
     387        break;
    361388    default:
    362389        // If no meta caps match, return the original cap.
Note: See TracChangeset for help on using the changeset viewer.