| @@ -8,94 +8,94 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | class FrmEmail { |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | - * @var string $email_key | |
| 12 | + * @var string | |
| 13 | 13 | */ |
| 14 | 14 | private $email_key = ''; |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * @var array $to | |
| 17 | + * @var array | |
| 18 | 18 | */ |
| 19 | 19 | private $to = array(); |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | - * @var array $cc | |
| 22 | + * @var array | |
| 23 | 23 | */ |
| 24 | 24 | private $cc = array(); |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * @var array $bcc | |
| 27 | + * @var array | |
| 28 | 28 | */ |
| 29 | 29 | private $bcc = array(); |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * @var string $from | |
| 32 | + * @var string | |
| 33 | 33 | */ |
| 34 | 34 | private $from = ''; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * @var string $reply_to | |
| 37 | + * @var string | |
| 38 | 38 | */ |
| 39 | 39 | private $reply_to = ''; |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * @var string $subject | |
| 42 | + * @var string | |
| 43 | 43 | */ |
| 44 | 44 | private $subject = ''; |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | - * @var string $message | |
| 47 | + * @var string | |
| 48 | 48 | */ |
| 49 | 49 | private $message = ''; |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | - * @var array $attachments | |
| 52 | + * @var array | |
| 53 | 53 | */ |
| 54 | 54 | private $attachments = array(); |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | - * @var bool $is_plain_text | |
| 57 | + * @var bool | |
| 58 | 58 | */ |
| 59 | 59 | private $is_plain_text = false; |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | - * @var bool $is_single_recipient | |
| 62 | + * @var bool | |
| 63 | 63 | */ |
| 64 | 64 | private $is_single_recipient = false; |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | - * @var bool $include_user_info | |
| 67 | + * @var bool | |
| 68 | 68 | */ |
| 69 | 69 | private $include_user_info = false; |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | - * @var string $charset | |
| 72 | + * @var string | |
| 73 | 73 | */ |
| 74 | 74 | private $charset = ''; |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | - * @var string $content_type | |
| 77 | + * @var string | |
| 78 | 78 | */ |
| 79 | 79 | private $content_type = 'text/html'; |
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | - * @var array $settings | |
| 82 | + * @var array | |
| 83 | 83 | */ |
| 84 | 84 | private $settings = array(); |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * @var stdClass $entry | |
| 87 | + * @var stdClass | |
| 88 | 88 | */ |
| 89 | 89 | private $entry; |
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | - * @var stdClass $form | |
| 92 | + * @var stdClass | |
| 93 | 93 | */ |
| 94 | 94 | private $form; |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | - * @var int $action_id | |
| 97 | + * @var int | |
| 98 | 98 | */ |
| 99 | 99 | private $action_id = 0; |
| 100 | 100 | |
| 101 | 101 | /** |
| @@ -216,9 +216,9 @@ | ||
| 216 | 216 | * |
| 217 | 217 | * @since 2.03.04 |
| 218 | 218 | * |
| 219 | 219 | * @param string $recipients |
| 220 | - * @param array $user_id_args | |
| 220 | + * @param array $user_id_args | |
| 221 | 221 | * |
| 222 | 222 | * @return array |
| 223 | 223 | */ |
| 224 | 224 | private function prepare_additional_recipients( $recipients, $user_id_args ) { |
| @@ -304,9 +304,8 @@ | ||
| 304 | 304 | * Set the is_single_recipient property |
| 305 | 305 | * |
| 306 | 306 | * @since 2.03.04 |
| 307 | 307 | * |
| 308 | - * @param $action | |
| 309 | 308 | * @param object $action |
| 310 | 309 | * |
| 311 | 310 | * @return void |
| 312 | 311 | */ |
| @@ -386,16 +385,18 @@ | ||
| 386 | 385 | private function set_message() { |
| 387 | 386 | $this->message = $this->settings['email_message']; |
| 388 | 387 | |
| 389 | 388 | if ( ! $this->is_plain_text ) { |
| 390 | - $this->message = html_entity_decode( $this->message ); // The decode is to support [default-html] shortcodes. | |
| 389 | + // The decode is to support [default-html] shortcodes. | |
| 390 | + $this->message = html_entity_decode( $this->message ); | |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - $this->message = FrmFieldsHelper::basic_replace_shortcodes( $this->message, $this->form, $this->entry ); | |
| 393 | + $this->message = FrmFieldsHelper::basic_replace_shortcodes( $this->message, $this->form, $this->entry ); | |
| 394 | + $prev_mail_body = $this->message; | |
| 394 | 395 | |
| 395 | - $prev_mail_body = $this->message; | |
| 396 | - $pass_entry = clone $this->entry; // make a copy to prevent changes by reference | |
| 397 | - $mail_body = FrmEntriesHelper::replace_default_message( | |
| 396 | + // Make a copy to prevent changes by reference. | |
| 397 | + $pass_entry = clone $this->entry; | |
| 398 | + $mail_body = FrmEntriesHelper::replace_default_message( | |
| 398 | 399 | $prev_mail_body, |
| 399 | 400 | array( |
| 400 | 401 | 'id' => $this->entry->id, |
| 401 | 402 | 'entry' => $pass_entry, |
| @@ -405,9 +406,9 @@ | ||
| 405 | 406 | ); |
| 406 | 407 | |
| 407 | 408 | // Add the user info if it isn't already included |
| 408 | 409 | if ( $this->include_user_info && $prev_mail_body === $mail_body ) { |
| 409 | - $data = $this->entry->description; | |
| 410 | + $data = $this->entry->description; | |
| 410 | 411 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
| 411 | 412 | $this->maybe_add_ip( $mail_body ); |
| 412 | 413 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntriesHelper::get_browser( $data['browser'] ) . "\r\n"; |
| 413 | 414 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
| @@ -511,11 +512,10 @@ | ||
| 511 | 512 | */ |
| 512 | 513 | private function has_recipients() { |
| 513 | 514 | if ( empty( $this->to ) && empty( $this->cc ) && empty( $this->bcc ) ) { |
| 514 | 515 | return false; |
| 515 | - } else { | |
| 516 | - return true; | |
| 517 | 516 | } |
| 517 | + return true; | |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | /** |
| 521 | 521 | * Send an email |
| @@ -607,9 +607,9 @@ | ||
| 607 | 607 | * Get the userID field ID and key for email settings |
| 608 | 608 | * |
| 609 | 609 | * @since 2.03.04 |
| 610 | 610 | * |
| 611 | - * @param $form_id | |
| 611 | + * @param int $form_id | |
| 612 | 612 | * |
| 613 | 613 | * @return array |
| 614 | 614 | */ |
| 615 | 615 | private function get_user_id_args( $form_id ) { |
| @@ -631,9 +631,9 @@ | ||
| 631 | 631 | * |
| 632 | 632 | * @since 2.03.04 |
| 633 | 633 | * |
| 634 | 634 | * @param string $value |
| 635 | - * @param array $user_id_args | |
| 635 | + * @param array $user_id_args | |
| 636 | 636 | * |
| 637 | 637 | * @return string |
| 638 | 638 | */ |
| 639 | 639 | private function prepare_email_setting( $value, $user_id_args ) { |
| @@ -690,24 +690,24 @@ | ||
| 690 | 690 | |
| 691 | 691 | if ( is_email( $val ) ) { |
| 692 | 692 | // If a plain email is used, no formatting is needed |
| 693 | 693 | continue; |
| 694 | + } | |
| 695 | + | |
| 696 | + $parts = explode( ' ', $val ); | |
| 697 | + $email = end( $parts ); | |
| 698 | + | |
| 699 | + if ( is_email( $email ) ) { | |
| 700 | + // If user enters a name and email | |
| 701 | + $name = trim( str_replace( $email, '', $val ) ); | |
| 694 | 702 | } else { |
| 695 | - $parts = explode( ' ', $val ); | |
| 696 | - $email = end( $parts ); | |
| 697 | - | |
| 698 | - if ( is_email( $email ) ) { | |
| 699 | - // If user enters a name and email | |
| 700 | - $name = trim( str_replace( $email, '', $val ) ); | |
| 701 | - } else { | |
| 702 | - // If user enters a name without an email | |
| 703 | - unset( $recipients[ $key ] ); | |
| 704 | - continue; | |
| 705 | - } | |
| 703 | + // If user enters a name without an email | |
| 704 | + unset( $recipients[ $key ] ); | |
| 705 | + continue; | |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | $recipients[ $key ] = $this->format_from_email( $name, $email ); |
| 709 | - } | |
| 709 | + }//end foreach | |
| 710 | 710 | |
| 711 | 711 | return $recipients; |
| 712 | 712 | } |
| 713 | 713 | |
| @@ -757,9 +757,9 @@ | ||
| 757 | 757 | $reply_to = trim( $reply_to ); |
| 758 | 758 | |
| 759 | 759 | if ( ! is_email( $reply_to ) ) { |
| 760 | 760 | list( $name, $email ) = $this->get_name_and_email_for_sender( $reply_to ); |
| 761 | - $reply_to = $this->format_from_email( $name, $email ); | |
| 761 | + $reply_to = $this->format_from_email( $name, $email ); | |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | return $reply_to; |
| 765 | 765 | } |
| @@ -855,10 +855,10 @@ | ||
| 855 | 855 | ); |
| 856 | 856 | |
| 857 | 857 | // Remove phone number from to addresses |
| 858 | 858 | unset( $this->to[ $key ] ); |
| 859 | - } | |
| 860 | - } | |
| 859 | + }//end if | |
| 860 | + }//end foreach | |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | /** |
| 864 | 864 | * Package an array of FrmEmail properties |