Making WordPress.org

Changeset 2504


Ignore:
Timestamp:
02/15/2016 07:35:12 PM (10 years ago)
Author:
iandunn
Message:

WordCamp Budgets: Prevent editing invoices that have been sent to QuickBooks.

File:
1 edited

Legend:

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

    r2467 r2504  
    252252    /*
    253253     * We can't use current_user_can( 'edit_post', N ) in this case, because the restriction only applies when
    254      * submitting the edit form, not when viewing the post. So, instead, we simulate get the same result in a
    255      * different way.
     254     * submitting the edit form, not when viewing the post. We also want to allow editing by plugins, but not
     255     * always through the UI. So, instead, we simulate get the same result in a different way.
     256     *
     257     * Network admins can edit submitted invoices in order to correct them before they're sent to QuickBooks, but
     258     * not even network admins can edit them once they've been created in QuickBooks, because then our copy of the
     259     * invoice would no longer match QuickBooks.
     260     *
     261     * This intentionally only prevents editing through the UI; we still want plugins to be able to edit the
     262     * invoice, so that the status can be updated to paid, etc.
    256263     */
    257     $current_user_can_edit_request = in_array( $post->post_status, array( 'auto-draft', 'draft' ), true ) || current_user_can( 'manage_network' );
     264    $allowed_edit_statuses = array( 'auto-draft', 'draft' );
     265
     266    if ( current_user_can( 'manage_network' ) ) {
     267        $allowed_edit_statuses[] = 'wcbsi_submitted';
     268    }
     269
     270    $current_user_can_edit_request = in_array( $post->post_status, $allowed_edit_statuses, true );
    258271
    259272    require_once( dirname( __DIR__ ) . '/views/sponsor-invoice/metabox-status.php' );
Note: See TracChangeset for help on using the changeset viewer.