Debug v20

This commit is contained in:
Laurent Destailleur 2024-04-13 13:22:10 +02:00
parent 23c4cfd2b4
commit d4c74cf572
5 changed files with 119 additions and 60 deletions

View File

@ -308,7 +308,7 @@ if ($action == 'edit') {
}
}
function change_smtp_auth_method() {
console.log("We change smtp auth method radio_pw="+jQuery("#radio_pw").prop("checked"));
console.log("Call smtp auth method");
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_pw").hide();
jQuery(".smtp_oauth_service").show();

View File

@ -192,6 +192,7 @@ if ($action == 'edit') {
if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\')
{
console.log("I choose php mail mode");
jQuery(".drag").hide();
jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").prop("disabled", true);
@ -221,6 +222,7 @@ if ($action == 'edit') {
}
if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\')
{
console.log("I choose smtps mail mode");
jQuery(".drag").show();
jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_EMAILING').');
jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
@ -232,14 +234,15 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
jQuery("#smtp_port_mess").hide();
jQuery("#smtp_port_mess").hide();
jQuery("#smtp_server_mess").hide();
jQuery(".smtp_method").show();
jQuery(".smtp_method").show();
jQuery(".smtp_auth_method").show();
}
if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\')
{
jQuery(".drag").show();
console.log("I choose swiftmailer mail mode");
jQuery(".drag").show();
jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_EMAILING').');
jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_EMAILING').');
@ -252,35 +255,37 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
jQuery("#smtp_server_mess").hide();
jQuery("#smtp_port_mess").hide();
jQuery(".smtp_method").show();
jQuery(".smtp_auth_method").show();
jQuery(".smtp_method").show();
jQuery(".smtp_auth_method").show();
}
}
function change_smtp_auth_method() {
console.log(jQuery("#radio_pw").prop("checked"));
if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_oauth_service").show();
jQuery(".smtp_pw").hide();
} else if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_oauth_service").show();
jQuery(".smtp_pw").hide();
} else if(jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\' || jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\'){
jQuery(".smtp_oauth_service").hide();
jQuery(".smtp_pw").hide();
} else {
jQuery(".smtp_oauth_service").hide();
jQuery(".smtp_pw").show();
}
}
function change_smtp_auth_method() {
console.log("Call smtp auth method");
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_pw").hide();
jQuery(".smtp_oauth_service").show();
} else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_pw").hide();
jQuery(".smtp_oauth_service").show();
} else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
jQuery(".smtp_pw").hide();
jQuery(".smtp_oauth_service").hide();
} else {
jQuery(".smtp_pw").show();
jQuery(".smtp_oauth_service").hide();
}
}
change_smtp_auth_method();
initfields();
change_smtp_auth_method();
jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
change_smtp_auth_method();
initfields();
change_smtp_auth_method();
});
jQuery("#radio_pw, #radio_oauth").change(function() {
change_smtp_auth_method();
});
});
jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
change_smtp_auth_method();
});
jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").change(function() {
if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1)
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
@ -401,8 +406,11 @@ if ($action == 'edit') {
if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
// Note: Default value for MAIN_MAIL_SMTPS_AUTH_TYPE if not defined is 'LOGIN' (but login/pass may be empty and they won't be provided in such a case)
print '<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="LOGIN"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING', 'LOGIN') == 'LOGIN' ? ' checked' : '').'> ';
print '<label for="radio_pw" >'.$langs->trans("UsePassword").'</label>';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<label for="radio_pw" >'.$langs->trans("UseAUTHLOGIN").'</label>';
print '&nbsp; &nbsp; &nbsp;';
print '<input type="radio" id="radio_plain" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="PLAIN"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING', 'PLAIN') == 'PLAIN' ? ' checked' : '').'> ';
print '<label for="radio_plain" >'.$langs->trans("UseAUTHPLAIN").'</label>';
print '&nbsp; &nbsp; &nbsp;';
print '<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="XOAUTH2"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING') == 'XOAUTH2' ? ' checked' : '').'> ';
print '<label for="radio_oauth" >'.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).'</label>';
} else {
@ -552,7 +560,14 @@ if ($action == 'edit') {
// AUTH method
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
$authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING', 'LOGIN');
$text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ;
$text = '';
if ($authtype === "LOGIN") {
$text = $langs->trans("UseAUTHLOGIN");
} elseif ($authtype === "PLAIN") {
$text = $langs->trans("UseAUTHPLAIN");
} elseif ($authtype === "XOAUTH2") {
$text = $langs->trans("UseOauth");
}
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>'.$text.'</td></tr>';
}

View File

@ -93,6 +93,7 @@ if ($action == 'update' && !$cancel) {
}
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_TLS_TICKET"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_TICKET"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET"), 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@ -190,6 +191,7 @@ if ($action == 'edit') {
if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\')
{
console.log("I choose php mail mode");
jQuery(".drag").hide();
jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true);
@ -217,6 +219,7 @@ if ($action == 'edit') {
}
if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\')
{
console.log("I choose smtps mail mode");
jQuery(".drag").show();
jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET').');
jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
@ -233,6 +236,7 @@ if ($action == 'edit') {
}
if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\')
{
console.log("I choose swiftmailer mail mode");
jQuery(".drag").show();
jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET').');
jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
@ -248,33 +252,33 @@ if ($action == 'edit') {
jQuery(".smtp_auth_method").show();
}
}
function change_smtp_auth_method() {
console.log(jQuery("#radio_pw").prop("checked"));
if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_oauth_service").show();
jQuery(".smtp_pw").hide();
} else if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_oauth_service").show();
jQuery(".smtp_pw").hide();
} else if(jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\' || jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\'){
jQuery(".smtp_oauth_service").hide();
jQuery(".smtp_pw").hide();
} else {
jQuery(".smtp_oauth_service").hide();
jQuery(".smtp_pw").show();
}
}
function change_smtp_auth_method() {
console.log("Call smtp auth method");
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_pw").hide();
jQuery(".smtp_oauth_service").show();
} else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_pw").hide();
jQuery(".smtp_oauth_service").show();
} else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
jQuery(".smtp_pw").hide();
jQuery(".smtp_oauth_service").hide();
} else {
jQuery(".smtp_pw").show();
jQuery(".smtp_oauth_service").hide();
}
}
initfields();
change_smtp_auth_method();
change_smtp_auth_method();
jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() {
initfields();
change_smtp_auth_method();
change_smtp_auth_method();
});
jQuery("#radio_pw, #radio_oauth").change(function() {
change_smtp_auth_method();
});
jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
change_smtp_auth_method();
});
jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val() == 1)
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
@ -391,8 +395,11 @@ if ($action == 'edit') {
if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
// Note: Default value for MAIN_MAIL_SMTPS_AUTH_TYPE if not defined is 'LOGIN' (but login/pass may be empty and they won't be provided in such a case)
print '<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="LOGIN"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN') == 'LOGIN' ? ' checked' : '').'> ';
print '<label for="radio_pw" >'.$langs->trans("UsePassword").'</label>';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<label for="radio_pw" >'.$langs->trans("UseAUTHLOGIN").'</label>';
print '&nbsp; &nbsp; &nbsp;';
print '<input type="radio" id="radio_plain" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="PLAIN"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'PLAIN') == 'PLAIN' ? ' checked' : '').'> ';
print '<label for="radio_plain" >'.$langs->trans("UseAUTHPLAIN").'</label>';
print '&nbsp; &nbsp; &nbsp;';
print '<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="XOAUTH2"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') == 'XOAUTH2' ? ' checked' : '').'> ';
print '<label for="radio_oauth" >'.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).'</label>';
} else {
@ -480,6 +487,19 @@ if ($action == 'edit') {
}
print '</td></tr>';
// SMTP_ALLOW_SELF_SIGNED_TICKET
print '<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
if (function_exists('openssl_open')) {
print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET', (getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET : 0), 1);
} else {
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>';
print '</table>';
print dol_get_fiche_end();
@ -528,7 +548,14 @@ if ($action == 'edit') {
// AUTH method
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
$authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN');
$text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ;
$text = '';
if ($authtype === "LOGIN") {
$text = $langs->trans("UseAUTHLOGIN");
} elseif ($authtype === "PLAIN") {
$text = $langs->trans("UseAUTHPLAIN");
} elseif ($authtype === "XOAUTH2") {
$text = $langs->trans("UseOauth");
}
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>'.$text.'</td></tr>';
}
@ -539,7 +566,7 @@ if ($action == 'edit') {
// SMTPS PW
if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') != "XOAUTH2") {
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW_TICKET).'</td></tr>';
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW_TICKET')).'</td></tr>';
}
// SMTPS oauth service
@ -584,6 +611,23 @@ if ($action == 'edit') {
}
print '</td></tr>';
}
// SMTP_ALLOW_SELF_SIGNED_EMAILING
if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
// Nothing
} else {
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
if (function_exists('openssl_open')) {
print yn(getDolGlobalInt('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET'));
} else {
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
}
print '</td></tr>';
}
}
print '</table>';

View File

@ -584,7 +584,7 @@ class CMailFile
$smtps->setBCC($this->addr_bcc);
$smtps->setErrorsTo($this->errors_to);
$smtps->setDeliveryReceipt($this->deliveryreceipt);
if (!empty($conf->global->$keyforsslseflsigned)) {
if (getDolGlobalString($keyforsslseflsigned)) {
$smtps->setOptions(array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true)));
}

View File

@ -309,7 +309,7 @@ MAIN_MAIL_SMTPS_ID=SMTP username or ID (if sending server requires authenticatio
MAIN_MAIL_SMTPS_PW=SMTP password or token (if sending server requires authentication)
MAIN_MAIL_EMAIL_TLS=Use TLS (SSL) encryption
MAIN_MAIL_EMAIL_STARTTLS=Use TLS (STARTTLS) encryption
MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED=Authorize self-signed certificates
MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED=Allow connection to mail servers using self-signed certificates
MAIN_MAIL_EMAIL_DKIM_ENABLED=Use DKIM to generate email signature
MAIN_MAIL_EMAIL_DKIM_DOMAIN=Email Domain for use with dkim
MAIN_MAIL_EMAIL_DKIM_SELECTOR=Name of dkim selector