diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 9bd745eabbe..eea1a9908de 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2024-2025 Frédéric France * Copyright (C) 2024-2025 MDW + * Copyright (C) 2026 Vincent de Grandpré * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1766,6 +1767,7 @@ class EmailCollector extends CommonObject $nbactiondone = 0; $charset = ($this->hostcharset ? $this->hostcharset : "UTF-8"); $arrayofemail = array(); + $Query = 0; if (getDolGlobalString('MAIN_IMAP_USE_PHPIMAP') && is_object($client)) { try { @@ -1779,10 +1781,13 @@ class EmailCollector extends CommonObject $f = $client->getFolders(false, $tmpsourcedir); // Note the search of directory do a search on sourcedir* if ($f) { - $folder = $f[0]; - if ($folder instanceof Webklex\PHPIMAP\Folder) { - $Query = $folder->messages()->where($criteria); // @phan-suppress-current-line PhanPluginUnknownObjectMethodCall - } else { + foreach ($f as $_f) { + if ($_f->path == $this->source_directory && $_f instanceof Webklex\PHPIMAP\Folder) { + $Query = $_f->messages()->where($criteria); // @phan-suppress-current-line PhanPluginUnknownObjectMethodCall + } + } + // @phpstan-ignore-line + if (empty($Query)) { $error++; $this->error = "Source directory ".$sourcedir." not found"; $this->errors[] = $this->error; diff --git a/htdocs/public/includes/dolibarr-js-context/dolibarr-context.mock.js b/htdocs/public/includes/dolibarr-js-context/dolibarr-context.mock.js index 65c8c32390b..f1025f74d9b 100644 --- a/htdocs/public/includes/dolibarr-js-context/dolibarr-context.mock.js +++ b/htdocs/public/includes/dolibarr-js-context/dolibarr-context.mock.js @@ -60,6 +60,15 @@ var Dolibarr = { * @returns {string} */ trans(key, ...args) {}, + + /** + * Translate a key using current locale + * Supports placeholders like %s, %d, %f (simple sprintf) + * @param {string} key + * @param {...any} args + * @returns {string} + */ + transNoEntities(key, ...args) {}, }, // You can add more standard Dolibarr tools here for IDE autocompletion. diff --git a/htdocs/public/includes/dolibarr-js-context/dolibarr-tool.langs.js b/htdocs/public/includes/dolibarr-js-context/dolibarr-tool.langs.js index becfdff5f32..9255638716f 100644 --- a/htdocs/public/includes/dolibarr-js-context/dolibarr-tool.langs.js +++ b/htdocs/public/includes/dolibarr-js-context/dolibarr-tool.langs.js @@ -220,6 +220,21 @@ document.addEventListener('Dolibarr:Init', function(e) { return sprintf(text, ...args); } + /** + * Translate a key using current locale + * Supports placeholders like %s, %d, %f (simple sprintf) + * @param {string} key + * @param {...any} args + * @returns {string} + */ + function transNoEntities(key, ...args) { + let str = trans(key, ...args); + let txt = document.createElement('textarea'); + txt.innerHTML = str; + return txt.value; + } + + function sprintf(fmt, ...args) { let i = 0; return fmt.replace(/%[%bcdeEfFgGosuxX]/g, (match) => { @@ -246,6 +261,7 @@ document.addEventListener('Dolibarr:Init', function(e) { clearCache, setLocale, trans, + transNoEntities, get currentLocale() { return currentLocale; } }; };