Making WordPress.org


Ignore:
Timestamp:
02/25/2016 07:02:13 PM (10 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:
2 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/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                }
Note: See TracChangeset for help on using the changeset viewer.