Changeset 7109
- Timestamp:
- 02/29/2008 09:49:49 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit.php
r7098 r7109 82 82 <?php 83 83 $status_links = array(); 84 $num_posts = wp_count_posts('post' );84 $num_posts = wp_count_posts('post', 'readable'); 85 85 foreach ( $post_stati as $status => $label ) { 86 86 $class = ''; … … 89 89 continue; 90 90 91 if ( empty($num_posts->$status) ) 92 continue; 91 93 if ( $status == $_GET['post_status'] ) 92 94 $class = ' class="current"'; -
trunk/wp-admin/includes/post.php
r7103 r7109 514 514 515 515 $post_status_q = ''; 516 if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) ) 516 if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) ) { 517 517 $post_status_q = '&post_status=' . $q['post_status']; 518 $post_status_q .= '&perm=readable'; 519 } 518 520 519 521 if ( 'pending' === $q['post_status'] ) { -
trunk/wp-includes/classes.php
r7103 r7109 4 4 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots'); 5 5 6 var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type' );6 var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm'); 7 7 var $extra_query_vars = array(); 8 8 -
trunk/wp-includes/post.php
r7100 r7109 823 823 * @return array Number of posts for each status 824 824 */ 825 function wp_count_posts( $type = 'post' ) {825 function wp_count_posts( $type = 'post', $perm = '' ) { 826 826 global $wpdb; 827 827 828 $count = $wpdb->get_results( $wpdb->prepare( "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s GROUP BY post_status", $type ), ARRAY_A ); 828 $user = wp_get_current_user(); 829 830 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 831 if ( 'readable' == $perm && is_user_logged_in() ) { 832 if ( !current_user_can("read_private_{$type}s") ) 833 $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))"; 834 } 835 $query .= ' GROUP BY post_status'; 836 $count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 829 837 830 838 $stats = array( ); -
trunk/wp-includes/query.php
r7070 r7109 1214 1214 $q_status = explode(',', $q['post_status']); 1215 1215 $r_status = array(); 1216 $p_status = array(); 1216 1217 if ( in_array( 'draft' , $q_status ) ) 1217 1218 $r_status[] = "post_status = 'draft'"; … … 1223 1224 $r_status[] = "post_status = 'inherit'"; 1224 1225 if ( in_array( 'private', $q_status ) ) 1225 $ r_status[] = "post_status = 'private'";1226 $p_status[] = "post_status = 'private'"; 1226 1227 if ( in_array( 'publish', $q_status ) ) 1227 1228 $r_status[] = "post_status = 'publish'"; 1228 if ( !empty($r_status) ) 1229 $where .= " AND (" . join( ' OR ', $r_status ) . ")"; 1229 1230 if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) { 1231 $r_status = array_merge($r_status, $p_status); 1232 unset($p_status); 1233 } 1234 1235 if ( !empty($r_status) ) { 1236 if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can("edit_others_{$post_type}s") ) 1237 $where .= " AND (post_author = $user_ID " . "AND (" . join( ' OR ', $r_status ) . "))"; 1238 else 1239 $where .= " AND (" . join( ' OR ', $r_status ) . ")"; 1240 } 1241 if ( !empty($p_status) ) { 1242 if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can("read_private_{$post_type}s") ) 1243 $where .= " AND (post_author = $user_ID " . "AND (" . join( ' OR ', $p_status ) . "))"; 1244 else 1245 $where .= " AND (" . join( ' OR ', $p_status ) . ")"; 1246 } 1230 1247 } elseif ( !$this->is_singular ) { 1231 1248 $where .= " AND (post_status = 'publish'";
Note: See TracChangeset
for help on using the changeset viewer.