From aa5e9c6034bca8fe6d1e5511eb5aea94169c7b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Gaulin?= Date: Thu, 27 Aug 2015 20:50:13 +0200 Subject: [PATCH] Fix encryption settings to reflect laravel encryption config. --- modules/system/lang/en/lang.php | 4 ++++ modules/system/lang/fr/lang.php | 2 ++ modules/system/models/MailSettings.php | 21 ++++++++++++++++++- .../system/models/mailsettings/fields.yaml | 7 ++++--- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/modules/system/lang/en/lang.php b/modules/system/lang/en/lang.php index 67db14089..f3d59a847 100644 --- a/modules/system/lang/en/lang.php +++ b/modules/system/lang/en/lang.php @@ -146,6 +146,10 @@ return [ 'smtp_password' => 'Password', 'smtp_port' => 'SMTP port', 'smtp_ssl' => 'SSL connection required', + 'smtp_encryption' => 'SMTP encryption protocol', + 'smtp_encryption_none' => 'No encryption', + 'smtp_encryption_tls' => 'TLS', + 'smtp_encryption_ssl' => 'SSL', 'sendmail' => 'Sendmail', 'sendmail_path' => 'Sendmail path', 'sendmail_path_comment' => 'Please specify the path of the sendmail program.', diff --git a/modules/system/lang/fr/lang.php b/modules/system/lang/fr/lang.php index a8970ebfe..a1ed2395a 100644 --- a/modules/system/lang/fr/lang.php +++ b/modules/system/lang/fr/lang.php @@ -146,6 +146,8 @@ return [ 'smtp_password' => 'Mot de passe', 'smtp_port' => 'Port SMTP', 'smtp_ssl' => 'Connexion SSL requise', + 'smtp_encryption' => 'Protocole de sécurisation des échanges SMTP', + 'smtp_encryption_none' => 'Aucun cryptage', 'sendmail' => 'Sendmail', 'sendmail_path' => 'Chemin vers Sendmail', 'sendmail_path_comment' => 'Saisir le chemin du programme Sendmail.', diff --git a/modules/system/models/MailSettings.php b/modules/system/models/MailSettings.php index 94803257a..56bd95acd 100644 --- a/modules/system/models/MailSettings.php +++ b/modules/system/models/MailSettings.php @@ -44,7 +44,8 @@ class MailSettings extends Model $this->smtp_port = $config->get('mail.port', 587); $this->smtp_user = $config->get('mail.username'); $this->smtp_password = $config->get('mail.password'); - $this->smtp_authorization = strlen($this->smtp_user); + $this->smtp_authorization = !!strlen($this->smtp_user); + $this->smtp_encryption = $config->get('mail.encryption'); } public function getSendModeOptions() @@ -80,6 +81,11 @@ class MailSettings extends Model $config->set('mail.username', null); $config->set('mail.password', null); } + if ($settings->smtp_encryption) { + $config->set('mail.encryption', $settings->smtp_encryption); + } else { + $config->set('mail.encryption', null); + } break; case self::MODE_SENDMAIL: @@ -97,4 +103,17 @@ class MailSettings extends Model } } + + + /** + * @return array smtp_encryption options values + */ + public function getSmtpEncryptionOptions() + { + return [ + '' => 'system::lang.mail.smtp_encryption_none', + 'tls' => 'system::lang.mail.smtp_encryption_tls', + 'ssl' => 'system::lang.mail.smtp_encryption_ssl', + ]; + } } diff --git a/modules/system/models/mailsettings/fields.yaml b/modules/system/models/mailsettings/fields.yaml index 0e37e30fc..38f24078e 100644 --- a/modules/system/models/mailsettings/fields.yaml +++ b/modules/system/models/mailsettings/fields.yaml @@ -73,10 +73,11 @@ tabs: field: send_mode condition: value[smtp] - smtp_ssl: - type: checkbox - label: system::lang.mail.smtp_ssl + smtp_encryption: + type: dropdown + label: system::lang.mail.smtp_encryption tab: system::lang.mail.general + span: left trigger: action: show field: send_mode