| @@ -1,0 +1,80 @@ | ||
| 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 | + ?> | |
| 29 | + <div class="send_settings cell grid-x acym_vcenter" id="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings"> | |
| 30 | + <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings"> | |
| 31 | + <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings"> | |
| 32 | + <label for="brevo_identifier" class="cell shrink margin-right-1"> | |
| 33 | + <?php echo esc_html(acym_translation('ACYM_BREVO_LOGIN')); ?> | |
| 34 | + </label> | |
| 35 | + <?php $this->getLinks( | |
| 36 | + 'https://get.brevo.com/hbvmwg6onvve' | |
| 37 | + ); ?> | |
| 38 | + <div class="margin-left-1 cell grid-x acym-grid-margin-x shrink acym_vcenter"> | |
| 39 | + <p class="cell shrink"><?php echo esc_html(acym_translation('ACYM_ALREADY_HAVE_AN_ACCOUNT')); ?></p> | |
| 40 | + <a target="_blank" class="cell shrink" href="https://app.brevo.com/settings/keys/smtp"><?php echo esc_html( | |
| 41 | + strtolower(acym_translation('ACYM_HERE')) | |
| 42 | + ); ?></a> | |
| 43 | + </div> | |
| 44 | + <input id="brevo_identifier" | |
| 45 | + class="cell" | |
| 46 | + type="text" | |
| 47 | + name="config[brevo_identifier]" | |
| 48 | + value="<?php echo esc_attr($this->config->get('brevo_identifier', '')); ?>"> | |
| 49 | + </div> | |
| 50 | + <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings"> | |
| 51 | + <label for="brevo_smtp_key" class="cell"><?php echo esc_html(acym_translation('ACYM_BREVO_SMTP_KEY')); ?></label> | |
| 52 | + <input id="brevo_smtp_key" | |
| 53 | + class="cell" | |
| 54 | + type="text" | |
| 55 | + name="config[brevo_smtp_key]" | |
| 56 | + value="<?php echo esc_attr($this->config->get('brevo_smtp_key')); ?>"> | |
| 57 | + </div> | |
| 58 | + </div> | |
| 59 | + </div> | |
| 60 | + <?php | |
| 61 | + } | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * @param array $credentials | |
| 65 | + * @param string $sendingMethod | |
| 66 | + * @param array $sendingMethodListParams this parameter is only used for the plugin sending method list | |
| 67 | + * | |
| 68 | + * @return void | |
| 69 | + */ | |
| 70 | + public function onAcymGetCredentialsSendingMethod(array &$credentials, string $sendingMethod, array $sendingMethodListParams = []) | |
| 71 | + { | |
| 72 | + if ($sendingMethod != self::SENDING_METHOD_ID) return; | |
| 73 | + | |
| 74 | + $credentials = [ | |
| 75 | + self::SENDING_METHOD_ID.'_host' => self::SENDING_METHOD_HOST, | |
| 76 | + self::SENDING_METHOD_ID.'_username' => $sendingMethodListParams['brevo_identifier'] ?? $this->config->get('brevo_identifier', ''), | |
| 77 | + self::SENDING_METHOD_ID.'_password' => $sendingMethodListParams['brevo_smtp_key'] ?? $this->config->get('brevo_smtp_key', ''), | |
| 78 | + ]; | |
| 79 | + } | |
| 80 | +} | |