Making WordPress.org

Changeset 2615


Ignore:
Timestamp:
02/25/2016 07:02:13 PM (11 years ago)
Author:
kovshenin
Message:

WordCamp.org: Better status flow for payment requests.

Network administrators (super deputies) can see and change
the current request status and add incomplete notes.

Regular users (admins) can only take the request from draft
to pending-approval, or from incomplete to draft/pending-approval.
After a request is pending approval or any further status, the
author can no longer edit it, unless a network admin explicitly
set it to draft or incomplete.

Location:
sites/branches/wcb-payment-request-statuses/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sites/branches/wcb-payment-request-statuses/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • sites/branches/wcb-payment-request-statuses/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/css/wordcamp-budgets.css

    r2610 r2615  
    1212#submitpost.wcb .misc-pub-section input {
    1313        width: 100%;
     14}
     15
     16#submitpost.wcb .misc-pub-section select {
     17        font-weight: normal;
     18}
     19
     20#wcb-save-draft {
     21        float: left;
    1422}
    1523
  • sites/branches/wcb-payment-request-statuses/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php

    r2609 r2615  
    2323
    2424                // Saving posts
    25                 add_filter( 'wp_insert_post_data',    array( $this, 'ensure_post_date_gmt_set' ), 10, 2 );
     25                add_filter( 'wp_insert_post_data',    array( $this, 'wp_insert_post_data' ), 10, 2 );
    2626                add_action( 'save_post',              array( $this, 'save_payment' ), 10, 2 );
    2727                add_filter( 'map_meta_cap',           array( $this, 'modify_capabilities' ), 10, 4 );
     
    288288                }
    289289
    290                 $submit_text = 'auto-draft' == $post->post_status ? __( 'Submit', 'wordcamporg' ) : __( 'Update', 'wordcamporg' );
    291290                $editable_statuses = array( 'auto-draft', 'draft', 'wcb-incomplete' );
    292                 $current_user_can_edit_request = in_array( $post->post_status, $editable_statuses ) || current_user_can( 'manage_network' );
     291                $current_user_can_edit_request = false;
     292                $submit_text = _x( 'Update', 'payment request', 'wordcamporg' );
     293
     294                if ( current_user_can( 'manage_network' ) ) {
     295                        $current_user_can_edit_request = true;
     296                } elseif ( in_array( $post->post_status, $editable_statuses ) ) {
     297                        $submit_text = __( 'Submit for Review', 'wordcamporg' );
     298                        $current_user_can_edit_request = true;
     299                }
    293300
    294301                $date_vendor_paid = get_post_meta( $post->ID, '_camppayments_date_vendor_paid', true );
     
    300307
    301308                $incomplete_notes = get_post_meta( $post->ID, '_wcp_incomplete_notes', true );
     309                $incomplete_readonly = ! current_user_can( 'manage_network' ) ? 'readonly' : '';
     310
    302311                require_once( dirname( __DIR__ ) . '/views/payment-request/metabox-status.php' );
    303312        }
     
    585594
    586595        /**
    587          * Ensure that new posts have the `post_date_gmt` field populated.
    588          *
    589          * Core only handles this for post types that use the `draft` status (see r8636).
    590596         *
    591597         * @param array $post_data
     
    594600         * @return array
    595601         */
    596         public function ensure_post_date_gmt_set( $post_data, $post_data_raw ) {
     602        public function wp_insert_post_data( $post_data, $post_data_raw ) {
     603                if ( $post_data['post_type'] != self::POST_TYPE )
     604                        return $post_data;
     605
     606                // Ensure that new posts have the `post_date_gmt` field populated.
    597607                if ( 'auto-draft' !== $post_data['post_status'] ) {
    598608                        if ( '0000-00-00 00:00:00' === $post_data['post_date_gmt'] ) {
    599609                                $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
     610                        }
     611                }
     612
     613                // Save Draft button was clicked.
     614                if ( ! empty( $post_data_raw['wcb-save-draft'] ) ) {
     615                        $post_data['post_status'] = 'draft';
     616                }
     617
     618                // Submit for Review button was clicked.
     619                if ( ! current_user_can( 'manage_network' ) ) {
     620                        $editable_statuses = array( 'auto-draft', 'draft', 'wcb-incomplete' );
     621                        if ( ! empty( $post_data_raw['wcb-update'] ) && in_array( $post_data['post_status'], $editable_statuses ) ) {
     622                                $post_data['post_status'] = 'wcb-pending-approval';
    600623                        }
    601624                }
  • sites/branches/wcb-payment-request-statuses/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/payment-request/metabox-status.php

    r2604 r2615  
    11<div id="submitpost" class="wcb submitbox">
    22        <div id="minor-publishing">
     3
     4                <?php if ( $current_user_can_edit_request && ! current_user_can( 'manage_network' ) ) : ?>
     5                <div id="minor-publishing-actions">
     6                        <div id="save-action">
     7                                <?php submit_button( __( 'Save Draft', 'wordcamporg' ), 'button', 'wcb-save-draft', false ); ?>
     8                                <span class="spinner"></span>
     9                        </div>
     10                        <div class="clear"></div>
     11                </div>
     12                <?php endif; ?>
     13
    314                <div id="misc-publishing-actions">
    4 
    515                        <div class="misc-pub-section">
    616                                <?php _e( 'ID:', 'wordcamporg' ); ?>
     
    1727                        </div>
    1828
     29                        <?php if ( $post->post_status != 'auto-draft' ) : ?>
    1930                        <div class="misc-pub-section">
    2031                                <?php $this->render_text_input( $post, 'Date Vendor was Paid', 'date_vendor_paid', '', 'date', array(), $date_vendor_paid_readonly ); ?>
     
    4152                                                        <?php $status = get_post_status_object( $post->post_status ); ?>
    4253                                                        <?php echo esc_html( $status->label ); ?>
     54                                                        <input type="hidden" name="post_status" value="<?php echo esc_attr( $post->post_status ); ?>" />
    4355
    4456                                                <?php endif; ?>
     
    4658                                </label>
    4759                        </div>
     60                        <?php endif; ?>
    4861
    4962                        <div class="misc-pub-section hide-if-js wcb-mark-incomplete-notes">
    5063                                <label for="wcp_mark_incomplete_notes">What information is needed?</label>
    5164                                <textarea id="wcp_mark_incomplete_notes" name="wcp_mark_incomplete_notes" class="large-text" rows="5"
    52                                         placeholder="Need to attach receipt, etc"><?php echo esc_textarea( $incomplete_notes ); ?></textarea>
     65                                        placeholder="Need to attach receipt, etc" <?php echo $incomplete_readonly; ?>><?php echo esc_textarea( $incomplete_notes ); ?></textarea>
    5366                        </div>
    5467
     
    7386                        <div id="publishing-action">
    7487                                <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr( $submit_text ) ?>" />
    75                                 <?php submit_button( $submit_text, 'primary button-large', 'save', false, array( 'accesskey' => 'p' ) ); ?>
     88                                <?php submit_button( $submit_text, 'primary button-large', 'wcb-update', false, array( 'accesskey' => 'p' ) ); ?>
    7689                        </div>
    7790
     
    8093                <?php else : ?>
    8194
    82                         <p><?php _e( 'Paid requests are closed and cannot be edited.', 'wordcamporg' ); ?></p>
     95                        <?php _e( 'This request can not be edited.', 'wordcamporg' ); ?>
    8396
    8497                <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.