WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/27/2010 01:07:21 AM (10 years ago)
Author:
scribu
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/deprecated.php

    r15540 r15542  
    240240
    241241/**
     242 * @deprecated 3.1.0
     243 *
     244 * @param int $user_id User ID.
     245 * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros.
     246 * @return unknown
     247 */
     248function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
     249    _deprecated_function( __FUNCTION__, '3.1' );
     250
     251    global $wpdb;
     252
     253    $user = new WP_User( $user_id );
     254    $post_type_obj = get_post_type_object($post_type);
     255
     256    if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
     257        if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
     258            return array($user->id);
     259        else
     260            return array();
     261    }
     262
     263    if ( !is_multisite() )
     264        $level_key = $wpdb->get_blog_prefix() . 'user_level';
     265    else
     266        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
     267
     268    $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
     269    if ( $exclude_zeros )
     270        $query .= " AND meta_value != '0'";
     271
     272    return $wpdb->get_col( $query );
     273}
     274
     275/**
     276 * @deprecated 3.1.0
     277 */
     278function get_nonauthor_user_ids() {
     279    _deprecated_function( __FUNCTION__, '3.1' );
     280
     281    global $wpdb;
     282
     283    if ( !is_multisite() )
     284        $level_key = $wpdb->get_blog_prefix() . 'user_level';
     285    else
     286        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
     287
     288    return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
     289}
     290
     291/**
     292 * Retrieve editable posts from other users.
     293 *
     294 * @deprecated 3.1.0
     295 *
     296 * @param int $user_id User ID to not retrieve posts from.
     297 * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
     298 * @return array List of posts from others.
     299 */
     300function get_others_unpublished_posts($user_id, $type='any') {
     301    _deprecated_function( __FUNCTION__, '3.1' );
     302
     303    global $wpdb;
     304
     305    $editable = get_editable_user_ids( $user_id );
     306
     307    if ( in_array($type, array('draft', 'pending')) )
     308        $type_sql = " post_status = '$type' ";
     309    else
     310        $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
     311
     312    $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
     313
     314    if ( !$editable ) {
     315        $other_unpubs = '';
     316    } else {
     317        $editable = join(',', $editable);
     318        $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) );
     319    }
     320
     321    return apply_filters('get_others_drafts', $other_unpubs);
     322}
     323
     324/**
     325 * Retrieve drafts from other users.
     326 *
     327 * @deprecated 3.1.0
     328 *
     329 * @param int $user_id User ID.
     330 * @return array List of drafts from other users.
     331 */
     332function get_others_drafts($user_id) {
     333    _deprecated_function( __FUNCTION__, '3.1' );
     334
     335    return get_others_unpublished_posts($user_id, 'draft');
     336}
     337
     338/**
     339 * Retrieve pending review posts from other users.
     340 *
     341 * @deprecated 3.1.0
     342 *
     343 * @param int $user_id User ID.
     344 * @return array List of posts with pending review post type from other users.
     345 */
     346function get_others_pending($user_id) {
     347    _deprecated_function( __FUNCTION__, '3.1' );
     348
     349    return get_others_unpublished_posts($user_id, 'pending');
     350}
     351
     352/**
    242353 * Register column headers for a particular screen.
    243354 *
Note: See TracChangeset for help on using the changeset viewer.