From 2f3c8f4e40d5676038266a230ebe7f791c6b2ee7 Mon Sep 17 00:00:00 2001 From: w3houde Date: Sun, 31 May 2026 03:39:57 +0700 Subject: [PATCH] Fix #35593 use acceptLocalLinktoMedia in mailing editor (#38525) Since v21 the wysiwyg editor in comm/mailing/card.php was created with $uselocalbrowser=-1, which DolEditor maps to the hidden constant WYSIWYG_ALLOW_UPLOAD_MEDIA_FILES (default 0). The local image browser that was available before v21 disappears for any installation that does not explicitly set that constant. The email templates editor at admin/mails_templates.php solves this with the dedicated helper acceptLocalLinktoMedia() (also gated on MAIN_DISALLOW_MEDIAS_IN_EMAIL_TEMPLATES, plus an IP allowlist for private networks). The two editors are intended to behave the same way (maintainer comment on the issue thread). Mirror that pattern in the mailing page: compute $acceptlocallinktomedia once near the top and pass it as the $uselocalbrowser argument to all five DolEditor instances. The default-deny behavior for installs exposed to the internet is preserved through acceptLocalLinktoMedia()'s own checks, and an existing local install on a private network gets the image browser back without having to set the hidden WYSIWYG_ALLOW_UPLOAD_MEDIA_FILES flag. Signed-off-by: Dolicraft Co-authored-by: Dolicraft --- htdocs/comm/mailing/card.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 741c80cdfdd..36d83f091ed 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -761,6 +761,10 @@ if (empty($reshook)) { $form = new Form($db); $htmlother = new FormOther($db); +// Same check as the email templates editor in admin/mails_templates.php so the +// local media browser is shown consistently in both places. +$acceptlocallinktomedia = (acceptLocalLinktoMedia() > 0 ? 1 : 0); + $help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'; llxHeader( '', @@ -894,7 +898,7 @@ if ($action == 'create') { // aaa print '
'; // wysiwyg editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'restricthtmlallowunvalid'), '', 600, 'dolibarr_mailings', '', true, -1, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%'); + $doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'restricthtmlallowunvalid'), '', 600, 'dolibarr_mailings', '', true, $acceptlocallinktomedia, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%'); $doleditor->Create(); print '
'; @@ -1334,7 +1338,7 @@ if ($action == 'create') { // aaa $readonly = 1; // wysiwyg editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, -1, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%', $readonly); + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, $acceptlocallinktomedia, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%', $readonly); $doleditor->Create(); } else { print dol_htmlentitiesbr($object->body); @@ -1553,19 +1557,19 @@ if ($action == 'create') { // aaa if ($action == 'edit') { // wysiwyg editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, -1, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%'); + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, $acceptlocallinktomedia, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%'); $doleditor->Create(); } if ($action == 'edittxt') { // wysiwyg editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, -1, 0, 20, '100%'); + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, $acceptlocallinktomedia, 0, 20, '100%'); $doleditor->Create(); } if ($action == 'edithtml') { // HTML source editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, -1, 'ace', 20, '100%'); + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, $acceptlocallinktomedia, 'ace', 20, '100%'); $doleditor->Create(0, '', false, 'HTML Source', 'php'); }