diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 6d19ce90ed..a4a24e7917 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -101,9 +101,11 @@ addLoadEvent(focusit);

-
- +
+ + +
@@ -167,6 +169,8 @@ if ('publish' != $post->post_status || 0 == $post_ID) { ?> + + diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 9bcaeec59e..6d03527514 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -11,10 +11,13 @@ $_GET['cat'] = (int) $_GET['cat']; $post_stati = array( // array( adj, noun ) 'draft' => array(__('Draft'), _c('Drafts|manage posts header')), 'future' => array(__('Scheduled'), __('Scheduled posts')), + 'pending' => array(__('Pending Review'), __('Pending posts')), 'private' => array(__('Private'), __('Private posts')), 'publish' => array(__('Published'), __('Published posts')) ); +$avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'"); + $post_status_q = ''; $post_status_label = _c('Posts|manage posts header'); if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { @@ -30,14 +33,16 @@ if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($ wp("what_to_show=posts$post_status_q&posts_per_page=15"); // define the columns to display, the syntax is 'internal name' => 'display name' -$posts_columns = array( - 'id' => '
' . __('ID') . '
', - 'date' => __('When'), - 'title' => __('Title'), - 'categories' => __('Categories'), - 'comments' => '
' . __('Comments') . '
', - 'author' => __('Author') -); +$posts_columns = array(); +$posts_columns['id'] = '
' . __('ID') . '
'; +if ( !in_array($_GET['post_status'], array('pending', 'draft')) ) + $posts_columns['date'] = __('When'); +$posts_columns['title'] = __('Title'); +$posts_columns['categories'] = __('Categories'); +if ( 'publish' == $_GET['post_status'] ) + $posts_columns['comments'] = '
' . __('Comments') . '
'; +$posts_columns['author'] = __('Author'); + $posts_columns = apply_filters('manage_posts_columns', $posts_columns); // you can not edit these at the moment @@ -57,9 +62,14 @@ if ( is_single() ) { $h2_noun = $post_status_label; // Use $_GET instead of is_ since they can override each other $h2_author = ''; - if ( isset($_GET['author']) && $_GET['author'] ) { - $author_user = get_userdata( get_query_var( 'author' ) ); - $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name )); + $_GET['author'] = (int) $_GET['author']; + if ( $_GET['author'] != 0 ) { + if ( $_GET['author'] == '-' . $user_ID ) { // author exclusion + $h2_author = ' ' . __('by other authors'); + } else { + $author_user = get_userdata( get_query_var( 'author' ) ); + $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name )); + } } $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( get_search_query() ) ) : ''; $h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in “%s”'), single_cat_title('', false) ) : ''; @@ -73,10 +83,10 @@ if ( is_single() ) { -
+
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 588be7fb08..46ed65fb02 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -64,10 +64,10 @@ function edit_post() { if ( 'page' == $_POST['post_type'] ) { if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' )) - $_POST['post_status'] = 'draft'; + $_POST['post_status'] = 'pending'; } else { if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' )) - $_POST['post_status'] = 'draft'; + $_POST['post_status'] = 'pending'; } if (!isset( $_POST['comment_status'] )) @@ -268,10 +268,10 @@ function wp_write_post() { if ( 'page' == $_POST['post_type'] ) { if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) ) - $_POST['post_status'] = 'draft'; + $_POST['post_status'] = 'pending'; } else { if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) ) - $_POST['post_status'] = 'draft'; + $_POST['post_status'] = 'pending'; } if (!isset( $_POST['comment_status'] )) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 90beddd1d0..01ff50e2d5 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -106,7 +106,7 @@ CREATE TABLE $wpdb->posts ( post_title text NOT NULL, post_category int(4) NOT NULL default '0', post_excerpt text NOT NULL, - post_status enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL default 'publish', + post_status enum('publish','draft','private','static','object','attachment','inherit','future', 'pending') NOT NULL default 'publish', comment_status enum('open','closed','registered_only') NOT NULL default 'open', ping_status enum('open','closed') NOT NULL default 'open', post_password varchar(20) NOT NULL default '', diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index d0efb3af60..6956fb494e 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -420,7 +420,7 @@ function touch_time( $edit = 1, $for_post = 1 ) { global $wp_locale, $post, $comment; if ( $for_post ) - $edit = ( ('draft' == $post->post_status ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true; + $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true; echo '
'; @@ -592,4 +592,4 @@ function wp_remember_old_slug() { echo ''; } -?> +?> \ No newline at end of file diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index b8996bf59c..d6ad907e29 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -181,21 +181,34 @@ function get_nonauthor_user_ids() { return $wpdb->get_col( $query ); } -function get_others_drafts( $user_id ) { +function get_others_unpublished_posts($user_id, $type='any') { global $wpdb; $user = get_userdata( $user_id ); $level_key = $wpdb->prefix . 'user_level'; $editable = get_editable_user_ids( $user_id ); + if ( in_array($type, array('draft', 'pending')) ) + $type_sql = " post_status = '$type' "; + else + $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) "; + if( !$editable ) { - $other_drafts = ''; + $other_unpubs = ''; } else { $editable = join(',', $editable); - $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' "); + $other_unpubs = $wpdb->get_results("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != '$user_id' "); } - return apply_filters('get_others_drafts', $other_drafts); + return apply_filters('get_others_drafts', $other_unpubs); +} + +function get_others_drafts($user_id) { + return get_others_unpublished_posts($user_id, 'draft'); +} + +function get_others_pending($user_id) { + return get_others_unpublished_posts($user_id, 'pending'); } function get_user_to_edit( $user_id ) { diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php index 6d92fe782b..9779a9ecb0 100644 --- a/wp-admin/post-new.php +++ b/wp-admin/post-new.php @@ -24,31 +24,83 @@ if ( isset($_GET['posted']) && $_GET['posted'] ) : ?>

+ -if ( $drafts = get_users_drafts( $user_ID ) ) { ?> -
-

15 ) $num_drafts = 15; - for ( $i = 0; $i < $num_drafts; $i++ ) { - $draft = $drafts[$i]; - if ( 0 != $i ) - echo ', '; - if ( empty($draft->post_title) ) - $draft->post_title = sprintf(__('Post # %s'), $draft->ID); - echo "$draft->post_title"; +$my_drafts = get_users_drafts($user_ID); +$pending = get_others_pending($user_ID); +$others_drafts = get_others_drafts($user_ID); + +if ( !empty($my_drafts) || !empty($pending) || !empty($others_drafts) ) { + echo '

'; + + if ( $my_drafts ) { + echo '

' . __( 'Your Drafts:' ) . ' '; + if ( count($my_drafts) < 3 ) { + $i = 0; + foreach ( $my_drafts as $post ) { + if ( $i++ != 0 ) + echo ', '; + echo ''; + the_title(); + echo ''; + } + echo '.

'; + } else { + printf( + __( 'You have %d drafts.' ) . '

', + 'edit.php?post_status=draft&author=' . $user_ID, count($my_drafts) + ); + } } - if ( 15 < count($drafts) ) { ?> - , - -.

-
-' . __( 'Pending Review:' ) . ' '; + if ( count($pending) < 3 ) { + $i = 0; + foreach ( $pending as $post ) { + if ( $i++ != 0 ) + echo ', '; + echo ''; + the_title(); + echo ''; + } + echo '.

'; + } else { + printf( + __( 'There are %d drafts pending review.' ) . '

', + 'edit.php?post_status=pending', count($pending) + ); + } + } + if ( $others_drafts ) { + echo '

' . __( 'Others’ Drafts:' ) . ' '; + if ( count($others_drafts) < 3 ) { + $i = 0; + foreach ( $others_drafts as $post ) { + if ( $i++ != 0 ) + echo ', '; + echo ''; + the_title(); + echo ''; + } + echo '.

'; + } else { + printf( + __( 'There are %d in-progress drafts by other authors.' ) . '

', + 'edit.php?post_status=pending&author=-' . $user_ID, count($others_drafts) + ); + } + } + + echo "
\n"; +} +?> + + +comment_status) ) { } elseif ( 'closed' == $status->comment_status ) { do_action('comment_closed', $comment_post_ID); wp_die( __('Sorry, comments are closed for this item.') ); -} elseif ( 'draft' == $status->post_status ) { +} elseif ( in_array($status->post_status, array('draft', 'pending') ) ) { do_action('comment_on_draft', $comment_post_ID); exit; } diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 2b2ff5f8f4..d96be9c072 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -162,7 +162,7 @@ function wp_link_pages($args = '') { if ( 1 == $i ) { $output .= ''; } else { - if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) + if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) $output .= ''; else $output .= ''; @@ -181,7 +181,7 @@ function wp_link_pages($args = '') { if ( 1 == $i ) { $output .= '' . $previouspagelink . ''; } else { - if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) + if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) $output .= '' . $previouspagelink . ''; else $output .= '' . $previouspagelink . ''; @@ -192,7 +192,7 @@ function wp_link_pages($args = '') { if ( 1 == $i ) { $output .= '' . $nextpagelink . ''; } else { - if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) + if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) $output .= '' . $nextpagelink . ''; else $output .= '' . $nextpagelink . ''; diff --git a/wp-includes/post.php b/wp-includes/post.php index 540e5fc13c..0d1f41017d 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -553,12 +553,12 @@ function wp_insert_post($postarr = array()) { // If the post date is empty (due to having been new or a draft) and status is not 'draft', set date to now if (empty($post_date)) { - if ( 'draft' != $post_status ) + if ( !in_array($post_status, array('draft', 'pending')) ) $post_date = current_time('mysql'); } if (empty($post_date_gmt)) { - if ( 'draft' != $post_status ) + if ( !in_array($post_status, array('draft', 'pending')) ) $post_date_gmt = get_gmt_from_date($post_date); } @@ -738,7 +738,7 @@ function wp_update_post($postarr = array()) { $post_cats = $post['post_category']; // Drafts shouldn't be assigned a date unless explicitly done so by the user - if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) && + if ( in_array($post['post_status'], array('draft', 'pending')) && empty($postarr['edit_date']) && empty($postarr['post_date']) && ('0000-00-00 00:00:00' == $post['post_date']) ) $clear_date = true; else diff --git a/wp-includes/query.php b/wp-includes/query.php index f17911e953..2c0c2808de 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1006,6 +1006,8 @@ class WP_Query { $r_status = array(); if ( in_array( 'draft' , $q_status ) ) $r_status[] = "post_status = 'draft'"; + if ( in_array( 'pending', $q_status ) ) + $r_status[] = "post_status = 'pending'"; if ( in_array( 'future' , $q_status ) ) $r_status[] = "post_status = 'future'"; if ( in_array( 'inherit' , $q_status ) ) @@ -1020,7 +1022,7 @@ class WP_Query { $where .= " AND (post_status = 'publish'"; if ( is_admin() ) - $where .= " OR post_status = 'future' OR post_status = 'draft'"; + $where .= " OR post_status = 'future' OR post_status = 'draft' OR post_status = 'pending'"; if ( is_user_logged_in() ) { $where .= current_user_can( "read_private_{$post_type}s" ) ? " OR post_status = 'private'" : " OR post_author = $user_ID AND post_status = 'private'"; @@ -1128,7 +1130,7 @@ class WP_Query { // User must be logged in to view unpublished posts. $this->posts = array(); } else { - if ('draft' == $status) { + if (in_array($status, array('draft', 'pending')) ) { // User must have edit permissions on the draft to preview. if (! current_user_can('edit_post', $this->posts[0]->ID)) { $this->posts = array(); diff --git a/wp-includes/version.php b/wp-includes/version.php index 51e5d564ec..efc2ba935d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -3,6 +3,6 @@ // This holds the version number in a separate file so we can bump it without cluttering the SVN $wp_version = '2.3-alpha'; -$wp_db_version = 5539; +$wp_db_version = 5540; ?>