diff --git a/public_html/wp-content/plugins/wordcamp-organizer-reminders/tests/test-wcor-mailer.php b/public_html/wp-content/plugins/wordcamp-organizer-reminders/tests/test-wcor-mailer.php index 7182748e2f..995accd4e2 100644 --- a/public_html/wp-content/plugins/wordcamp-organizer-reminders/tests/test-wcor-mailer.php +++ b/public_html/wp-content/plugins/wordcamp-organizer-reminders/tests/test-wcor-mailer.php @@ -167,7 +167,7 @@ public function test_timed_messages_sent( $send_when, $send_when_period, $send_w 'post_status' => $wordcamp_post_status, ) ); - if ( in_array( $send_when, array( 'wcor_send_before', 'wcor_send_after', 'wcor_send_after_and_no_report' ) ) ) { + if ( in_array( $send_when, array( 'wcor_send_before', 'wcor_send_after' ) ) ) { update_post_meta( self::$wordcamp_dayton_post_id, 'Start Date (YYYY-mm-dd)', $compare_date ); } elseif ( 'wcor_send_after_pending' === $send_when ) { update_post_meta( self::$wordcamp_dayton_post_id, '_timestamp_added_to_planning_schedule', $compare_date ); @@ -235,15 +235,6 @@ public function data_timed_messages_sent() { strtotime( 'now - 3 days' ), 'wcpt-scheduled', ), - - // After the camp ends and no transparency report is received. - array( - 'wcor_send_after_and_no_report', - 'wcor_send_days_after_and_no_report', - 3, - strtotime( 'now - 3 days' ), - 'wcpt-scheduled', - ), ); } diff --git a/public_html/wp-content/plugins/wordcamp-organizer-reminders/views/metabox-reminder-details.php b/public_html/wp-content/plugins/wordcamp-organizer-reminders/views/metabox-reminder-details.php index 1d63059b24..1032d551f9 100644 --- a/public_html/wp-content/plugins/wordcamp-organizer-reminders/views/metabox-reminder-details.php +++ b/public_html/wp-content/plugins/wordcamp-organizer-reminders/views/metabox-reminder-details.php @@ -17,10 +17,11 @@ >
- (Will send to + (Will send to 1. support@wordcamp.org 2. If specified, the email address under WordCamp Information section on WordCamp edit page 3. If specified, the email address of the lead organizer) + @@ -122,6 +123,11 @@ + + + + + @@ -149,15 +155,6 @@ - - - - - - diff --git a/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-mailer.php b/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-mailer.php index 387e6bc266..55e6f21093 100644 --- a/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-mailer.php +++ b/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-mailer.php @@ -535,7 +535,7 @@ public function send_timed_emails() { 'meta_query' => array( array( 'key' => 'wcor_send_when', - 'value' => array( 'wcor_send_before', 'wcor_send_after', 'wcor_send_after_pending', 'wcor_send_after_and_no_report' ), + 'value' => array( 'wcor_send_before', 'wcor_send_after', 'wcor_send_after_pending' ), 'compare' => 'IN' ), ), @@ -595,6 +595,15 @@ protected function timed_email_is_ready_to_send( $wordcamp, $email, $sent_email_ return $ready; } + /** + * Do not send emails if it's for transparency report and the camp is running money through WPCS PBC. + */ + $transparency_report = get_post_meta( $email->ID, 'wcor_transparency_report', true ); + $through_wpcs_pbc = get_post_meta( $wordcamp->ID, 'Running money through WPCS PBC', true ); + if ( $transparency_report && $through_wpcs_pbc ) { + return $ready; + } + $send_when = get_post_meta( $email->ID, 'wcor_send_when', true ); $start_date = get_post_meta( $wordcamp->ID, 'Start Date (YYYY-mm-dd)', true ); $end_date = get_post_meta( $wordcamp->ID, 'End Date (YYYY-mm-dd)', true ); @@ -618,13 +627,25 @@ protected function timed_email_is_ready_to_send( $wordcamp, $email, $sent_email_ * Do not send emails with "send X days after the camp ends" trigger if WordCamp didn't happen. * All WordCamps that happen, should have public status. */ - if ( in_array( $wordcamp->post_status, WordCamp_Loader::get_public_post_statuses() ) ) { - $days_after = absint( get_post_meta( $email->ID, 'wcor_send_days_after', true ) ); + if ( ! in_array( $wordcamp->post_status, WordCamp_Loader::get_public_post_statuses() ) ) { + return $ready; + } + + $days_after = absint( get_post_meta( $email->ID, 'wcor_send_days_after', true ) ); - if ( $end_date && $days_after ) { - $send_date = $end_date + ( $days_after * DAY_IN_SECONDS ); + if ( $end_date && $days_after ) { + $send_date = $end_date + ( $days_after * DAY_IN_SECONDS ); - if ( $send_date <= current_time( 'timestamp' ) ) { + if ( $send_date <= current_time( 'timestamp' ) ) { + /** + * If this reminder is for transparency report, only send if the report hasn't been received yet. + */ + if ( $transparency_report ) { + $report_received = get_post_meta( $wordcamp->ID, 'Transparency Report Received', true ); + if ( ! $report_received ) { + $ready = true; + } + } else { $ready = true; } } @@ -636,17 +657,6 @@ protected function timed_email_is_ready_to_send( $wordcamp, $email, $sent_email_ if ( $days_after_pending && $timestamp_added_to_pending_schedule ) { $execution_timestamp = $timestamp_added_to_pending_schedule + ( $days_after_pending * DAY_IN_SECONDS ); - if ( $execution_timestamp <= current_time( 'timestamp' ) ) { - $ready = true; - } - } - } elseif ( 'wcor_send_after_and_no_report' == $send_when ) { - $days_after_and_no_report = absint( get_post_meta( $email->ID, 'wcor_send_days_after_and_no_report', true ) ); - $report_received = get_post_meta( $wordcamp->ID, 'Transparency Report Received', true ); - - if ( $end_date && $days_after_and_no_report && ! $report_received ) { - $execution_timestamp = $end_date + ( $days_after_and_no_report * DAY_IN_SECONDS ); - if ( $execution_timestamp <= current_time( 'timestamp' ) ) { $ready = true; } diff --git a/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-reminder.php b/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-reminder.php index ce95012013..1a28458033 100644 --- a/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-reminder.php +++ b/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-reminder.php @@ -194,11 +194,16 @@ protected function save_post_meta( $post, $new_meta ) { } if ( isset( $new_meta['wcor_send_when'] ) ) { - if ( in_array( $new_meta['wcor_send_when'], array( 'wcor_send_before', 'wcor_send_after', 'wcor_send_after_pending', 'wcor_send_after_and_no_report', 'wcor_send_trigger' ) ) ) { + if ( in_array( $new_meta['wcor_send_when'], array( 'wcor_send_before', 'wcor_send_after', 'wcor_send_after_pending', 'wcor_send_trigger' ) ) ) { update_post_meta( $post->ID, 'wcor_send_when', $new_meta['wcor_send_when'] ); } } + delete_post_meta( $post->ID, 'wcor_transparency_report' ); + if ( isset( $new_meta['wcor_transparency_report'] ) ) { + update_post_meta( $post->ID, 'wcor_transparency_report', sanitize_text_field( $new_meta['wcor_transparency_report'] ) ); + } + if ( isset( $new_meta['wcor_send_days_before'] ) ) { update_post_meta( $post->ID, 'wcor_send_days_before', absint( $new_meta['wcor_send_days_before'] ) ); } @@ -211,10 +216,6 @@ protected function save_post_meta( $post, $new_meta ) { update_post_meta( $post->ID, 'wcor_send_days_after_pending', absint( $new_meta['wcor_send_days_after_pending'] ) ); } - if ( isset( $new_meta['wcor_send_days_after_and_no_report'] ) ) { - update_post_meta( $post->ID, 'wcor_send_days_after_and_no_report', absint( $new_meta['wcor_send_days_after_and_no_report'] ) ); - } - if ( isset( $new_meta['wcor_which_trigger'] ) ) { if ( in_array( $new_meta['wcor_which_trigger'], array_merge( array( 'null' ), array_keys( $GLOBALS['WCOR_Mailer']->triggers ) ) ) ) { update_post_meta( $post->ID, 'wcor_which_trigger', $new_meta['wcor_which_trigger'] );
wcor_transparency_report, 'wcor_transparency_report' ); ?>>
wcor_send_when, 'wcor_send_before' ); ?>>
wcor_send_when, 'wcor_send_after_and_no_report' ); ?>> - - -
wcor_send_when, 'wcor_send_trigger' ); ?>>