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

git-svn-id: http://svn.automattic.com/wordpress/trunk@9683 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-11-14 17:13:08 +00:00
parent 73148914c2
commit ab2ac7f427
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;