Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Base_Send_Email | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| send_email | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jetpack CRM Automation Send_Email_To_Contact action. |
| 4 | * |
| 5 | * @package automattic/jetpack-crm |
| 6 | * @since 6.2.0 |
| 7 | */ |
| 8 | |
| 9 | namespace Automattic\Jetpack\CRM\Automation\Actions; |
| 10 | |
| 11 | use Automattic\Jetpack\CRM\Automation\Base_Action; |
| 12 | |
| 13 | /** |
| 14 | * Adds the Add_Contact_Log class. |
| 15 | * |
| 16 | * @since 6.2.0 |
| 17 | */ |
| 18 | abstract class Base_Send_Email extends Base_Action { |
| 19 | |
| 20 | /** |
| 21 | * Sends email. |
| 22 | * Note that this is essentially an abstraction layer on top of legacy code. |
| 23 | * |
| 24 | * @since 6.2.0 |
| 25 | * |
| 26 | * @param array $email_data Array with email data. |
| 27 | */ |
| 28 | public function send_email( $email_data ) { |
| 29 | |
| 30 | // default delivery method |
| 31 | $delivery_method = -1; |
| 32 | |
| 33 | // determine delivery method from email template settings |
| 34 | if ( empty( $email_data['template'] ) ) { |
| 35 | // legacy non-type |
| 36 | $email_type = -999; |
| 37 | } else { |
| 38 | $email_type = $email_data['template']; |
| 39 | $delivery_method = zeroBSCRM_mailTemplate_getMailDelMethod( $email_type ); |
| 40 | if ( empty( $delivery_method ) ) { |
| 41 | $delivery_method = -1; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | $legacy_email_data = array( |
| 46 | 'toEmail' => $email_data['to_email'], |
| 47 | 'toName' => $email_data['to_name'], |
| 48 | 'subject' => $email_data['subject'], |
| 49 | 'message' => $email_data['headers'], |
| 50 | 'body' => $email_data['body'], |
| 51 | 'textbody' => '', |
| 52 | 'options' => array( |
| 53 | 'html' => 1, |
| 54 | ), |
| 55 | 'tracking' => array( |
| 56 | 'emailTypeID' => $email_type, |
| 57 | 'targetObjID' => $email_data['target_id'], |
| 58 | 'senderWPID' => $email_data['sender_id'], |
| 59 | 'associatedObjID' => $email_data['assoc_obj_id'], |
| 60 | ), |
| 61 | ); |
| 62 | |
| 63 | // send email |
| 64 | zeroBSCRM_mailDelivery_sendMessage( $delivery_method, $legacy_email_data ); |
| 65 | } |
| 66 | } |