Skip to content

Commit

Permalink
Merge pull request cypht-org#1219 from Baraka24/can-not-send-mail
Browse files Browse the repository at this point in the history
[FIX]Compose page: clicking on Send button can't send email
  • Loading branch information
Shadow243 authored Sep 13, 2024
2 parents 2bf174c + 8d785e8 commit b4db07b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 44 deletions.
25 changes: 25 additions & 0 deletions modules/contacts/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,31 @@ var contact_import_pagination = function() {
});
};

var check_cc_exist_in_contacts_list = function() {
if (typeof list_emails !== "undefined") {
var compose_cc = $(".compose_cc").val().trim();
var list_cc = null;
var list_cc_not_exist_in_my_contact = [];
if (compose_cc.length > 0) {
list_cc = compose_cc.split(",");
var list_html = "<ol>";
list_cc.forEach(cc => {
cc = cc.trim().split(" ");
if (! list_emails.includes(cc.slice(-1)[0])) {
list_cc_not_exist_in_my_contact.push(cc.slice(-1)[0])
list_html += `<li>${cc.slice(-1)[0]}</li>`;
}
});
list_html += "</ol>";

if (list_cc_not_exist_in_my_contact) {
return list_html;
}
}
}
return "";
};

if (hm_page_name() == 'contacts') {
$('.delete_contact').on("click", function() {
delete_contact($(this).data('id'), $(this).data('source'), $(this).data('type'));
Expand Down
1 change: 0 additions & 1 deletion modules/core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ function setup_base_page($name, $source=false, $use_layout=true) {
add_output($name, 'header_start', false, $source);
add_output($name, 'header_css', false, $source);
add_output($name, 'header_content', false, $source);
add_handler($name, 'default_timezone', false, $source);
add_output($name, 'js_data', false, $source);
add_output($name, 'js_search_data', true, $source);
add_output($name, 'header_end', false, $source);
Expand Down
15 changes: 2 additions & 13 deletions modules/core/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,19 +569,6 @@ public function process() {
}
}

/**
* Setup the current language
* @subpackage core/handler
*/
class Hm_Handler_default_timezone extends Hm_Handler_Module {
/**
* output the default timezone
*/
public function process() {
$this->out('default_timezone', $this->user_config->get('default_setting_timezone', 'UTC'));
}
}

/**
* Setup the date
* @subpackage core/handler
Expand Down Expand Up @@ -668,6 +655,8 @@ public function process() {
$this->out('data_sources', array(), false);
$this->out('encrypt_ajax_requests', $this->config->get('encrypt_ajax_requests', false));
$this->out('encrypt_local_storage', $this->config->get('encrypt_local_storage', false));
$this->out('default_timezone', $this->user_config->get('default_setting_timezone', 'UTC'));
$this->out('enabled_modules', $this->config->get_modules());
if (!crypt_state($this->config)) {
$this->out('single_server_mode', true);
}
Expand Down
3 changes: 3 additions & 0 deletions modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@ protected function output() {
' return key;'.
'};';
$res .= 'window.hm_default_timezone = "'.$this->get('default_timezone','UTC').'";';
$res .= 'var hm_module_is_supported = function(module) {'.
' return '.json_encode($this->get('enabled_modules', array())).'.indexOf(module) !== -1;'.
'};';
$res .= '</script>';
return $res;
}
Expand Down
34 changes: 5 additions & 29 deletions modules/smtp/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,29 +419,6 @@ var force_send_message = function() {
}
}

var check_cc_exist_in_contacts_list = function(e) {
var compose_cc = $(".compose_cc").val().trim();
var list_cc = null;
var list_cc_not_exist_in_my_contact = [];
if (compose_cc.length > 0) {
list_cc = compose_cc.split(",");
var list_html = "<ol>";
list_cc.forEach(cc => {
cc = cc.trim().split(" ");
if (! list_emails.includes(cc.slice(-1)[0])) {
list_cc_not_exist_in_my_contact.push(cc.slice(-1)[0])
list_html += `<li>${cc.slice(-1)[0]}</li>`;
}
});
list_html += "</ol>";

if (list_cc_not_exist_in_my_contact) {
return list_html;
}
}
return "";
};

$(function () {
if (!hm_is_logged()) {
return;
Expand Down Expand Up @@ -510,16 +487,15 @@ $(function () {
modalContentHeadline = "Your subject and body are empty!";
}

// if contact_cc not exist in contact list for user
var checkInList = "";
if (list_emails) {
checkInList = check_cc_exist_in_contacts_list(e);
if (hm_module_is_supported('contacts')) {
var checkInList = check_cc_exist_in_contacts_list();
// if contact_cc not exist in contact list for user
if (checkInList) {
modalContentHeadline = "Adress mail not exist in your contact liste";
modalContentHeadline = "Adress mail not exist in your contact list";
showBtnSendAnywayDontWarnFuture = false;
}

}


// If the user has disabled the warning, we should send the message
if (Boolean(Hm_Utils.get_from_local_storage(dontWanValueInStorage))) {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/modules/core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function test_setup_base_page() {
$len = count($res['foo']);
$res2 = Hm_Output_Modules::dump();
$len2 = count($res2['foo']);
$this->assertEquals(13, $len);
$this->assertEquals(12, $len);
$this->assertEquals(19, $len2);
}
/**
Expand Down

0 comments on commit b4db07b

Please sign in to comment.