Changeset 15542
- Timestamp:
- 08/27/2010 01:07:21 AM (14 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-form-advanced.php
r15539 r15542 150 150 151 151 if ( post_type_supports($post_type, 'author') ) { 152 $_editable_user_ids = get_editable_user_ids( $current_user->id, true, $post_type ); // TODO: ROLE SYSTEM 153 if ( $post->post_author && !in_array($post->post_author, $_editable_user_ids) ) 154 $_editable_user_ids[] = $post->post_author; 155 156 if ( !empty($_editable_user_ids) || is_super_admin() ) 152 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) 157 153 add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core'); 158 154 } -
trunk/wp-admin/includes/default-list-tables.php
r15527 r15542 669 669 670 670 if ( post_type_supports( $screen->post_type, 'author' ) ) : 671 $authors = get_editable_user_ids( get_current_user_id(), true, $screen->post_type ); // TODO: ROLE SYSTEM672 671 $authors_dropdown = ''; 673 if ( $authors && count( $authors ) > 1 ) : 674 $users_opt = array( 'include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0 ); 672 673 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) : 674 $users_opt = array( 675 'name' => 'post_author', 676 'class'=> 'authors', 677 'multi' => 1, 678 'echo' => 0 679 ); 675 680 if ( $bulk ) 676 681 $users_opt['show_option_none'] = __( '— No Change —' ); … … 679 684 $authors_dropdown .= wp_dropdown_users( $users_opt ); 680 685 $authors_dropdown .= '</label>'; 681 682 686 endif; // authors 683 687 ?> -
trunk/wp-admin/includes/deprecated.php
r15540 r15542 240 240 241 241 /** 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 */ 248 function 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 */ 278 function 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 */ 300 function 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 */ 332 function 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 */ 346 function get_others_pending($user_id) { 347 _deprecated_function( __FUNCTION__, '3.1' ); 348 349 return get_others_unpublished_posts($user_id, 'pending'); 350 } 351 352 /** 242 353 * Register column headers for a particular screen. 243 354 * -
trunk/wp-admin/includes/meta-boxes.php
r15541 r15542 506 506 */ 507 507 function post_author_meta_box($post) { 508 global $user_ID, $_editable_user_ids; 509 510 ?> 511 <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) ); ?> 512 <?php 508 global $user_ID; 509 510 ?> 511 <label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label> 512 <?php 513 wp_dropdown_users( array( 514 'name' => 'post_author_override', 515 'selected' => empty($post->ID) ? $user_ID : $post->post_author 516 ) ); 513 517 } 514 518 -
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.