diff --git a/modules/core/output_modules.php b/modules/core/output_modules.php index 3d698452e7..5a7612e2f2 100644 --- a/modules/core/output_modules.php +++ b/modules/core/output_modules.php @@ -595,9 +595,9 @@ protected function output() { 'window.hm_current_lang = ' . json_encode($this->lang) . ';' . 'window.hm_translations = ' . json_encode($this->all_trans()) . ';' . 'var hm_trans = function(key, lang = window.hm_current_lang) {' . - ' const translation = window.translations[lang][key];' . - ' if (translation !== undefined && translation !== false) {' . - ' return translation;' . + ' const langTranslations = window.translations && window.translations[lang];' . + ' if (langTranslations && langTranslations[key] !== undefined && langTranslations[key] !== false) {' . + ' return langTranslations[key];' . ' }' . ' return key;' . '};' . diff --git a/modules/smtp/modules.php b/modules/smtp/modules.php index 8ee7a5b16b..21415ba9c9 100644 --- a/modules/smtp/modules.php +++ b/modules/smtp/modules.php @@ -646,10 +646,13 @@ function get_mime_type($filename) class Hm_Handler_process_compose_form_submit extends Hm_Handler_Module { public function process() { /* not sending */ - if (!array_key_exists('compose_smtp_id', $this->request->post)) { + if (!array_key_exists('smtp_send', $this->request->post)) { $this->out('enable_attachment_reminder', $this->user_config->get('enable_attachment_reminder_setting', false)); return; } + if (!array_key_exists('compose_smtp_id', $this->request->post)) { + return; + } /* missing field */ list($success, $form) = $this->process_form(array('compose_to', 'compose_subject', 'compose_body', 'compose_smtp_id', 'draft_id', 'post_archive', 'next_email_post')); diff --git a/modules/smtp/site.js b/modules/smtp/site.js index 185a5e08ad..ab088b205c 100644 --- a/modules/smtp/site.js +++ b/modules/smtp/site.js @@ -516,49 +516,37 @@ $(function () { }; function handleFiles() { - var msg_uid = hm_msg_uid(); - var detail = Hm_Utils.parse_folder_path(hm_list_path(), 'imap'); - var class_name = 'imap_' + detail.server_id + '_' + msg_uid + '_' + detail.folder; - var key = 'imap_' + Hm_Utils.get_url_page_number() + '_' + hm_list_path(); - var next_message = Hm_Message_List.prev_next_links(key, class_name)[1]; - if (next_message) { - $('.compose_next_email_data').val(next_message); - } var uploaded_files = $("input[name='uploaded_files[]']").map(function () { return $(this).val(); }).get(); - $('#send_uploaded_files').val(uploaded_files); - Hm_Ajax.show_loading_icon(); $('.smtp_send').addClass('disabled_input'); - $('.smtp_send_archive').addClass('disabled_input'); - $('.smtp_send').on("click", function () { return false; }); - const compose_body_value = document.getElementById('compose_body').value; - const force_send = document.getElementById('force_send')?.value; - var reminder_value = $('.compose_form').data('reminder'); - if (reminder_value === 1) { - const uploaded_files = $("input[name='uploaded_files[]']").map(function () { return $(this).val(); }).get(); - let all_translated_keywords = []; - for (let lang in window.hm_translations) { - if (window.hm_translations.hasOwnProperty(lang)) { - // Get translated keywords for the current language - const translated_keywords = hm_trans('attachment,file,attach,attached,attaching,enclosed,CV,cover letter', lang).split(','); - // Concatenate translated keywords with the array - all_translated_keywords = all_translated_keywords.concat(translated_keywords); + const compose_body_value = document.getElementById('compose_body').value; + const force_send = document.getElementById('force_send')?.value; + var reminder_value = $('.compose_form').data('reminder'); + if (reminder_value === 1) { + let all_translated_keywords = []; + for (let lang in window.hm_translations) { + if (window.hm_translations.hasOwnProperty(lang)) { + // Get translated keywords for the current language + const translated_keywords = hm_trans('attachment,file,attach,attached,attaching,enclosed,CV,cover letter', lang).split(','); + // Concatenate translated keywords with the array + all_translated_keywords = all_translated_keywords.concat(translated_keywords); + } } - } - const additional_keywords = ['.doc', '.pdf']; - // Split the translated keywords into an array && Add additional keywords or file extensions - const combined_keywords = all_translated_keywords.concat(additional_keywords); - // Build the regex pattern - const pattern = new RegExp('(' + combined_keywords.map(keyword => keyword.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')).join('|') + ')', 'i'); - // Check if the pattern is found in the message - if (pattern.test(compose_body_value) && uploaded_files.length === 0 && force_send !== '1') { - if (confirm(trans('We couldn\'t find the attachment you referred to. Please confirm if you attached it or provide the details again.'))) { - force_send_message(); + const additional_keywords = ['.doc', '.pdf']; + // Split the translated keywords into an array && Add additional keywords or file extensions + const combined_keywords = all_translated_keywords.concat(additional_keywords); + // Build the regex pattern + const pattern = new RegExp('(' + combined_keywords.map(keyword => keyword.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')).join('|') + ')', 'i'); + // Check if the pattern is found in the message + if (pattern.test(compose_body_value) && uploaded_files.length === 0 && force_send !== '1') { + if (confirm(hm_trans('We couldn\'t find the attachment you referred to. Please confirm if you attached it or provide the details again.'))) { + force_send_message(); + } + e.preventDefault(); + } else { + process_compose_form(); } - e.preventDefault(); } else { process_compose_form(); } - } else { - process_compose_form(); } }); if ($('.compose_cc').val() || $('.compose_bcc').val()) {