Changeset 1396
- Timestamp:
- 03/13/2015 12:56:45 AM (10 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-organizer-reminders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-mailer.php
r1310 r1396 228 228 229 229 /** 230 * Retrieve the e-mail address that a Reminder should be sent to.230 * Retrieve the e-mail address(es) that a Reminder should be sent to. 231 231 * 232 232 * @param int $wordcamp_id 233 233 * @param int $email_id 234 * @return string 235 */ 236 protected function get_recipient( $wordcamp_id, $email_id ) { 237 $recipient = false; 238 $send_where = get_post_meta( $email_id, 'wcor_send_where', true ); 239 240 if ( 'wcor_send_custom' == $send_where ) { 241 $recipient = get_post_meta( $email_id, 'wcor_send_custom_address', true ); 242 } elseif ( 'wcor_send_mes' == $send_where ) { 234 * 235 * @return array 236 */ 237 protected function get_recipients( $wordcamp_id, $email_id ) { 238 $recipients = array(); 239 $send_where = get_post_meta( $email_id, 'wcor_send_where' ); 240 241 if ( in_array( 'wcor_send_custom', $send_where ) ) { 242 $recipients[] = get_post_meta( $email_id, 'wcor_send_custom_address', true ); 243 } 244 245 if ( in_array( 'wcor_send_mes', $send_where ) ) { 243 246 /** @var $multi_event_sponsors Multi_Event_Sponsors */ 244 247 global $multi_event_sponsors; 245 248 246 $recipient = $multi_event_sponsors->get_sponsor_emails( $multi_event_sponsors->get_wordcamp_me_sponsors( $wordcamp_id ) ); 247 } elseif ( 'wcor_send_sponsor_wrangler' == $send_where ) { 248 249 $recipients = array_merge( 250 $recipients, 251 $multi_event_sponsors->get_sponsor_emails( $multi_event_sponsors->get_wordcamp_me_sponsors( $wordcamp_id ) ) 252 ); 253 } 254 255 if ( in_array( 'wcor_send_sponsor_wrangler', $send_where ) ) { 249 256 // If the Sponsor Wrangler email is invalid, use the default email address. 250 257 if ( is_email( get_post_meta( $wordcamp_id, 'Sponsor Wrangler E-mail Address', true ) ) ) { 251 $recipient = get_post_meta( $wordcamp_id, 'Sponsor Wrangler E-mail Address', true );258 $recipients[] = get_post_meta( $wordcamp_id, 'Sponsor Wrangler E-mail Address', true ); 252 259 } else { 253 $recipient = get_post_meta( $wordcamp_id, 'Email Address', true ); 254 } 255 256 } elseif ( 'wcor_send_camera_wrangler' == $send_where ) { 260 $recipients[] = get_post_meta( $wordcamp_id, 'Email Address', true ); 261 } 262 } 263 264 if ( in_array( 'wcor_send_camera_wrangler', $send_where ) ) { 257 265 $region_id = get_post_meta( $wordcamp_id, 'Multi-Event Sponsor Region', true ); 258 $recipient = MES_Region::get_camera_wranger_from_region( $region_id ); 259 } else { 266 $recipients[] = MES_Region::get_camera_wranger_from_region( $region_id ); 267 } 268 269 if ( in_array( 'wcor_send_organizers', $send_where ) ) { 260 270 $email_address_key = wcpt_key_to_str( 'E-mail Address', 'wcpt_' ); 261 271 272 /* 273 * If a WordCamp post type is being updated, use the new address in the request, rather than the old 274 * one stored in the database 275 */ 262 276 if ( ! empty( $_POST[ $email_address_key ] ) ) { 263 $recipient = sanitize_email( $_POST[ $email_address_key ] );277 $recipients[] = sanitize_email( $_POST[ $email_address_key ] ); 264 278 } else { 265 $recipient = sanitize_email( get_post_meta( $wordcamp_id, 'E-mail Address', true ) );266 } 267 } 268 269 return $recipient ;279 $recipients[] = sanitize_email( get_post_meta( $wordcamp_id, 'E-mail Address', true ) ); 280 } 281 } 282 283 return $recipients; 270 284 } 271 285 … … 299 313 */ 300 314 public function send_manual_email( $email, $wordcamp ) { 301 $recipient = $this->get_recipient ( $wordcamp->ID, $email->ID );315 $recipient = $this->get_recipients( $wordcamp->ID, $email->ID ); 302 316 303 317 return $this->mail( $recipient, $email->post_title, $email->post_content, array(), $email, $wordcamp ); … … 344 358 345 359 foreach ( $reminder_emails as $email ) { 346 $recipient = $this->get_recipient ( $wordcamp->ID, $email->ID );360 $recipient = $this->get_recipients( $wordcamp->ID, $email->ID ); 347 361 348 362 if ( $this->timed_email_is_ready_to_send( $wordcamp, $email, $sent_email_ids ) ) { … … 465 479 */ 466 480 protected function send_individual_emails( $email_id ) { 467 $send_where = get_post_meta( $email_id, 'wcor_send_where' , true);468 469 return 'wcor_send_mes' == $send_where;481 $send_where = get_post_meta( $email_id, 'wcor_send_where' ); 482 483 return in_array( 'wcor_send_mes', $send_where ); 470 484 } 471 485 … … 534 548 535 549 foreach( $emails as $email ) { 536 $recipient = $this->get_recipient ( $wordcamp->ID, $email->ID );550 $recipient = $this->get_recipients( $wordcamp->ID, $email->ID ); 537 551 538 552 if ( ! in_array( $email->ID, $sent_email_ids ) ) { -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-reminder.php
r1309 r1396 85 85 */ 86 86 public function markup_reminder_details( $post ) { 87 $send_where = get_post_meta( $post->ID, 'wcor_send_where' , true);87 $send_where = get_post_meta( $post->ID, 'wcor_send_where' ); 88 88 $send_custom_address = get_post_meta( $post->ID, 'wcor_send_custom_address', true ); 89 89 $send_when = get_post_meta( $post->ID, 'wcor_send_when', true ); … … 100 100 <tbody> 101 101 <tr> 102 <th><input id="wcor_send_organizers" name="wcor_send_where " type="radio" value="wcor_send_organizers" <?php checked( $send_where, 'wcor_send_organizers'); ?>></th>102 <th><input id="wcor_send_organizers" name="wcor_send_where[]" type="checkbox" value="wcor_send_organizers" <?php checked( in_array( 'wcor_send_organizers', $send_where ) ); ?>></th> 103 103 <td colspan="2"><label for="wcor_send_organizers">The organizing team</label></td> 104 104 </tr> 105 105 106 106 <tr> 107 <th><input id="wcor_send_sponsor_wrangler" name="wcor_send_where " type="radio" value="wcor_send_sponsor_wrangler" <?php checked( $send_where, 'wcor_send_sponsor_wrangler'); ?>></th>107 <th><input id="wcor_send_sponsor_wrangler" name="wcor_send_where[]" type="checkbox" value="wcor_send_sponsor_wrangler" <?php checked( in_array( 'wcor_send_sponsor_wrangler', $send_where ) ); ?>></th> 108 108 <td colspan="2"><label for="wcor_send_sponsor_wrangler">The Sponsor Wrangler</label></td> 109 109 </tr> 110 110 111 111 <tr> 112 <th><input id="wcor_send_mes" name="wcor_send_where " type="radio" value="wcor_send_mes" <?php checked( $send_where, 'wcor_send_mes'); ?>></th>112 <th><input id="wcor_send_mes" name="wcor_send_where[]" type="checkbox" value="wcor_send_mes" <?php checked( in_array( 'wcor_send_mes', $send_where ) ); ?>></th> 113 113 <td colspan="2"><label for="wcor_send_mes">The WordCamp's Multi-Event Sponsors</label></td> 114 114 </tr> 115 115 116 116 <tr> 117 <th><input id="wcor_send_camera_wrangler" name="wcor_send_where " type="radio" value="wcor_send_camera_wrangler" <?php checked( $send_where, 'wcor_send_camera_wrangler'); ?>></th>117 <th><input id="wcor_send_camera_wrangler" name="wcor_send_where[]" type="checkbox" value="wcor_send_camera_wrangler" <?php checked( in_array( 'wcor_send_camera_wrangler', $send_where ) ); ?>></th> 118 118 <td colspan="2"><label for="wcor_send_camera_wrangler">The Region's Camera Kit Wrangler</label></td> 119 119 </tr> 120 120 121 121 <tr> 122 <th><input id="wcor_send_custom" name="wcor_send_where " type="radio" value="wcor_send_custom" <?php checked( $send_where, 'wcor_send_custom'); ?>></th>122 <th><input id="wcor_send_custom" name="wcor_send_where[]" type="checkbox" value="wcor_send_custom" <?php checked( in_array( 'wcor_send_custom', $send_where ) ); ?>></th> 123 123 <td><label for="wcor_send_custom">A custom address: </label></td> 124 124 <td><input id="wcor_send_custom_address" name="wcor_send_custom_address" type="text" class="regular-text" value="<?php echo esc_attr( $send_custom_address ); ?>" /></td> … … 367 367 */ 368 368 protected function save_post_meta( $post, $new_meta ) { 369 $send_where_whitelist = array( 'wcor_send_organizers', 'wcor_send_sponsor_wrangler', 'wcor_send_mes', 'wcor_send_camera_wrangler', 'wcor_send_custom' ); 370 371 delete_post_meta( $post->ID, 'wcor_send_where' ); 369 372 if ( isset( $new_meta['wcor_send_where'] ) ) { 370 if ( in_array( $new_meta['wcor_send_where'], array( 'wcor_send_organizers', 'wcor_send_sponsor_wrangler', 'wcor_send_mes', 'wcor_send_camera_wrangler', 'wcor_send_custom' ) ) ) { 371 update_post_meta( $post->ID, 'wcor_send_where', $new_meta['wcor_send_where'] ); 373 foreach( $new_meta['wcor_send_where'] as $send_where ) { 374 if ( in_array( $send_where, $send_where_whitelist ) ) { 375 add_post_meta( $post->ID, 'wcor_send_where', $send_where ); 376 } 372 377 } 373 378 }
Note: See TracChangeset
for help on using the changeset viewer.