Show sending mode on emailing file

This commit is contained in:
Laurent Destailleur 2023-04-23 21:42:05 +02:00
parent 67c67bbf2e
commit 73539162ff
5 changed files with 99 additions and 16 deletions

View File

@ -59,6 +59,16 @@ $substitutionarrayfortest = array(
);
complete_substitutions_array($substitutionarrayfortest, $langs);
// List of sending methods
$listofmethods = array();
$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
$listofmethods['mail'] = 'PHP mail function';
//$listofmethods['simplemail']='Simplemail class';
$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
// Security check
if (!$user->admin) {
accessforbidden();
@ -147,16 +157,6 @@ print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
$head = email_admin_prepare_head();
// List of sending methods
$listofmethods = array();
$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
$listofmethods['mail'] = 'PHP mail function';
//$listofmethods['simplemail']='Simplemail class';
$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
// List of oauth services
$oauthservices = array();

View File

@ -77,8 +77,13 @@ $object->substitutionarrayfortest = $substitutionarray;
// List of sending methods
$listofmethods = array();
//$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
$listofmethods['mail'] = 'PHP mail function';
//$listofmethods['simplemail']='Simplemail class';
$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
// Security check
if (empty($user->rights->mailing->lire) || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) {
@ -1005,6 +1010,26 @@ if ($action == 'create') {
}
print '</td></tr>';
print '<tr><td>';
print $langs->trans("MAIN_MAIL_SENDMODE");
print '</td><td>';
if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
$text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')];
} elseif (getDolGlobalString('MAIN_MAIL_SENDMODE')) {
$text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE')];
} else {
$text = $listofmethods['mail'];
}
print $text;
if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'mail') {
print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER_EMAILING').')</span>';
}
} elseif (getDolGlobalString('MAIN_MAIL_SENDMODE') != 'mail' && getDolGlobalString('MAIN_MAIL_SMTP_SERVER')) {
print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>';
}
print '</td></tr>';
// Other attributes. Fields from hook formObjectOptions and Extrafields.
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
@ -1237,9 +1262,9 @@ if ($action == 'create') {
*/
// From
print '<tr><td class="titlefield">'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans("MailFrom").'</td><td>'.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'</td></tr>';
// To
print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td colspan="3">'.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).'</td></tr>';
print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>'.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).'</td></tr>';
print '</table>';
print '</div>';
@ -1253,7 +1278,7 @@ if ($action == 'create') {
// Number of distinct emails
print '<tr><td>';
print $langs->trans("TotalNbOfDistinctRecipients");
print '</td><td colspan="3">';
print '</td><td>';
$nbemail = ($object->nbemail ? $object->nbemail : 0);
if (is_numeric($nbemail)) {
$text = '';
@ -1275,6 +1300,27 @@ if ($action == 'create') {
}
print '</td></tr>';
print '<tr><td>';
print $langs->trans("MAIN_MAIL_SENDMODE");
print '</td><td>';
if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
$text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')];
} elseif (getDolGlobalString('MAIN_MAIL_SENDMODE')) {
$text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE')];
} else {
$text = $listofmethods['mail'];
}
print $text;
if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'mail') {
print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER_EMAILING').')</span>';
}
} elseif (getDolGlobalString('MAIN_MAIL_SENDMODE') != 'mail' && getDolGlobalString('MAIN_MAIL_SMTP_SERVER')) {
print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>';
}
print '</td></tr>';
// Other attributes
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook

View File

@ -73,14 +73,24 @@ $result = $object->fetch($id);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('ciblescard', 'globalcard'));
$sqlmessage = '';
// List of sending methods
$listofmethods = array();
//$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
$listofmethods['mail'] = 'PHP mail function';
//$listofmethods['simplemail']='Simplemail class';
$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
// Security check
if (!$user->hasRight('mailing', 'lire') || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) {
accessforbidden();
}
//$result = restrictedArea($user, 'mailing');
$sqlmessage = '';
/*
* Actions
@ -354,6 +364,26 @@ if ($object->fetch($id) >= 0) {
}
print '</td></tr>';
print '<tr><td>';
print $langs->trans("MAIN_MAIL_SENDMODE");
print '</td><td>';
if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
$text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')];
} elseif (getDolGlobalString('MAIN_MAIL_SENDMODE')) {
$text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE')];
} else {
$text = $listofmethods['mail'];
}
print $text;
if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'mail') {
print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER_EMAILING').')</span>';
}
} elseif (getDolGlobalString('MAIN_MAIL_SENDMODE') != 'mail' && getDolGlobalString('MAIN_MAIL_SMTP_SERVER')) {
print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>';
}
print '</td></tr>';
// Other attributes. Fields from hook formObjectOptions and Extrafields.
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';

View File

@ -195,7 +195,6 @@ class Mailing extends CommonObject
*/
public $substitutionarrayfortest;
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
const STATUS_SENTPARTIALY = 2;
@ -209,6 +208,8 @@ class Mailing extends CommonObject
*/
public function __construct($db)
{
global $langs;
$this->db = $db;
// List of language codes for status

View File

@ -80,6 +80,12 @@ class FactureRec extends CommonInvoice
*/
public $title;
/**
* @var string The label of recurring invoice
* @deprecated Use $title instead
*/
public $titre;
public $socid;
public $number;
public $date;