| 1 |
<?php |
| 2 |
|
| 3 |
use AcyMailing\Core\AcymPlugin; |
| 4 |
|
| 5 |
class plgAcymBrevo extends AcymPlugin |
| 6 |
{ |
| 7 |
const SENDING_METHOD_ID = 'brevo-smtp'; |
| 8 |
const SENDING_METHOD_NAME = 'Brevo'; |
| 9 |
const SENDING_METHOD_HOST = 'smtp-relay.brevo.com'; |
| 10 |
|
| 11 |
public function __construct() |
| 12 |
{ |
| 13 |
parent::__construct(); |
| 14 |
$this->pluginDescription->name = self::SENDING_METHOD_NAME; |
| 15 |
} |
| 16 |
|
| 17 |
public function onAcymGetSendingMethods(&$data, $isMailer = false) |
| 18 |
{ |
| 19 |
$data['sendingMethods'][self::SENDING_METHOD_ID] = [ |
| 20 |
'name' => $this->pluginDescription->name, |
| 21 |
'image' => ACYM_IMAGES.'mailers/brevo.png', |
| 22 |
'image_class' => '', |
| 23 |
]; |
| 24 |
} |
| 25 |
|
| 26 |
public function onAcymGetSendingMethodsHtmlSetting(&$data) |
| 27 |
{ |
| 28 |
ob_start(); |
| 29 |
?> |
| 30 |
<div class="send_settings cell grid-x acym_vcenter" id="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings"> |
| 31 |
<div class="cell grid-x acym_vcenter acym__sending__methods__one__settings"> |
| 32 |
<div class="cell grid-x acym_vcenter acym__sending__methods__one__settings"> |
| 33 |
<label for="brevo_identifier" class="cell shrink margin-right-1"> |
| 34 |
<?php echo esc_html(acym_translation('ACYM_BREVO_LOGIN')); ?> |
| 35 |
</label> |
| 36 |
<?php $this->getLinks( |
| 37 |
'https://get.brevo.com/hbvmwg6onvve' |
| 38 |
); ?> |
| 39 |
<div class="margin-left-1 cell grid-x acym-grid-margin-x shrink acym_vcenter"> |
| 40 |
<p class="cell shrink"><?php echo esc_html(acym_translation('ACYM_ALREADY_HAVE_AN_ACCOUNT')); ?></p> |
| 41 |
<a target="_blank" class="cell shrink" href="https://app.brevo.com/settings/keys/smtp"><?php echo esc_html( |
| 42 |
strtolower(acym_translation('ACYM_HERE')) |
| 43 |
); ?></a> |
| 44 |
</div> |
| 45 |
<input id="brevo_identifier" |
| 46 |
class="cell" |
| 47 |
type="text" |
| 48 |
name="config[brevo_identifier]" |
| 49 |
value="<?php echo esc_attr($this->config->get('brevo_identifier', '')); ?>"> |
| 50 |
</div> |
| 51 |
<div class="cell grid-x acym_vcenter acym__sending__methods__one__settings"> |
| 52 |
<label for="brevo_smtp_key" class="cell"><?php echo esc_html(acym_translation('ACYM_BREVO_SMTP_KEY')); ?></label> |
| 53 |
<input id="brevo_smtp_key" |
| 54 |
class="cell" |
| 55 |
type="text" |
| 56 |
name="config[brevo_smtp_key]" |
| 57 |
value="<?php echo esc_attr($this->config->get('brevo_smtp_key')); ?>"> |
| 58 |
</div> |
| 59 |
</div> |
| 60 |
</div> |
| 61 |
<?php |
| 62 |
$data['sendingMethodsHtmlSettings'][self::SENDING_METHOD_ID] = ob_get_clean(); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* @param array $credentials |
| 67 |
* @param string $sendingMethod |
| 68 |
* @param array $sendingMethodListParams this parameter is only used for the plugin sending method list |
| 69 |
* |
| 70 |
* @return void |
| 71 |
*/ |
| 72 |
public function onAcymGetCredentialsSendingMethod(array &$credentials, string $sendingMethod, array $sendingMethodListParams = []) |
| 73 |
{ |
| 74 |
if ($sendingMethod != self::SENDING_METHOD_ID) return; |
| 75 |
|
| 76 |
$credentials = [ |
| 77 |
self::SENDING_METHOD_ID.'_host' => self::SENDING_METHOD_HOST, |
| 78 |
self::SENDING_METHOD_ID.'_username' => $sendingMethodListParams['brevo_identifier'] ?? $this->config->get('brevo_identifier', ''), |
| 79 |
self::SENDING_METHOD_ID.'_password' => $sendingMethodListParams['brevo_smtp_key'] ?? $this->config->get('brevo_smtp_key', ''), |
| 80 |
]; |
| 81 |
} |
| 82 |
} |
| 83 |
|