Skip to content
Snippets Groups Projects
Commit a98e19a1 authored by jtisseau's avatar jtisseau
Browse files

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.
parent d7b0e412
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2016 Jonathan TISSEAU <jonathan.tisseau@86dev.fr>
*
* 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 '</script>'."\n";
}
......@@ -475,6 +489,20 @@ if ($action == 'edit')
else print yn(0).' ('.$langs->trans("NotSupported").')';
print '</td></tr>';
// STARTTLS
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
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 '</td></tr>';
// Separator
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="2">&nbsp;</td></tr>';
......@@ -579,6 +607,20 @@ else
else print yn(0).' ('.$langs->trans("NotSupported").')';
print '</td></tr>';
// STARTTLS
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
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 '</td></tr>';
// Separator
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="2">&nbsp;</td></tr>';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment