<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[2646] sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments: WordCamp Budgets: New post statuses and flow for reimbursement requests.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/2646">2646</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/2646","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>kovshenin</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-02-26 23:17:32 +0000 (Fri, 26 Feb 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>WordCamp Budgets: New post statuses and flow for reimbursement requests.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcamppaymentsincludespaymentrequestphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcamppaymentsincludesreimbursementrequestphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/reimbursement-request.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcamppaymentsincludeswordcampbudgetsphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/wordcamp-budgets.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcamppaymentsjavascriptreimbursementrequestsjs">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/javascript/reimbursement-requests.js</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcamppaymentsviewsreimbursementrequestmetaboxstatusphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/reimbursement-request/metabox-status.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcamppaymentsincludespaymentrequestphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php 2016-02-26 23:05:01 UTC (rev 2645)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php 2016-02-26 23:17:32 UTC (rev 2646)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -76,86 +76,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Register our custom post statuses
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function register_post_statuses() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Uses core's draft status.
-
- register_post_status( 'wcb-incomplete', array (
- 'label' => _x( 'Incomplete', 'payment request', 'wordcamporg' ),
- 'public' => false,
- 'protected' => true,
- 'label_count' => _nx_noop(
- 'Incomplete <span class="count">(%s)</span>',
- 'Incomplete <span class="count">(%s)</span>',
- 'wordcamporg'
- ),
- ) );
-
- register_post_status( 'wcb-pending-approval', array (
- 'label' => _x( 'Pending Approval', 'payment request', 'wordcamporg' ),
- 'public' => false,
- 'protected' => true,
- 'label_count' => _nx_noop(
- 'Pending Approval <span class="count">(%s)</span>',
- 'Pending Approval <span class="count">(%s)</span>',
- 'wordcamporg'
- ),
- ) );
-
- register_post_status( 'wcb-approved', array (
- 'label' => _x( 'Approved', 'payment request', 'wordcamporg' ),
- 'public' => false,
- 'protected' => true,
- 'label_count' => _nx_noop(
- 'Approved <span class="count">(%s)</span>',
- 'Approved <span class="count">(%s)</span>',
- 'wordcamporg'
- ),
- ) );
-
- register_post_status( 'wcb-pending-payment', array (
- 'label' => _x( 'Pending Payment', 'payment request', 'wordcamporg' ),
- 'public' => false,
- 'protected' => true,
- 'label_count' => _nx_noop(
- 'Pending Payment <span class="count">(%s)</span>',
- 'Pending Payment <span class="count">(%s)</span>',
- 'wordcamporg'
- ),
- ) );
-
- register_post_status( 'wcb-paid', array (
- 'label' => _x( 'Paid', 'payment request', 'wordcamporg' ),
- 'public' => false,
- 'protected' => true,
- 'label_count' => _nx_noop(
- 'Paid <span class="count">(%s)</span>',
- 'Paid <span class="count">(%s)</span>',
- 'wordcamporg'
- ),
- ) );
-
- register_post_status( 'wcb-failed', array (
- 'label' => _x( 'Failed', 'payment request', 'wordcamporg' ),
- 'public' => false,
- 'protected' => true,
- 'label_count' => _nx_noop(
- 'Failed <span class="count">(%s)</span>',
- 'Failed <span class="count">(%s)</span>',
- 'wordcamporg'
- ),
- ) );
-
- register_post_status( 'wcb-cancelled', array (
- 'label' => _x( 'Cancelled', 'payment request', 'wordcamporg' ),
- 'public' => false,
- 'protected' => true,
- 'label_count' => _nx_noop(
- 'Cancelled <span class="count">(%s)</span>',
- 'Cancelled <span class="count">(%s)</span>',
- 'wordcamporg'
- ),
- ) );
-
- // Legacy statuses
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Legacy statuses. Real statuses are registered in wordcamp-budgets.php.
</ins><span class="cx" style="display: block; padding: 0 10px"> register_post_status(
</span><span class="cx" style="display: block; padding: 0 10px"> 'paid',
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcamppaymentsincludesreimbursementrequestphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/reimbursement-request.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/reimbursement-request.php 2016-02-26 23:05:01 UTC (rev 2645)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/reimbursement-request.php 2016-02-26 23:17:32 UTC (rev 2646)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -58,22 +58,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'supports' => array( 'title' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'has_archive' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return \register_post_type( POST_TYPE, $args );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Get the slugs and names for our custom post statuses
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function get_custom_statuses() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function get_post_statuses() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'wcbrr_submitted' => __( 'Submitted', 'wordcamporg' ),
- 'wcbrr_info_requested' => __( 'Information Requested', 'wordcamporg' ),
- 'wcbrr_rejected' => __( 'Rejected', 'wordcamporg' ),
- 'wcbrr_in_process' => __( 'Payment in Process', 'wordcamporg' ),
- 'wcbrr_paid' => __( 'Paid', 'wordcamporg' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'draft',
+ 'wcb-incomplete',
+ 'wcb-pending-approval',
+ 'wcb-approved',
+ 'wcb-pending-payment',
+ 'wcb-paid',
+ 'wcb-failed',
+ 'wcb-cancelled',
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -81,7 +82,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Register our custom post statuses
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function register_post_statuses() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // todo use get_custom_statuses() for DRYness, but need to handle label_count
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // These are legacy statuses. Real statuses in wordcamp-budgets.php.
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_status(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wcbrr_submitted',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,7 +243,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function user_can_edit_request( $post ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $editable_status = in_array( $post->post_status, array( 'auto-draft', 'draft', 'wcbrr_info_requested' ), true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $editable_status = in_array( $post->post_status, array( 'auto-draft', 'draft', 'wcb-incomplete' ), true );
</ins><span class="cx" style="display: block; padding: 0 10px"> return current_user_can( 'manage_network' ) || $editable_status;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -254,47 +255,43 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function render_status_metabox( $post ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_nonce_field( 'status', 'status_nonce' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $show_draft_button = current_user_can( 'draft_post', $post->ID ) && ! current_user_can( 'manage_network' ); // Network admins can save as draft via the status dropdown, so the button is unnecessary UI clutter
- $show_submit_button = user_can_edit_request( $post );
- $available_statuses = array_merge( array( 'draft' => __( 'Draft' ) ), get_custom_statuses() );
- $status_name = get_status_name( $post->post_status );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $back_compat_statuses = array(
+ 'wcbrr_submitted' => 'pending-approval',
+ 'wcbrr_info_requested' => 'wcb-incomplete',
+ 'wcbrr_rejected' => 'wcb-failed',
+ 'wcbrr_in_process' => 'pending-payment',
+ 'wcbrr_paid' => 'wcb-paid',
+ );
+
+ // Map old statuses to new statuses.
+ if ( array_key_exists( $post->post_status, $back_compat_statuses ) ) {
+ $post->post_status = $back_compat_statuses[ $post->post_status ];
+ }
+
+ $editable_statuses = array( 'auto-draft', 'draft', 'wcb-incomplete' );
+ $current_user_can_edit_request = false;
+ $submit_text = _x( 'Update', 'payment request', 'wordcamporg' );
+ $submit_note = '';
+
+ if ( current_user_can( 'manage_network' ) ) {
+ $current_user_can_edit_request = true;
+ } elseif ( in_array( $post->post_status, $editable_statuses ) ) {
+ $submit_text = __( 'Submit for Review', 'wordcamporg' );
+ $submit_note = __( 'Once submitted for review, this request can not be edited.', 'wordcamporg' );
+ $current_user_can_edit_request = true;
+ }
+
+ $incomplete_notes = get_post_meta( $post->ID, '_wcp_incomplete_notes', true );
+ $incomplete_readonly = ! current_user_can( 'manage_network' ) ? 'readonly' : '';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $request_id = get_current_blog_id() . '-' . $post->ID;
</span><span class="cx" style="display: block; padding: 0 10px"> $requested_by = \WordCamp_Budgets::get_requester_name( $post->post_author );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $delete_text = EMPTY_TRASH_DAYS ? __( 'Move to Trash' ) : __( 'Delete Permanently' );
</del><span class="cx" style="display: block; padding: 0 10px"> $update_text = current_user_can( 'manage_network' ) ? __( 'Update Request', 'wordcamporg' ) : __( 'Send Request', 'wordcamporg' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> require_once( dirname( __DIR__ ) . '/views/reimbursement-request/metabox-status.php' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Get the name for the given status slug
- *
- * @param string $status_slug
- *
- * @return string
- */
-function get_status_name( $status_slug ) {
- $status_name = '';
-
- switch ( $status_slug ) {
- case 'auto-draft':
- case 'draft':
- $status_name = __( 'Draft' );
- break;
-
- default:
- $custom_statuses = get_custom_statuses();
- foreach ( $custom_statuses as $custom_slug => $custom_name ) {
- if ( $custom_slug === $status_slug ) {
- $status_name = $custom_name;
- }
- }
- }
-
- return $status_name;
-}
-
-/**
</del><span class="cx" style="display: block; padding: 0 10px"> * Render the Notes metabox
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param \WP_Post $post
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -382,12 +379,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function display_post_states( $states ) {
</span><span class="cx" style="display: block; padding: 0 10px"> global $post;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $custom_states = get_custom_statuses();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $post->post_type != POST_TYPE )
+ return $states;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $custom_states as $slug => $name ) {
- if ( $slug == $post->post_status && $slug != get_query_var( 'post_status' ) ) {
- $states[ $slug ] = $name;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $status = get_post_status_object( $post->post_status );
+ if ( get_query_var( 'post_status' ) != $post->post_status ) {
+ $states[ $status->name ] = $status->label;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $states;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -407,18 +404,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Requesting to save draft
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $post_data_raw['wcbsi-save-draft'] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $post_data_raw['wcb-save-draft'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( current_user_can( 'draft_post', $post_data['ID'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_data['post_status'] = 'draft';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Requesting to submit/update the post
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- elseif ( isset( $post_data_raw['send-reimbursement-request'] ) ) {
- if ( current_user_can( 'manage_network' ) ) {
- $post_data['post_status'] = $_POST['post_status'];
- } else {
- $post_data['post_status'] = 'wcbrr_submitted';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'manage_network' ) ) {
+ $editable_statuses = array( 'auto-draft', 'draft', 'wcb-incomplete' );
+ if ( ! empty( $post_data_raw['wcb-update'] ) && in_array( $post_data['post_status'], $editable_statuses ) ) {
+ $post_data['post_status'] = 'wcb-pending-approval';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -550,6 +546,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $expenses
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function validate_and_save_notes( $post, $new_note_message ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Save incomplete message.
+ if ( isset( $_POST['wcp_mark_incomplete_notes'] ) ) {
+ $safe_value = '';
+ if ( $post->post_status == 'wcb-incomplete' ) {
+ $safe_value = wp_kses( $_POST['wcp_mark_incomplete_notes'], wp_kses_allowed_html( 'strip' ) );
+ }
+
+ update_post_meta( $post->ID, '_wcp_incomplete_notes', $safe_value );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $new_note_message = sanitize_text_field( wp_unslash( $new_note_message ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $new_note_message ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -627,14 +634,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $to = \WordCamp_Budgets::get_requester_formatted_email( $request->post_author );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $relevant_statuses = array( 'wcbrr_info_requested', 'wcbrr_rejected', 'wcbrr_in_process', 'wcbrr_paid' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $relevant_statuses = get_post_statuses();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $to || ! in_array( $request->post_status, $relevant_statuses, true ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $subject = 'Status update for ' . sanitize_text_field( $request->post_title );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $status_name = get_status_name( $request->post_status );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $status = get_post_status_object( $request->post_status );
+ $status_name = $status->label;
</ins><span class="cx" style="display: block; padding: 0 10px"> $request_url = admin_url( sprintf( 'post.php?post=%s&action=edit', $request->ID ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $headers = array( 'Reply-To: support@wordcamp.org' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -671,7 +679,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $drafted_status = in_array( $post->post_status, array( 'auto-draft', 'draft' ), true );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $draft_or_incomplete_status = $drafted_status || 'wcbrr_info_requested' === $post->post_status;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $draft_or_incomplete_status = $drafted_status || 'wcb-incomplete' === $post->post_status;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch( $requested_capability ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'draft_post':
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcamppaymentsincludeswordcampbudgetsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/wordcamp-budgets.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/wordcamp-budgets.php 2016-02-26 23:05:01 UTC (rev 2645)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/wordcamp-budgets.php 2016-02-26 23:17:32 UTC (rev 2646)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,11 +10,96 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Constructor
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'init', array( __CLASS__, 'register_post_statuses' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_menu', array( $this, 'register_budgets_menu' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_common_assets' ), 11 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Register all post statuses used by any CPTs.
+ */
+ public static function register_post_statuses() {
+ // Uses core's draft status too.
+
+ register_post_status( 'wcb-incomplete', array (
+ 'label' => _x( 'Incomplete', 'payment request', 'wordcamporg' ),
+ 'public' => false,
+ 'protected' => true,
+ 'label_count' => _nx_noop(
+ 'Incomplete <span class="count">(%s)</span>',
+ 'Incomplete <span class="count">(%s)</span>',
+ 'wordcamporg'
+ ),
+ ) );
+
+ register_post_status( 'wcb-pending-approval', array (
+ 'label' => _x( 'Pending Approval', 'payment request', 'wordcamporg' ),
+ 'public' => false,
+ 'protected' => true,
+ 'label_count' => _nx_noop(
+ 'Pending Approval <span class="count">(%s)</span>',
+ 'Pending Approval <span class="count">(%s)</span>',
+ 'wordcamporg'
+ ),
+ ) );
+
+ register_post_status( 'wcb-approved', array (
+ 'label' => _x( 'Approved', 'payment request', 'wordcamporg' ),
+ 'public' => false,
+ 'protected' => true,
+ 'label_count' => _nx_noop(
+ 'Approved <span class="count">(%s)</span>',
+ 'Approved <span class="count">(%s)</span>',
+ 'wordcamporg'
+ ),
+ ) );
+
+ register_post_status( 'wcb-pending-payment', array (
+ 'label' => _x( 'Pending Payment', 'payment request', 'wordcamporg' ),
+ 'public' => false,
+ 'protected' => true,
+ 'label_count' => _nx_noop(
+ 'Pending Payment <span class="count">(%s)</span>',
+ 'Pending Payment <span class="count">(%s)</span>',
+ 'wordcamporg'
+ ),
+ ) );
+
+ register_post_status( 'wcb-paid', array (
+ 'label' => _x( 'Paid', 'payment request', 'wordcamporg' ),
+ 'public' => false,
+ 'protected' => true,
+ 'label_count' => _nx_noop(
+ 'Paid <span class="count">(%s)</span>',
+ 'Paid <span class="count">(%s)</span>',
+ 'wordcamporg'
+ ),
+ ) );
+
+ register_post_status( 'wcb-failed', array (
+ 'label' => _x( 'Failed', 'payment request', 'wordcamporg' ),
+ 'public' => false,
+ 'protected' => true,
+ 'label_count' => _nx_noop(
+ 'Failed <span class="count">(%s)</span>',
+ 'Failed <span class="count">(%s)</span>',
+ 'wordcamporg'
+ ),
+ ) );
+
+ register_post_status( 'wcb-cancelled', array (
+ 'label' => _x( 'Cancelled', 'payment request', 'wordcamporg' ),
+ 'public' => false,
+ 'protected' => true,
+ 'label_count' => _nx_noop(
+ 'Cancelled <span class="count">(%s)</span>',
+ 'Cancelled <span class="count">(%s)</span>',
+ 'wordcamporg'
+ ),
+ ) );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Register the Budgets menu
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * This is just an empty page so that a top-level menu can be created to hold the various post types and pages.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -405,13 +490,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> case 'beneficiary_state':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'beneficiary_zip_code':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'beneficiary_country':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> case 'payable_to':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'check_street_address':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'check_city':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'check_state':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'check_zip_code':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> case 'ach_bank_name':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'ach_routing_number':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'ach_account_number':
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcamppaymentsjavascriptreimbursementrequestsjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/javascript/reimbursement-requests.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/javascript/reimbursement-requests.js 2016-02-26 23:05:01 UTC (rev 2645)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/javascript/reimbursement-requests.js 2016-02-26 23:17:32 UTC (rev 2646)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -45,6 +45,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> currency.change( function() {
</span><span class="cx" style="display: block; padding: 0 10px"> app.expenses.trigger( 'updateTotal' );
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $('[name="post_status"]').on('change', function() {
+ var $notes = $('.wcb-mark-incomplete-notes'),
+ state = $(this).val() == 'wcb-incomplete';
+
+ $notes.toggle(state);
+ $notes.find('textarea').attr('required', state);
+ }).trigger('change');
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcamppaymentsviewsreimbursementrequestmetaboxstatusphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/reimbursement-request/metabox-status.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/reimbursement-request/metabox-status.php 2016-02-26 23:05:01 UTC (rev 2645)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/reimbursement-request/metabox-status.php 2016-02-26 23:17:32 UTC (rev 2646)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,12 +7,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="submitpost" class="wcb submitbox">
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="minor-publishing">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php if ( $show_draft_button ) : ?>
- <div id="minor-publishing-actions">
- <div id="save-action">
- <?php submit_button( __( 'Save Draft' ), 'secondary', 'wcbsi-save-draft', false ); ?>
- </div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php if ( $current_user_can_edit_request && ! current_user_can( 'manage_network' ) ) : ?>
+ <div id="minor-publishing-actions">
+ <div id="save-action">
+ <?php submit_button( __( 'Save Draft', 'wordcamporg' ), 'button', 'wcb-save-draft', false ); ?>
+ <span class="spinner"></span>
</ins><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="clear"></div>
+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="misc-publishing-actions">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -41,22 +43,31 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php if ( current_user_can( 'manage_network' ) ) : ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <select name="post_status">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php foreach ( $available_statuses as $status_slug => $status_name ) : ?>
- <option value="<?php echo esc_attr( $status_slug ); ?>" <?php selected( $post->post_status, $status_slug ); ?> >
- <?php echo esc_html( $status_name ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php foreach ( get_post_statuses() as $status ) : ?>
+ <?php $status = get_post_status_object( $status ); ?>
+ <option value="<?php echo esc_attr( $status->name ); ?>" <?php selected( $post->post_status, $status->name ); ?> >
+ <?php echo esc_html( $status->label ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </option>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php endforeach; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </select>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php else : ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php echo esc_html( $status_name ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php $status = get_post_status_object( $post->post_status ); ?>
+ <?php echo esc_html( $status->label ); ?>
+ <input type="hidden" name="post_status" value="<?php echo esc_attr( $post->post_status ); ?>" />
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </span>
</span><span class="cx" style="display: block; padding: 0 10px"> </label>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- </div> <!-- .misc-pub-section -->
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="misc-pub-section hide-if-js wcb-mark-incomplete-notes">
+ <label for="wcp_mark_incomplete_notes">What information is needed?</label>
+ <textarea id="wcp_mark_incomplete_notes" name="wcp_mark_incomplete_notes" class="large-text" rows="5"
+ placeholder="Need to attach receipt, etc" <?php echo $incomplete_readonly; ?>><?php echo esc_textarea( $incomplete_notes ); ?></textarea>
+ </div>
+
</ins><span class="cx" style="display: block; padding: 0 10px"> <div class="misc-pub-section misc-pub-total-amount-requested">
</span><span class="cx" style="display: block; padding: 0 10px"> <label>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php _e( 'Total Amount Requested:' ) ?>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -75,34 +86,29 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="major-publishing-actions">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php if ( $show_submit_button ) : ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php if ( $current_user_can_edit_request ) : ?>
+ <?php if ( !empty( $submit_note ) ) : ?>
+ <div><?php echo $submit_note; ?></div>
+ <?php endif; ?>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="delete-action">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php if ( current_user_can( 'delete_post', $post->ID ) ) : ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <a class="submitdelete deletion" href="<?php echo get_delete_post_link( $post->ID ); ?>">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php echo $delete_text; ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php _e( 'Delete', 'wordcamporg' ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </a>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="publishing-action">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr( $update_text ) ?>" />
- <?php submit_button(
- $update_text,
- 'primary button-large',
- 'send-reimbursement-request',
- false,
- array( 'accesskey' => 'p' )
- ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr( $submit_text ) ?>" />
+ <?php submit_button( $submit_text, 'primary button-large', 'wcb-update', false, array( 'accesskey' => 'p' ) ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="clear"></div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php else : ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <p>
- <?php _e( "Requests can't be edited after they've been submitted.", 'wordcamporg' ); ?>
- </p>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php _e( 'This request can not be edited.', 'wordcamporg' ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </div> <!-- #major-publishing-actions -->
</span></span></pre>
</div>
</div>
</body>
</html>