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

git-svn-id: https://develop.svn.wordpress.org/trunk@3526 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2006-02-14 01:10:51 +00:00
parent 7bb0afb636
commit 143d456a7f
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);
//echo "post ID: {$args[0]}<br/>";
$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);
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
// If the user is the author...
@ -303,6 +307,10 @@ function map_meta_cap($cap, $user_id) {
$author_data = get_userdata($user_id);
//echo "post ID: {$args[0]}<br/>";
$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);
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
// If the user is the author...
@ -345,6 +353,10 @@ function map_meta_cap($cap, $user_id) {
break;
case 'read_post':
$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 ) {
$caps[] = 'read';
@ -358,6 +370,21 @@ function map_meta_cap($cap, $user_id) {
else
$caps[] = 'read_private_posts';
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:
// If no meta caps match, return the original cap.
$caps[] = $cap;