Making WordPress.org


Ignore:
Timestamp:
01/24/2019 02:31:10 PM (6 years ago)
Author:
coreymckrill
Message:

WordCamp Payments: Prevent submission of requests that have no documentation

For both Payment Requests and Reimbursement Requests:

  • Add a method to check and see if the request post can be submitted. Currently this just checks to see if the post has one or more files attached to it.
  • When the post fails the check, show a note in the Status metabox that documentation must be attached first, and don't render the Submit for Review button.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php

    r6718 r8136  
    109109            )
    110110        );
     111    }
     112
     113    /**
     114     * Get a list of statuses for which posts can be edited by non-admins.
     115     *
     116     * @return array
     117     */
     118    protected static function get_editable_statuses() {
     119        return [ 'auto-draft', 'draft', 'wcb-incomplete' ];
    111120    }
    112121
     
    231240        }
    232241
    233         $editable_statuses = array( 'auto-draft', 'draft', 'wcb-incomplete' );
     242        $editable_statuses = self::get_editable_statuses();
    234243        $current_user_can_edit_request = false;
    235244        $submit_text = esc_html_x( 'Update', 'payment request', 'wordcamporg' );
    236245        $submit_note = '';
     246        $submit_note_class = 'warning';
    237247
    238248        if ( current_user_can( 'manage_network' ) ) {
    239249            $current_user_can_edit_request = true;
    240250        } elseif ( in_array( $post->post_status, $editable_statuses ) ) {
    241             $submit_text = esc_html__( 'Submit for Review', 'wordcamporg' );
    242             $submit_note = esc_html__( 'Once submitted for review, this request can not be edited.', 'wordcamporg' );
     251            if ( WordCamp_Budgets::can_submit_request( $post ) ) {
     252                $submit_text = __( 'Submit for Review', 'wordcamporg' );
     253                $submit_note = __( 'Once submitted for review, this request cannot be edited.', 'wordcamporg' );
     254            } else {
     255                $submit_note = __( 'Please add an invoice or other supporting documentation in the Files section and save the draft.', 'wordcamporg' );
     256                $submit_note_class = 'error';
     257            }
     258
    243259            $current_user_can_edit_request = true;
    244260        }
     
    584600        // Submit for Review button was clicked.
    585601        if ( ! current_user_can( 'manage_network' ) ) {
    586             $editable_statuses = array( 'auto-draft', 'draft', 'wcb-incomplete' );
     602            $editable_statuses = self::get_editable_statuses();
    587603            if ( ! empty( $post_data_raw['wcb-update'] ) && in_array( $post_data['post_status'], $editable_statuses ) ) {
    588604                $post_data['post_status'] = 'wcb-pending-approval';
Note: See TracChangeset for help on using the changeset viewer.