From 302ab362d5b3a21cae4eb2d1efd76ce5e43fbcc1 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Tue, 18 Mar 2025 17:41:37 +0100 Subject: [PATCH] Fix edit of template with back to page --- htdocs/admin/mails_templates.php | 15 ++++++++++++++- htdocs/core/lib/admin.lib.php | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 6f79d58551a..4539689568c 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -70,6 +70,7 @@ $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $mode = GETPOST('mode', 'aZ09'); $optioncss = GETPOST('optioncss', 'alpha'); +$backtopage = GETPOST('backtopage'); $contextpage = GETPOST('contextpage', 'aZ09'); $id = $rowid = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('rowid')); @@ -287,15 +288,21 @@ if ($rowid > 0) { * Actions */ -if (GETPOST('cancel', 'alpha')) { +if (GETPOST('cancel', 'alpha') || GETPOST('actioncancel', 'alpha')) { $action = 'list'; $massaction = ''; + + if (!empty($backtopage)) { + header("Location: ".$backtopage); + exit(1); + } } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $parameters = array(); +$object = null; $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -439,6 +446,11 @@ if (empty($reshook)) { if ($result) { // Add is ok setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); $_POST = array('id' => 25); // Clean $_POST array, we keep only id + + if (!empty($backtopage)) { + header("Location: ".$backtopage); + exit(1); + } } else { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); @@ -740,6 +752,7 @@ if ($action == 'create') { print ''; print ''; print ''; + print ''; print '
'; print ''; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 7d9beb89411..3159c7d297a 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1901,6 +1901,8 @@ function form_constantes($tableau, $strictw3c = 2, $helptext = '', $text = 'Valu //var_dump($arraydefaultmessage); //var_dump($arrayofmessagename); print $form->selectarray('constvalue'.(empty($strictw3c) ? '' : ($strictw3c == 3 ? '_'.$const : '[]')), $arrayofmessagename, $obj->value.':'.$tmp[1], 'None', 0, 0, '', 0, 0, 0, '', '', 1); + + print ''.img_picto('', 'add').''; } elseif (preg_match('/MAIL_FROM$/i', $const)) { print img_picto('', 'email', 'class="pictofixedwidth"').''; } else { // type = 'string' ou 'chaine'