Deprecated get_editable_user_ids() altogether, along with similar, unused functions. See #14572

git-svn-id: http://svn.automattic.com/wordpress/trunk@15542 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-08-27 01:07:21 +00:00
parent 7a62e9057d
commit 253faa4bbe
5 changed files with 126 additions and 116 deletions

View File

@ -149,11 +149,7 @@ if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object-
add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
if ( post_type_supports($post_type, 'author') ) {
$_editable_user_ids = get_editable_user_ids( $current_user->id, true, $post_type ); // TODO: ROLE SYSTEM
if ( $post->post_author && !in_array($post->post_author, $_editable_user_ids) )
$_editable_user_ids[] = $post->post_author;
if ( !empty($_editable_user_ids) || is_super_admin() )
if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) )
add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
}

View File

@ -668,17 +668,21 @@ class WP_Posts_Table extends WP_List_Table {
<?php endif; // $bulk
if ( post_type_supports( $screen->post_type, 'author' ) ) :
$authors = get_editable_user_ids( get_current_user_id(), true, $screen->post_type ); // TODO: ROLE SYSTEM
$authors_dropdown = '';
if ( $authors && count( $authors ) > 1 ) :
$users_opt = array( 'include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0 );
if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
$users_opt = array(
'name' => 'post_author',
'class'=> 'authors',
'multi' => 1,
'echo' => 0
);
if ( $bulk )
$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
$authors_dropdown = '<label>';
$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
$authors_dropdown .= wp_dropdown_users( $users_opt );
$authors_dropdown .= '</label>';
endif; // authors
?>

View File

@ -238,6 +238,117 @@ function get_editable_authors( $user_id ) {
return apply_filters('get_editable_authors', $authors);
}
/**
* @deprecated 3.1.0
*
* @param int $user_id 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, $post_type = 'post' ) {
_deprecated_function( __FUNCTION__, '3.1' );
global $wpdb;
$user = new WP_User( $user_id );
$post_type_obj = get_post_type_object($post_type);
if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
return array($user->id);
else
return array();
}
if ( !is_multisite() )
$level_key = $wpdb->get_blog_prefix() . 'user_level';
else
$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
if ( $exclude_zeros )
$query .= " AND meta_value != '0'";
return $wpdb->get_col( $query );
}
/**
* @deprecated 3.1.0
*/
function get_nonauthor_user_ids() {
_deprecated_function( __FUNCTION__, '3.1' );
global $wpdb;
if ( !is_multisite() )
$level_key = $wpdb->get_blog_prefix() . 'user_level';
else
$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
}
/**
* Retrieve editable posts from other users.
*
* @deprecated 3.1.0
*
* @param int $user_id User ID to not retrieve posts from.
* @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
* @return array List of posts from others.
*/
function get_others_unpublished_posts($user_id, $type='any') {
_deprecated_function( __FUNCTION__, '3.1' );
global $wpdb;
$editable = get_editable_user_ids( $user_id );
if ( in_array($type, array('draft', 'pending')) )
$type_sql = " post_status = '$type' ";
else
$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
if ( !$editable ) {
$other_unpubs = '';
} else {
$editable = join(',', $editable);
$other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
}
return apply_filters('get_others_drafts', $other_unpubs);
}
/**
* Retrieve drafts from other users.
*
* @deprecated 3.1.0
*
* @param int $user_id User ID.
* @return array List of drafts from other users.
*/
function get_others_drafts($user_id) {
_deprecated_function( __FUNCTION__, '3.1' );
return get_others_unpublished_posts($user_id, 'draft');
}
/**
* Retrieve pending review posts from other users.
*
* @deprecated 3.1.0
*
* @param int $user_id User ID.
* @return array List of posts with pending review post type from other users.
*/
function get_others_pending($user_id) {
_deprecated_function( __FUNCTION__, '3.1' );
return get_others_unpublished_posts($user_id, 'pending');
}
/**
* Register column headers for a particular screen.
*

View File

@ -505,11 +505,15 @@ function post_slug_meta_box($post) {
* @param object $post
*/
function post_author_meta_box($post) {
global $user_ID, $_editable_user_ids;
global $user_ID;
?>
<label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label><?php wp_dropdown_users( array('include' => $_editable_user_ids, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?>
<label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label>
<?php
wp_dropdown_users( array(
'name' => 'post_author_override',
'selected' => empty($post->ID) ? $user_ID : $post->post_author
) );
}

View File

@ -188,36 +188,6 @@ function edit_user( $user_id = 0 ) {
return $user_id;
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since unknown
*
* @param int $user_id User ID.
* @param bool $deprecated Not used.
* @return array
*/
function get_editable_user_ids( $user_id, $deprecated = true, $post_type = 'post' ) {
global $wpdb;
if ( !$deprecated )
_deprecated_argument( __FUNCTION__, '3.1.0' );
$user = new WP_User( $user_id );
$post_type_obj = get_post_type_object($post_type);
if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
return array($user->id);
else
return array();
}
return get_users( array('fields' => 'ids') );
}
/**
* Fetch a filtered list of user roles that the current user is
* allowed to edit.
@ -243,81 +213,6 @@ function get_editable_roles() {
return $editable_roles;
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since unknown
*
* @return unknown
*/
function get_nonauthor_user_ids() {
global $wpdb;
if ( !is_multisite() )
$level_key = $wpdb->get_blog_prefix() . 'user_level';
else
$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
}
/**
* Retrieve editable posts from other users.
*
* @since unknown
*
* @param int $user_id User ID to not retrieve posts from.
* @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
* @return array List of posts from others.
*/
function get_others_unpublished_posts($user_id, $type='any') {
global $wpdb;
$editable = get_editable_user_ids( $user_id );
if ( in_array($type, array('draft', 'pending')) )
$type_sql = " post_status = '$type' ";
else
$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
if ( !$editable ) {
$other_unpubs = '';
} else {
$editable = join(',', $editable);
$other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
}
return apply_filters('get_others_drafts', $other_unpubs);
}
/**
* Retrieve drafts from other users.
*
* @since unknown
*
* @param int $user_id User ID.
* @return array List of drafts from other users.
*/
function get_others_drafts($user_id) {
return get_others_unpublished_posts($user_id, 'draft');
}
/**
* Retrieve pending review posts from other users.
*
* @since unknown
*
* @param int $user_id User ID.
* @return array List of posts with pending review post type from other users.
*/
function get_others_pending($user_id) {
return get_others_unpublished_posts($user_id, 'pending');
}
/**
* Retrieve user data and filter it.
*