WordPress.org

Make WordPress Core

Changeset 5707


Ignore:
Timestamp:
06/14/2007 04:24:28 PM (12 years ago)
Author:
markjaquith
Message:

Introducing post_status="pending". see #4446 and put any initial bug reports on that ticket

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r5587 r5707  
    102102<fieldset id="poststatusdiv" class="dbx-box">
    103103<h3 class="dbx-handle"><?php _e('Post Status') ?></h3>
    104 <div class="dbx-content"><?php if ( current_user_can('publish_posts') ) : ?>
    105 <label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label>
    106 <?php endif; ?>
     104<div class="dbx-content">
     105<?php if ( current_user_can('publish_posts') ) : ?>
     106    <label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label>
     107<?php endif; ?>
     108    <label for="post_status_pending" class="selectit"><input id="post_status_pending" name="post_status" type="radio" value="pending" <?php checked($post->post_status, 'pending'); ?> /> <?php _e('Pending Review') ?></label>
    107109      <label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label>
    108110      <label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="radio" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></div>
     
    168170<?php if ( current_user_can('publish_posts') ) : ?>
    169171    <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
     172<?php else : ?>
     173    <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
    170174<?php endif; ?>
    171175<?php
  • trunk/wp-admin/edit-post-rows.php

    r5575 r5707  
    1111    <tbody id="the-list">
    1212<?php
    13 if ($posts) {
     13if ( have_posts() ) {
    1414$bgcolor = '';
    1515while (have_posts()) : the_post();
     
    9898  </tr>
    9999<?php
    100 } // end if ($posts)
     100} // end if ( have_posts() )
    101101?>
    102102    </tbody>
  • trunk/wp-admin/edit.php

    r5667 r5707  
    1212            'draft' => array(__('Draft'), _c('Drafts|manage posts header')),
    1313            'future' => array(__('Scheduled'), __('Scheduled posts')),
     14            'pending' => array(__('Pending Review'), __('Pending posts')),
    1415            'private' => array(__('Private'), __('Private posts')),
    1516            'publish' => array(__('Published'), __('Published posts'))
    1617        );
     18
     19$avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'");
    1720
    1821$post_status_q = '';
     
    3134
    3235// define the columns to display, the syntax is 'internal name' => 'display name'
    33 $posts_columns = array(
    34     'id'         => '<div style="text-align: center">' . __('ID') . '</div>',
    35     'date'       => __('When'),
    36     'title'      => __('Title'),
    37     'categories' => __('Categories'),
    38     'comments'   => '<div style="text-align: center">' . __('Comments') . '</div>',
    39     'author'     => __('Author')
    40 );
     36$posts_columns = array();
     37$posts_columns['id'] = '<div style="text-align: center">' . __('ID') . '</div>';
     38if ( !in_array($_GET['post_status'], array('pending', 'draft')) )
     39    $posts_columns['date'] = __('When');
     40$posts_columns['title'] = __('Title');
     41$posts_columns['categories'] = __('Categories');
     42if ( 'publish' == $_GET['post_status'] )
     43    $posts_columns['comments'] = '<div style="text-align: center">' . __('Comments') . '</div>';
     44$posts_columns['author'] = __('Author');
     45
    4146$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
    4247
     
    5863    // Use $_GET instead of is_ since they can override each other
    5964    $h2_author = '';
    60     if ( isset($_GET['author']) && $_GET['author'] ) {
    61         $author_user = get_userdata( get_query_var( 'author' ) );
    62         $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
     65    $_GET['author'] = (int) $_GET['author'];
     66    if ( $_GET['author'] != 0 ) {
     67        if ( $_GET['author'] == '-' . $user_ID ) { // author exclusion
     68            $h2_author = ' ' . __('by other authors');
     69        } else {
     70            $author_user = get_userdata( get_query_var( 'author' ) );
     71            $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
     72        }
    6373    }
    6474    $h2_search = isset($_GET['s'])   && $_GET['s']   ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( get_search_query() ) ) : '';
     
    7484    </fieldset>
    7585
    76     <fieldset><legend><?php _e('Post Type&hellip;'); ?></legend>
     86    <fieldset><legend><?php _e('Status&hellip;'); ?></legend>
    7787        <select name='post_status'>
    7888            <option<?php selected( @$_GET['post_status'], 0 ); ?> value='0'><?php _e('Any'); ?></option>
    79 <?php   foreach ( $post_stati as $status => $label ) : ?>
     89<?php   foreach ( $post_stati as $status => $label ) : if ( !in_array($status, $avail_post_stati) ) continue; ?>
    8090            <option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option>
    8191<?php   endforeach; ?>
  • trunk/wp-admin/includes/post.php

    r5566 r5707  
    6565    if ( 'page' == $_POST['post_type'] ) {
    6666        if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' ))
    67             $_POST['post_status'] = 'draft';
     67            $_POST['post_status'] = 'pending';
    6868    } else {
    6969        if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' ))
    70             $_POST['post_status'] = 'draft';
     70            $_POST['post_status'] = 'pending';
    7171    }
    7272
     
    269269    if ( 'page' == $_POST['post_type'] ) {
    270270        if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) )
    271             $_POST['post_status'] = 'draft';
     271            $_POST['post_status'] = 'pending';
    272272    } else {
    273273        if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) )
    274             $_POST['post_status'] = 'draft';
     274            $_POST['post_status'] = 'pending';
    275275    }
    276276
  • trunk/wp-admin/includes/schema.php

    r5700 r5707  
    107107  post_category int(4) NOT NULL default '0',
    108108  post_excerpt text NOT NULL,
    109   post_status enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL default 'publish',
     109  post_status enum('publish','draft','private','static','object','attachment','inherit','future', 'pending') NOT NULL default 'publish',
    110110  comment_status enum('open','closed','registered_only') NOT NULL default 'open',
    111111  ping_status enum('open','closed') NOT NULL default 'open',
  • trunk/wp-admin/includes/template.php

    r5700 r5707  
    421421
    422422    if ( $for_post )
    423         $edit = ( ('draft' == $post->post_status ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
     423        $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
    424424
    425425    echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__( 'Edit timestamp' ).'</label></legend>';
  • trunk/wp-admin/includes/user.php

    r5566 r5707  
    182182}
    183183
    184 function get_others_drafts( $user_id ) {
     184function get_others_unpublished_posts($user_id, $type='any') {
    185185    global $wpdb;
    186186    $user = get_userdata( $user_id );
     
    189189    $editable = get_editable_user_ids( $user_id );
    190190
     191    if ( in_array($type, array('draft', 'pending')) )
     192        $type_sql = " post_status = '$type' ";
     193    else
     194        $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
     195
    191196    if( !$editable ) {
    192         $other_drafts = '';
     197        $other_unpubs = '';
    193198    } else {
    194199        $editable = join(',', $editable);
    195         $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' ");
    196     }
    197 
    198     return apply_filters('get_others_drafts', $other_drafts);
     200        $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' ");
     201    }
     202
     203    return apply_filters('get_others_drafts', $other_unpubs);
     204}
     205
     206function get_others_drafts($user_id) {
     207    return get_others_unpublished_posts($user_id, 'draft');
     208}
     209
     210function get_others_pending($user_id) {
     211    return get_others_unpublished_posts($user_id, 'pending');
    199212}
    200213
  • trunk/wp-admin/post-new.php

    r5676 r5707  
    2525<?php
    2626endif;
     27?>
    2728
    28 if ( $drafts = get_users_drafts( $user_ID ) ) { ?>
    29 <div class="wrap">
    30 <p><strong><?php _e('Your Drafts:') ?></strong>
     29
    3130<?php
    32 // Show drafts.
    33     $num_drafts = count($drafts);
    34     if ( $num_drafts > 15 ) $num_drafts = 15;
    35     for ( $i = 0; $i < $num_drafts; $i++ ) {
    36         $draft = $drafts[$i];
    37         if ( 0 != $i )
    38             echo ', ';
    39         if ( empty($draft->post_title) )
    40             $draft->post_title = sprintf(__('Post # %s'), $draft->ID);
    41         echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
     31$my_drafts = get_users_drafts($user_ID);
     32$pending = get_others_pending($user_ID);
     33$others_drafts = get_others_drafts($user_ID);
     34
     35if ( !empty($my_drafts) || !empty($pending) || !empty($others_drafts) ) {
     36    echo '<div class="wrap" id="draft-nag">';
     37
     38    if ( $my_drafts ) {
     39        echo '<p><strong>' . __( 'Your Drafts:' ) . '</strong> ';
     40        if ( count($my_drafts) < 3 ) {
     41            $i = 0;
     42            foreach ( $my_drafts as $post ) {
     43                if ( $i++ != 0 )
     44                    echo ', ';
     45                echo '<a href="post.php?action=edit&amp;post=' . $post->ID . '">';
     46                the_title();
     47                echo '</a>';
     48            }
     49            echo '.</p>';
     50        } else {
     51            printf(
     52                __( 'You have <a href="%s">%d drafts</a>.' ) . '</p>',
     53                'edit.php?post_status=draft&author=' . $user_ID, count($my_drafts)
     54            );
     55        }
    4256    }
    4357
    44     if ( 15 < count($drafts) ) { ?>
    45         , <a href="edit.php"><?php echo sprintf(__('and %s more &raquo;'), (count($drafts) - 15) ); ?></a>
    46     <?php } ?>
    47 .</p>
    48 </div>
     58    if ( $pending ) {
     59        echo '<p><strong>' . __( 'Pending Review:' ) . '</strong> ';
     60        if ( count($pending) < 3 ) {
     61            $i = 0;
     62            foreach ( $pending as $post ) {
     63                if ( $i++ != 0 )
     64                    echo ', ';
     65                echo '<a href="post.php?action=edit&amp;post=' . $post->ID . '">';
     66                the_title();
     67                echo '</a>';
     68            }
     69            echo '.</p>';
     70        } else {
     71            printf(
     72                __( 'There are <a href="%s">%d drafts pending review</a>.' ) . '</p>',
     73                'edit.php?post_status=pending', count($pending)
     74            );
     75        }
     76    }
     77
     78    if ( $others_drafts ) {
     79        echo '<p><strong>' . __( 'Others&#8217; Drafts:' ) . '</strong> ';
     80        if ( count($others_drafts) < 3 ) {
     81            $i = 0;
     82            foreach ( $others_drafts as $post ) {
     83                if ( $i++ != 0 )
     84                    echo ', ';
     85                echo '<a href="post.php?action=edit&amp;post=' . $post->ID . '">';
     86                the_title();
     87                echo '</a>';
     88            }
     89            echo '.</p>';
     90        } else {
     91            printf(
     92                __( 'There are <a href="%s">%d in-progress drafts by other authors</a>.' ) . '</p>',
     93                'edit.php?post_status=pending&author=-' . $user_ID, count($others_drafts)
     94            );
     95        }
     96    }
     97
     98    echo "</div>\n";
     99}
     100?>
     101
     102
    49103<?php
    50 }
    51 
    52104// Show post form.
    53105$post = get_default_post_to_edit();
  • trunk/wp-comments-post.php

    r5640 r5707  
    2020    do_action('comment_closed', $comment_post_ID);
    2121    wp_die( __('Sorry, comments are closed for this item.') );
    22 } elseif ( 'draft' == $status->post_status ) {
     22} elseif ( in_array($status->post_status, array('draft', 'pending') ) ) {
    2323    do_action('comment_on_draft', $comment_post_ID);
    2424    exit;
  • trunk/wp-includes/post-template.php

    r5700 r5707  
    163163                        $output .= '<a href="' . get_permalink() . '">';
    164164                    } else {
    165                         if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status )
     165                        if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
    166166                            $output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">';
    167167                        else
     
    182182                        $output .= '<a href="' . get_permalink() . '">' . $previouspagelink . '</a>';
    183183                    } else {
    184                         if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status )
     184                        if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
    185185                            $output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">' . $previouspagelink . '</a>';
    186186                        else
     
    193193                        $output .= '<a href="' . get_permalink() . '">' . $nextpagelink . '</a>';
    194194                    } else {
    195                         if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status )
     195                        if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
    196196                            $output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">' . $nextpagelink . '</a>';
    197197                        else
  • trunk/wp-includes/post.php

    r5700 r5707  
    554554    // If the post date is empty (due to having been new or a draft) and status is not 'draft', set date to now
    555555    if (empty($post_date)) {
    556         if ( 'draft' != $post_status )
     556        if ( !in_array($post_status, array('draft', 'pending')) )
    557557            $post_date = current_time('mysql');
    558558    }
    559559
    560560    if (empty($post_date_gmt)) {
    561         if ( 'draft' != $post_status )
     561        if ( !in_array($post_status, array('draft', 'pending')) )
    562562            $post_date_gmt = get_gmt_from_date($post_date);
    563563    }
     
    739739
    740740    // Drafts shouldn't be assigned a date unless explicitly done so by the user
    741     if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) &&
     741    if ( in_array($post['post_status'], array('draft', 'pending')) && empty($postarr['edit_date']) && empty($postarr['post_date']) &&
    742742             ('0000-00-00 00:00:00' == $post['post_date']) )
    743743        $clear_date = true;
  • trunk/wp-includes/query.php

    r5700 r5707  
    10071007            if ( in_array( 'draft'  , $q_status ) )
    10081008                $r_status[] = "post_status = 'draft'";
     1009            if ( in_array( 'pending', $q_status ) )
     1010                $r_status[] = "post_status = 'pending'";
    10091011            if ( in_array( 'future' , $q_status ) )
    10101012                $r_status[] = "post_status = 'future'";
     
    10211023
    10221024            if ( is_admin() )
    1023                 $where .= " OR post_status = 'future' OR post_status = 'draft'";
     1025                $where .= " OR post_status = 'future' OR post_status = 'draft' OR post_status = 'pending'";
    10241026
    10251027            if ( is_user_logged_in() ) {
     
    11291131                    $this->posts = array();
    11301132                } else {
    1131                     if ('draft' == $status) {
     1133                    if  (in_array($status, array('draft', 'pending')) ) {
    11321134                        // User must have edit permissions on the draft to preview.
    11331135                        if (! current_user_can('edit_post', $this->posts[0]->ID)) {
  • trunk/wp-includes/version.php

    r5539 r5707  
    44
    55$wp_version = '2.3-alpha';
    6 $wp_db_version = 5539;
     6$wp_db_version = 5540;
    77
    88?>
Note: See TracChangeset for help on using the changeset viewer.