Skip to content

Commit

Permalink
resolve cypht-org#868 conflits
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow243 committed Jan 31, 2024
1 parent f250347 commit a1c5d73
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 41 deletions.
6 changes: 3 additions & 3 deletions modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;' .
'};' .
Expand Down
5 changes: 4 additions & 1 deletion modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
62 changes: 25 additions & 37 deletions modules/smtp/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit a1c5d73

Please sign in to comment.