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

git-svn-id: http://svn.automattic.com/wordpress/trunk@3526 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-02-14 01:10:51 +00:00
parent f3faa6c75d
commit 535d41ea76
1 changed files with 27 additions and 0 deletions

View File

@ -257,6 +257,10 @@ function map_meta_cap($cap, $user_id) {
$author_data = get_userdata($user_id); $author_data = get_userdata($user_id);
//echo "post ID: {$args[0]}<br/>"; //echo "post ID: {$args[0]}<br/>";
$post = get_post($args[0]); $post = get_post($args[0]);
if ( 'page' == $post->post_type ) {
$args = array_merge(array('delete_page', $user_id), $args);
return call_user_func_array('map_meta_cap', $args);
}
$post_author_data = get_userdata($post->post_author); $post_author_data = get_userdata($post->post_author);
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>"; //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
// If the user is the author... // If the user is the author...
@ -303,6 +307,10 @@ function map_meta_cap($cap, $user_id) {
$author_data = get_userdata($user_id); $author_data = get_userdata($user_id);
//echo "post ID: {$args[0]}<br/>"; //echo "post ID: {$args[0]}<br/>";
$post = get_post($args[0]); $post = get_post($args[0]);
if ( 'page' == $post->post_type ) {
$args = array_merge(array('edit_page', $user_id), $args);
return call_user_func_array('map_meta_cap', $args);
}
$post_author_data = get_userdata($post->post_author); $post_author_data = get_userdata($post->post_author);
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>"; //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
// If the user is the author... // If the user is the author...
@ -345,6 +353,10 @@ function map_meta_cap($cap, $user_id) {
break; break;
case 'read_post': case 'read_post':
$post = get_post($args[0]); $post = get_post($args[0]);
if ( 'page' == $post->post_type ) {
$args = array_merge(array('read_page', $user_id), $args);
return call_user_func_array('map_meta_cap', $args);
}
if ( 'private' != $post->post_status ) { if ( 'private' != $post->post_status ) {
$caps[] = 'read'; $caps[] = 'read';
@ -358,6 +370,21 @@ function map_meta_cap($cap, $user_id) {
else else
$caps[] = 'read_private_posts'; $caps[] = 'read_private_posts';
break; break;
case 'read_page':
$page = get_page($args[0]);
if ( 'private' != $page->post_status ) {
$caps[] = 'read';
break;
}
$author_data = get_userdata($user_id);
$page_author_data = get_userdata($post->post_author);
if ($user_id == $page_author_data->ID)
$caps[] = 'read';
else
$caps[] = 'read_private_pages';
break;
default: default:
// If no meta caps match, return the original cap. // If no meta caps match, return the original cap.
$caps[] = $cap; $caps[] = $cap;