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/reimbursement-request.php

    r6718 r8136  
    66
    77namespace WordCamp\Budgets\Reimbursement_Requests;
     8defined( 'WPINC' ) or die();
     9
     10use WP_Post;
    811use WCP_Encryption;
    912use WordCamp\Utilities;
    10 
    11 defined( 'WPINC' ) or die();
     13use WordCamp_Budgets;
    1214
    1315const POST_TYPE = 'wcb_reimbursement';
     
    251253 * submitted yet, or if we've asked for more information.
    252254 *
    253  * @param \WP_Post $post
     255 * @param WP_Post $post
    254256 *
    255257 * @return bool
     
    263265 * Render the Status metabox
    264266 *
    265  * @param \WP_Post $post
     267 * @param WP_Post $post
    266268 */
    267269function render_status_metabox( $post ) {
     
    286288    $submit_text = esc_html_x( 'Update', 'payment request', 'wordcamporg' );
    287289    $submit_note = '';
     290    $submit_note_class = 'warning';
    288291
    289292    if ( current_user_can( 'manage_network' ) ) {
    290293        $current_user_can_edit_request = true;
    291294    } elseif ( in_array( $post->post_status, $editable_statuses ) ) {
    292         $submit_text = esc_html__( 'Submit for Review', 'wordcamporg' );
    293         $submit_note = esc_html__( 'Once submitted for review, this request can not be edited.', 'wordcamporg' );
     295        if ( WordCamp_Budgets::can_submit_request( $post ) ) {
     296            $submit_text = __( 'Submit for Review', 'wordcamporg' );
     297            $submit_note = __( 'Once submitted for review, this request cannot be edited.', 'wordcamporg' );
     298        } else {
     299            $submit_note = __( 'Please add an invoice or other supporting documentation in the Files section and save the draft.', 'wordcamporg' );
     300            $submit_note_class = 'error';
     301        }
     302
    294303        $current_user_can_edit_request = true;
    295304    }
     
    300309    $request_id         = get_current_blog_id() . '-' . $post->ID;
    301310    $requested_by       = \WordCamp_Budgets::get_requester_name( $post->post_author );
    302     $update_text        = current_user_can( 'manage_network' ) ? esc_html__( 'Update Request', 'wordcamporg' ) : esc_html__( 'Send Request', 'wordcamporg' );
    303311
    304312    require_once( dirname( __DIR__ ) . '/views/reimbursement-request/metabox-status.php' );
     
    308316 * Render the Notes metabox
    309317 *
    310  * @param \WP_Post $post
     318 * @param WP_Post $post
    311319 */
    312320function render_notes_metabox( $post ) {
     
    321329 * Render General Information Metabox
    322330 *
    323  * @param \WP_Post $post
     331 * @param WP_Post $post
    324332 *
    325333 */
     
    365373 * Render Expenses Metabox
    366374 *
    367  * @param \WP_Post $post
     375 * @param WP_Post $post
    368376 *
    369377 */
     
    440448 *
    441449 * @param int      $post_id
    442  * @param \WP_Post $post
     450 * @param WP_Post $post
    443451 */
    444452function save_request( $post_id, $post ) {
     
    465473     * user_can_edit_request() instead.
    466474     */
    467     $original_post = new \WP_Post( (object) array( 'post_status' => $_POST['original_post_status'] ) );
     475    $original_post = new WP_Post( (object) array( 'post_status' => $_POST['original_post_status'] ) );
    468476
    469477    if ( user_can_edit_request( $original_post ) ) {
     
    671679 * Validate and save expense data
    672680 *
    673  * @param \WP_Post $post
     681 * @param WP_Post $post
    674682 * @param array    $expenses
    675683 */
     
    716724 * Notify WordCamp Central or the request author when new notes are added
    717725 *
    718  * @param \WP_Post $request
     726 * @param WP_Post $request
    719727 * @param array    $note
    720728 */
     
    762770 * @param string   $new_status
    763771 * @param string   $old_status
    764  * @param \WP_Post $request
     772 * @param WP_Post $request
    765773 */
    766774function notify_organizer_request_updated( $new_status, $old_status, $request ) {
Note: See TracChangeset for help on using the changeset viewer.