Handle both post and page caps in get_editable_user_id(). Props DD32. fixes #8208

git-svn-id: https://develop.svn.wordpress.org/trunk@9683 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-11-14 17:13:08 +00:00
parent 84f08ca047
commit 455462be39
2 changed files with 5 additions and 5 deletions

View File

@ -356,7 +356,7 @@ function page_slug_meta_box($post){
}
add_meta_box('pageslugdiv', __('Page Slug'), 'page_slug_meta_box', 'page', 'normal', 'core');
$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
$authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM
if ( $post->post_author && !in_array($post->post_author, $authors) )
$authors[] = $post->post_author;
if ( $authors && count( $authors ) > 1 ) {
@ -369,7 +369,7 @@ if ( $authors && count( $authors ) > 1 ) {
*/
function page_author_meta_box($post){
global $current_user, $user_ID;
$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
$authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM
if ( $post->post_author && !in_array($post->post_author, $authors) )
$authors[] = $post->post_author;
?>

View File

@ -220,13 +220,13 @@ function get_editable_authors( $user_id ) {
* @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros.
* @return unknown
*/
function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
global $wpdb;
$user = new WP_User( $user_id );
if ( ! $user->has_cap('edit_others_posts') ) {
if ( $user->has_cap('edit_posts') || $exclude_zeros == false )
if ( ! $user->has_cap("edit_others_{$post_type}s") ) {
if ( $user->has_cap("edit_{$post_type}s") || $exclude_zeros == false )
return array($user->id);
else
return false;