From 643c05116f6bf35065b749dcb321c2609fe759aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Feb 2023 13:37:27 +0100 Subject: [PATCH] Debug v17 --- htdocs/admin/mailing.php | 6 +-- htdocs/comm/action/class/actioncomm.class.php | 4 +- htdocs/comm/mailing/card.php | 39 ++++++++++++++++--- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 19effcdfd2e..81f8210b23f 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -150,8 +150,8 @@ print ''; print ''; print $langs->trans("MailingEMailError").''; -print ''; -if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && !isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) { +print ''; +if (getDolGlobalString('MAILING_EMAIL_ERRORSTO') && !isValidEmail(getDolGlobalString('MAILING_EMAIL_ERRORSTO'))) { print ' '.img_warning($langs->trans("BadEMail")); } print ''; @@ -160,7 +160,7 @@ print ''; print ''; print $form->textwithpicto($langs->trans("MailingDelay"), $langs->trans("IfDefinedUseAValueBeetween", '0.001', '10')).''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index eae7136ac88..39c4fd50be9 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2463,7 +2463,7 @@ class ActionComm extends CommonObject } // Sender - $from = $conf->global->MAIN_MAIL_EMAIL_FROM; + $from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM'); if (empty($from)) { $errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM"; $error++; @@ -2471,7 +2471,7 @@ class ActionComm extends CommonObject if (!$error) { // Errors Recipient - $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; + $errors_to = getDolGlobalString('MAIN_MAIL_ERRORS_TO'); // Mail Creation $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', ''); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 32207425d2a..63750d5d834 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -43,18 +43,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("mails"); $id = (GETPOST('mailid', 'int') ? GETPOST('mailid', 'int') : GETPOST('id', 'int')); + $action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel'); $confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); $urlfrom = GETPOST('urlfrom'); +// Initialize technical objects $object = new Mailing($db); +$extrafields = new ExtraFields($db); $result = $object->fetch($id); -$extrafields = new ExtraFields($db); - -// fetch optionals attributes and labels +// Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -98,6 +99,32 @@ if ($reshook < 0) { } if (empty($reshook)) { + $error = 0; + + $backurlforlist = DOL_URL_ROOT.'/comm/mailing/list.php'; + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = DOL_URL_ROOT.'/comm/mailing/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); + } + } + } + + if ($cancel) { + /*var_dump($cancel);var_dump($backtopage);var_dump($backtopageforcancel);exit;*/ + if (!empty($backtopageforcancel)) { + header("Location: ".$backtopageforcancel); + exit; + } elseif (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + $action = ''; + } + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { if (!GETPOST("clone_content", 'alpha') && !GETPOST("clone_receivers", 'alpha')) { @@ -736,9 +763,9 @@ if ($action == 'create') { print ''.$langs->trans("MailTitle").''; - print ''.$langs->trans("MailFrom").''; + print ''.$langs->trans("MailFrom").''; - print ''.$langs->trans("MailErrorsTo").''; + print ''.$langs->trans("MailErrorsTo").''; // Other attributes $parameters = array();