Changeset 15542 for trunk/wp-admin/includes/user.php
- Timestamp:
- 08/27/2010 01:07:21 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/user.php
r15540 r15542 190 190 191 191 /** 192 * {@internal Missing Short Description}}193 *194 * {@internal Missing Long Description}}195 *196 * @since unknown197 *198 * @param int $user_id User ID.199 * @param bool $deprecated Not used.200 * @return array201 */202 function get_editable_user_ids( $user_id, $deprecated = true, $post_type = 'post' ) {203 global $wpdb;204 205 if ( !$deprecated )206 _deprecated_argument( __FUNCTION__, '3.1.0' );207 208 $user = new WP_User( $user_id );209 $post_type_obj = get_post_type_object($post_type);210 211 if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {212 if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )213 return array($user->id);214 else215 return array();216 }217 218 return get_users( array('fields' => 'ids') );219 }220 221 /**222 192 * Fetch a filtered list of user roles that the current user is 223 193 * allowed to edit. … … 242 212 243 213 return $editable_roles; 244 }245 246 /**247 * {@internal Missing Short Description}}248 *249 * {@internal Missing Long Description}}250 *251 * @since unknown252 *253 * @return unknown254 */255 function get_nonauthor_user_ids() {256 global $wpdb;257 258 if ( !is_multisite() )259 $level_key = $wpdb->get_blog_prefix() . 'user_level';260 else261 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels262 263 return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );264 }265 266 /**267 * Retrieve editable posts from other users.268 *269 * @since unknown270 *271 * @param int $user_id User ID to not retrieve posts from.272 * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.273 * @return array List of posts from others.274 */275 function get_others_unpublished_posts($user_id, $type='any') {276 global $wpdb;277 278 $editable = get_editable_user_ids( $user_id );279 280 if ( in_array($type, array('draft', 'pending')) )281 $type_sql = " post_status = '$type' ";282 else283 $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";284 285 $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';286 287 if ( !$editable ) {288 $other_unpubs = '';289 } else {290 $editable = join(',', $editable);291 $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) );292 }293 294 return apply_filters('get_others_drafts', $other_unpubs);295 }296 297 /**298 * Retrieve drafts from other users.299 *300 * @since unknown301 *302 * @param int $user_id User ID.303 * @return array List of drafts from other users.304 */305 function get_others_drafts($user_id) {306 return get_others_unpublished_posts($user_id, 'draft');307 }308 309 /**310 * Retrieve pending review posts from other users.311 *312 * @since unknown313 *314 * @param int $user_id User ID.315 * @return array List of posts with pending review post type from other users.316 */317 function get_others_pending($user_id) {318 return get_others_unpublished_posts($user_id, 'pending');319 214 } 320 215
Note: See TracChangeset
for help on using the changeset viewer.