Changeset 2900
- Timestamp:
- 09/21/2005 05:13:49 AM (19 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-db.php
r2702 r2900 13 13 $user = get_userdata( $user_id ); 14 14 $level_key = $wpdb->prefix . 'user_level'; 15 if ( 1 < $user->user_level ) { 16 15 16 $editable = get_editable_user_ids( $user_id ); 17 17 18 if( !$editable ) { 19 $other_drafts = ''; 20 } else { 21 $editable = join(',', $editable); 22 $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' "); 23 } 18 if( !$editable ) { 19 $other_drafts = ''; 24 20 } else { 25 $other_drafts = false; 21 $editable = join(',', $editable); 22 $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' "); 26 23 } 24 27 25 return apply_filters('get_others_drafts', $other_drafts); 28 26 } … … 30 28 function get_editable_authors( $user_id ) { 31 29 global $wpdb; 32 $user = get_userdata( $user_id );33 $level_key = $wpdb->prefix . 'user_level';34 35 if ( 7 > $user->user_level ) // TODO: ROLE SYSTEM36 return false;37 30 38 31 $editable = get_editable_user_ids( $user_id ); 39 32 40 if( !$editable ) 41 42 else {33 if( !$editable ) { 34 return false; 35 } else { 43 36 $editable = join(',', $editable); 44 37 $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable)" ); … … 50 43 function get_editable_user_ids( $user_id, $exclude_zeros = true ) { 51 44 global $wpdb; 52 $user = get_userdata( $user_id ); 45 46 $user = new WP_User( $user_id ); 47 48 if ( ! $user->has_cap('edit_others_posts') ) { 49 echo "no cap<br/>"; 50 if ( $user->has_cap('edit_posts') || $exclude_zeros == false ) 51 return array($user->id); 52 else 53 return false; 54 } 55 53 56 $level_key = $wpdb->prefix . 'user_level'; 54 57 55 $query = "SELECT *FROM $wpdb->usermeta WHERE meta_key = '$level_key'";58 $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key'"; 56 59 if ( $exclude_zeros ) 57 60 $query .= " AND meta_value != '0'"; 58 $possible = $wpdb->get_results( $query ); 59 60 if ( !$possible ) 61 return false; 62 63 $user_ids = array(); 64 foreach ( $possible as $mark ) 65 if ( intval($mark->meta_value) <= $user->user_level ) 66 $user_ids[] = $mark->user_id; 67 if ( empty( $user_ids ) ) 68 return false; 69 return $user_ids; 61 62 return $wpdb->get_col( $query ); 70 63 } 71 64 -
trunk/wp-admin/edit-form-advanced.php
r2804 r2900 103 103 <?php endif; ?> 104 104 105 <?php if ( $authors = get_editable_authors( $current_user-> ID) ) : // TODO: ROLE SYSTEM ?>105 <?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?> 106 106 <fieldset id="authordiv" class="dbx-box"> 107 107 <h3 class="dbx-handle"><?php _e('Post author'); ?>:</h3> -
trunk/wp-admin/edit-page-form.php
r2826 r2900 84 84 </fieldset> 85 85 86 <?php if ( $authors = get_editable_authors( $current_user-> ID) ) : // TODO: ROLE SYSTEM ?>86 <?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?> 87 87 <fieldset id="authordiv" class="dbx-box"> 88 88 <h3 class="dbx-handle"><?php _e('Post author'); ?>:</h3>
Note: See TracChangeset
for help on using the changeset viewer.