From a98e19a1439683805b5f247c5ffde5d474695424 Mon Sep 17 00:00:00 2001 From: jtisseau Date: Wed, 16 Mar 2016 02:09:55 +0100 Subject: [PATCH] Adds a STARTTLS option Adds a STARTTLS authentification option. This is used by Microsoft Hotmail and Exchange. This commit includes a new constant named MAIN_MAIL_EMAIL_STARTTLS, a view and edit view for it and the edit action needed to modify value in DB. It also updates the js function initFields to make it behave like the standard TLS option and adds two jQuery function respectively to set TSL off when STARTTLS is selected and to set STARTTLS off when TLS is selected. Unselecting one of those won"t select the other. --- htdocs/admin/mails.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 733569d8071..52324dc1678 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2012 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2016 Jonathan TISSEAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -71,6 +72,7 @@ if ($action == 'update' && empty($_POST["cancel"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS"),'chaine',0,'',$conf->entity); // Content parameters dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity); @@ -274,6 +276,8 @@ if ($action == 'edit') jQuery(".drag").hide(); jQuery("#MAIN_MAIL_EMAIL_TLS").val(0); jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true); + jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0); + jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true); '; if ($linuxlike) { @@ -300,6 +304,8 @@ if ($action == 'edit') jQuery(".drag").show(); jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.'); jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled"); + jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.'); + jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled"); jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled"); jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled"); jQuery("#MAIN_MAIL_SMTP_SERVER").show(); @@ -312,6 +318,14 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_SENDMODE").change(function() { initfields(); }); + jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() { + if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1) + jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0); + }); + jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() { + if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1) + jQuery("#MAIN_MAIL_EMAIL_TLS").val(0); + }); })'; print ''."\n"; } @@ -475,6 +489,20 @@ if ($action == 'edit') else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; + // STARTTLS + $var=!$var; + print ''.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; + if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'smtps')) + { + if (function_exists('openssl_open')) + { + print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS',(! empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS)?$conf->global->MAIN_MAIL_EMAIL_STARTTLS:0),1); + } + else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } + else print yn(0).' ('.$langs->trans("NotSupported").')'; + print ''; + // Separator $var=!$var; print ' '; @@ -579,6 +607,20 @@ else else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; + // STARTTLS + $var=!$var; + print ''.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'smtps') + { + if (function_exists('openssl_open')) + { + print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS); + } + else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } + else print yn(0).' ('.$langs->trans("NotSupported").')'; + print ''; + // Separator $var=!$var; print ' ';