Oauth ui for tickets and emailing
This commit is contained in:
parent
e5937ef742
commit
0188629cf6
@ -261,9 +261,9 @@ if ($action == 'edit') {
|
||||
jQuery("#MAIN_MAIL_SMTP_SERVER").show();
|
||||
jQuery("#MAIN_MAIL_SMTP_PORT").show();
|
||||
jQuery("#smtp_server_mess").hide();
|
||||
jQuery("#smtp_port_mess").hide();
|
||||
jQuery("#smtp_port_mess").hide();
|
||||
jQuery(".smtp_method").show();
|
||||
jQuery(".dkim").hide();
|
||||
jQuery(".dkim").hide();
|
||||
jQuery(".smtp_auth_method").show();
|
||||
}
|
||||
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
|
||||
@ -290,9 +290,9 @@ if ($action == 'edit') {
|
||||
jQuery("#MAIN_MAIL_SMTP_PORT").show();
|
||||
jQuery("#smtp_server_mess").hide();
|
||||
jQuery("#smtp_port_mess").hide();
|
||||
jQuery(".smtp_method").show();
|
||||
jQuery(".smtp_method").show();
|
||||
jQuery(".dkim").show();
|
||||
jQuery(".smtp_auth_method").show();
|
||||
jQuery(".smtp_auth_method").show();
|
||||
}
|
||||
}
|
||||
function change_smtp_auth_method() {
|
||||
|
||||
@ -71,7 +71,15 @@ if ($action == 'update' && !$cancel) {
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_EMAILING", GETPOST("MAIN_MAIL_SMTP_SERVER_EMAILING"), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_EMAILING", GETPOST("MAIN_MAIL_SMTPS_ID_EMAILING"), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_EMAILING", GETPOST("MAIN_MAIL_SMTPS_PW_EMAILING"), 'chaine', 0, '', $conf->entity);
|
||||
if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW_EMAILING")) {
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_EMAILING", GETPOST("MAIN_MAIL_SMTPS_PW_EMAILING", 'none'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING")) {
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING", 'chaine'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING")) {
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING", 'chaine'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_TLS_EMAILING"), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_EMAILING"), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING"), 'chaine', 0, '', $conf->entity);
|
||||
@ -145,6 +153,24 @@ if (version_compare(phpversion(), '7.0', '>=')) {
|
||||
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
|
||||
}
|
||||
|
||||
// List of oauth services
|
||||
$oauthservices = array();
|
||||
|
||||
foreach ($conf->global as $key => $val) {
|
||||
if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
|
||||
$key = preg_replace('/^OAUTH_/', '', $key);
|
||||
$key = preg_replace('/_ID$/', '', $key);
|
||||
if (preg_match('/^.*-/', $key)) {
|
||||
$name = preg_replace('/^.*-/', '', $key);
|
||||
} else {
|
||||
$name = $langs->trans("NoName");
|
||||
}
|
||||
$provider = preg_replace('/-.*$/', '', $key);
|
||||
$provider = ucfirst(strtolower($provider));
|
||||
|
||||
$oauthservices[$key] = $name." (".$provider.")";
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'edit') {
|
||||
if ($conf->use_javascript_ajax) {
|
||||
@ -170,6 +196,8 @@ if ($action == 'edit') {
|
||||
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").prop("disabled", true);
|
||||
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
|
||||
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").prop("disabled", true);
|
||||
jQuery(".smtp_method").hide();
|
||||
jQuery(".smtp_auth_method").hide();
|
||||
';
|
||||
if ($linuxlike) {
|
||||
print '
|
||||
@ -201,9 +229,11 @@ 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_server_mess").hide();
|
||||
jQuery("#smtp_port_mess").hide();
|
||||
}
|
||||
jQuery(".smtp_method").show();
|
||||
jQuery(".smtp_auth_method").show();
|
||||
}
|
||||
if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\')
|
||||
{
|
||||
jQuery(".drag").show();
|
||||
@ -219,12 +249,35 @@ 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();
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
initfields();
|
||||
jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
|
||||
change_smtp_auth_method();
|
||||
jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
|
||||
initfields();
|
||||
});
|
||||
change_smtp_auth_method();
|
||||
});
|
||||
jQuery("#radio_pw, #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);
|
||||
@ -237,7 +290,7 @@ if ($action == 'edit') {
|
||||
else
|
||||
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
|
||||
});
|
||||
})';
|
||||
})';
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
@ -354,10 +407,28 @@ if ($action == 'edit') {
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// OAUTH
|
||||
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
|
||||
print '<tr class="oddeven smtp_auth_method hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>';
|
||||
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
|
||||
print '<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="LOGIN"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING') == 'LOGIN' ? ' checked' : '').'> ';
|
||||
print '<label for="radio_pw" >'.$langs->trans("UsePassword").'</label>';
|
||||
print ' ';
|
||||
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 {
|
||||
$value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING', 'LOGIN');
|
||||
$htmltext = $langs->trans("ContactSuperAdminForChange");
|
||||
print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING"), $htmltext, 1, 'superadmin');
|
||||
print '<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="'.$value.'">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// PW
|
||||
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
|
||||
$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING : '');
|
||||
print '<tr class="drag drop oddeven hideifdefault"><td>' . $langs->trans("MAIN_MAIL_SMTPS_PW") . '</td><td>';
|
||||
print '<tr class="drag drop oddeven smtp_pw hideifdefault"><td>' . $langs->trans("MAIN_MAIL_SMTPS_PW") . '</td><td>';
|
||||
// SuperAdministrator access only
|
||||
if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
|
||||
print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="' . $mainsmtppw . '">';
|
||||
@ -369,6 +440,26 @@ if ($action == 'edit') {
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// OAUTH service provider
|
||||
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
|
||||
print '<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>';
|
||||
|
||||
// SuperAdministrator access only
|
||||
if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
|
||||
print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING);
|
||||
} else {
|
||||
$text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING];
|
||||
if (empty($text)) {
|
||||
$text = $langs->trans("Undefined");
|
||||
}
|
||||
$htmltext = $langs->trans("ContactSuperAdminForChange");
|
||||
print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
|
||||
print '<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING" value="'.$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING.'">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// TLS
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
|
||||
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
|
||||
@ -458,11 +549,28 @@ if ($action == 'edit') {
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.getDolGlobalString('MAIN_MAIL_SMTPS_ID_EMAILING').'</td></tr>';
|
||||
}
|
||||
|
||||
// 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") : '') ;
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING").'</td><td>'.$text.'</td></tr>';
|
||||
}
|
||||
|
||||
// SMTPS PW
|
||||
if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) {
|
||||
if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') != "XOAUTH2") {
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW_EMAILING')).'</td></tr>';
|
||||
}
|
||||
|
||||
// SMTPS oauth service
|
||||
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING') === "XOAUTH2") {
|
||||
$text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING];
|
||||
if (empty($text)) {
|
||||
$text = $langs->trans("Undefined").img_warning();
|
||||
}
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING").'</td><td>'.$text.'</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// TLS
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
|
||||
if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) {
|
||||
|
||||
@ -66,8 +66,15 @@ if ($action == 'update' && !$cancel) {
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_TICKET", GETPOST("MAIN_MAIL_SMTP_SERVER_TICKET"), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_TICKET", GETPOST("MAIN_MAIL_SMTPS_ID_TICKET"), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_TICKET", GETPOST("MAIN_MAIL_SMTPS_PW_TICKET"), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_TLS_TICKET"), 'chaine', 0, '', $conf->entity);
|
||||
if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW_TICKET")) {
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_TICKET", GETPOST("MAIN_MAIL_SMTPS_PW_TICKET", 'none'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET")) {
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET", 'chaine'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET")) {
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET", 'chaine'), 'chaine', 0, '', $conf->entity);
|
||||
}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);
|
||||
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
|
||||
@ -139,6 +146,25 @@ if (version_compare(phpversion(), '7.0', '>=')) {
|
||||
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
|
||||
}
|
||||
|
||||
// List of oauth services
|
||||
$oauthservices = array();
|
||||
|
||||
foreach ($conf->global as $key => $val) {
|
||||
if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
|
||||
$key = preg_replace('/^OAUTH_/', '', $key);
|
||||
$key = preg_replace('/_ID$/', '', $key);
|
||||
if (preg_match('/^.*-/', $key)) {
|
||||
$name = preg_replace('/^.*-/', '', $key);
|
||||
} else {
|
||||
$name = $langs->trans("NoName");
|
||||
}
|
||||
$provider = preg_replace('/-.*$/', '', $key);
|
||||
$provider = ucfirst(strtolower($provider));
|
||||
|
||||
$oauthservices[$key] = $name." (".$provider.")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'edit') {
|
||||
if ($conf->use_javascript_ajax) {
|
||||
@ -162,6 +188,8 @@ if ($action == 'edit') {
|
||||
jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true);
|
||||
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
|
||||
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true);
|
||||
jQuery(".smtp_method").hide();
|
||||
jQuery(".smtp_auth_method").hide();
|
||||
';
|
||||
if ($linuxlike) {
|
||||
print '
|
||||
@ -192,7 +220,9 @@ if ($action == 'edit') {
|
||||
jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
|
||||
jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
|
||||
jQuery("#smtp_server_mess").hide();
|
||||
jQuery("#smtp_port_mess").hide();
|
||||
jQuery("#smtp_port_mess").hide();
|
||||
jQuery(".smtp_method").show();
|
||||
jQuery(".smtp_auth_method").show();
|
||||
}
|
||||
if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\')
|
||||
{
|
||||
@ -207,12 +237,37 @@ if ($action == 'edit') {
|
||||
jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
|
||||
jQuery("#smtp_server_mess").hide();
|
||||
jQuery("#smtp_port_mess").hide();
|
||||
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_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();
|
||||
}
|
||||
}
|
||||
initfields();
|
||||
change_smtp_auth_method();
|
||||
|
||||
jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() {
|
||||
initfields();
|
||||
change_smtp_auth_method();
|
||||
|
||||
});
|
||||
jQuery("#radio_pw, #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);
|
||||
@ -333,10 +388,29 @@ if ($action == 'edit') {
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// OAUTH
|
||||
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
|
||||
print '<tr class="oddeven smtp_auth_method hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>';
|
||||
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
|
||||
print '<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="LOGIN"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') == 'LOGIN' ? ' checked' : '').'> ';
|
||||
print '<label for="radio_pw" >'.$langs->trans("UsePassword").'</label>';
|
||||
print ' ';
|
||||
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 {
|
||||
$value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN');
|
||||
$htmltext = $langs->trans("ContactSuperAdminForChange");
|
||||
print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET"), $htmltext, 1, 'superadmin');
|
||||
print '<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="'.$value.'">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// PW
|
||||
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
|
||||
$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET : '');
|
||||
print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>';
|
||||
print '<tr class="drag drop oddeven smtp_pw hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>';
|
||||
// SuperAdministrator access only
|
||||
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
|
||||
print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.'">';
|
||||
@ -348,6 +422,24 @@ if ($action == 'edit') {
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// OAUTH service provider
|
||||
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
|
||||
print '<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>';
|
||||
// SuperAdministrator access only
|
||||
if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
|
||||
print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET);
|
||||
} else {
|
||||
$text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET];
|
||||
if (empty($text)) {
|
||||
$text = $langs->trans("Undefined");
|
||||
}
|
||||
$htmltext = $langs->trans("ContactSuperAdminForChange");
|
||||
print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
|
||||
print '<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET" value="'.$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET.'">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// TLS
|
||||
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
|
||||
@ -425,11 +517,27 @@ if ($action == 'edit') {
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID_TICKET.'</td></tr>';
|
||||
}
|
||||
|
||||
// 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") : '') ;
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET").'</td><td>'.$text.'</td></tr>';
|
||||
}
|
||||
|
||||
// SMTPS PW
|
||||
if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
|
||||
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>';
|
||||
}
|
||||
|
||||
// SMTPS oauth service
|
||||
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') === "XOAUTH2") {
|
||||
$text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET];
|
||||
if (empty($text)) {
|
||||
$text = $langs->trans("Undefined").img_warning();
|
||||
}
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET").'</td><td>'.$text.'</td></tr>';
|
||||
}
|
||||
|
||||
// TLS
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
|
||||
if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
|
||||
|
||||
@ -691,11 +691,11 @@ class CMailFile
|
||||
}
|
||||
|
||||
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER';
|
||||
$keyforsmtpauthtype = "MAIN_MAIL_SMTPS_AUTH_TYPE";
|
||||
$keyforsmtpoauthservice = "MAIN_MAIL_SMTPS_OAUTH_SERVICE";
|
||||
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT';
|
||||
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID';
|
||||
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW';
|
||||
$keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE';
|
||||
$keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE';
|
||||
$keyfortls = 'MAIN_MAIL_EMAIL_TLS';
|
||||
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS';
|
||||
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED';
|
||||
@ -708,6 +708,8 @@ class CMailFile
|
||||
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey;
|
||||
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey;
|
||||
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey;
|
||||
$keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE_'.$smtpContextKey;
|
||||
$keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE_'.$smtpContextKey;
|
||||
$keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey;
|
||||
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey;
|
||||
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user