Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master(fixes) to 2.x #1192

Merged
merged 19 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
174d6a2
Like Gmail, warn if you are about to reply to a new contact (and perh…
christer77 Jun 5, 2024
0977e5d
[FIX] ensure the email address part is the only value captured when a…
mercihabam Aug 13, 2024
652e144
fix conversion from numeric to string IDs - special_imap_folders clea…
kroky Aug 16, 2024
bfeb479
[FIX]Site Settings/General/:Warn for Unsaved Changes parameter once s…
Baraka24 Aug 18, 2024
79fd6ed
Update Cypht Docker version
Shadow243 Aug 19, 2024
e70db0e
Merge pull request #1180 from Shadow243/update-cypht-docker-to-2-2-0
marclaporte Aug 19, 2024
22da66e
Merge pull request #1166 from jacob-js/fix-external-res
Shadow243 Aug 20, 2024
b7e2ffd
Autocrypt messages encrept automatically
David-Muhasa Aug 20, 2024
bd8a404
Define constant for theme path
Shadow243 Aug 20, 2024
bc9177b
Merge pull request #1183 from David-Muhasa/encrypt-auto
kroky Aug 21, 2024
4dcfe7a
Merge pull request #1185 from Shadow243/themes-css-path-incorrect-in-…
kroky Aug 21, 2024
61d6408
[Fix] Add error message for a missing database connexion
GedeonTS Aug 21, 2024
0992ff0
[EHN]Email filtering: Cypht Sieve filters: Better handling of 'Stop p…
christer77 Jun 22, 2024
65be5be
Merge pull request #1188 from GedeonTS/db-connexion-alert
Shadow243 Aug 22, 2024
92cb940
[FIX]Profiles: Fixing undefined array key rmk on Profiles page
Baraka24 Aug 22, 2024
89cde3f
Merge pull request #1190 from Baraka24/fix-undefined-array_key-rmk
Shadow243 Aug 22, 2024
2827438
Merge pull request #1065 from christer77/Like-Gmail-warn-if-you-are-a…
Shadow243 Aug 22, 2024
25707d6
Merge pull request #1179 from Baraka24/warn_for_unsaved_changes-once-…
Shadow243 Aug 22, 2024
35991c9
Merge branch 'master' into merge-master-2-x
Shadow243 Aug 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
- MYSQL_USER=cypht
- MYSQL_PASSWORD=cypht_password
cypht:
image: cypht/cypht:2.1.0
image: cypht/cypht:2.2.0
ports:
- "80:80"
# env_file:
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
define('VENDOR_PATH', APP_PATH.'vendor/');
define('CONFIG_PATH', APP_PATH.'config/');
define('WEB_ROOT', '');
define('ASSETS_THEMES_ROOT', APP_PATH.'site/');
define('DEBUG_MODE', true);
define('CACHE_ID', '');
define('SITE_ID', '');
Expand Down
1 change: 1 addition & 0 deletions lib/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ static public function connect($site_config) {
return self::$dbh[$key];
} catch (Exception $oops) {
Hm_Debug::add($oops->getMessage());
Hm_Msgs::add('ERRUnable to connect to the database. Please check your configuration settings and try again.');
self::$dbh[$key] = false;
return false;
}
Expand Down
52 changes: 52 additions & 0 deletions modules/contacts/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public function process() {
}
$this->out('contact_page', $page);
$this->out('contact_store', $contacts, false);
$this->out('enable_warn_contacts_cc_not_exist_in_list_contact', $this->user_config->get('enable_warn_contacts_cc_not_exist_in_list_contact_setting', false));

}
}

Expand Down Expand Up @@ -429,6 +431,56 @@ protected function output() {
}
}

/**
* @subpackage contacts/output
*/
class Hm_Output_load_contact_mails extends Hm_Output_Module {
protected function output() {
if (!$this->get("enable_warn_contacts_cc_not_exist_in_list_contact")) {
return "";
}
$contact_store = $this->get('contact_store');
$emails = [];
foreach ($contact_store->dump() as $contact) {
$email = $contact->value('email_address');
if ($email) {
$emails[] = $email;
}
}
$emails = json_encode($emails);
return "<script>var list_emails = $emails; </script>";
}
}

/**
* @subpackage contacts/output
*/
class Hm_Output_enable_warn_contacts_cc_not_exist_in_list_contact extends Hm_Output_Module {
protected function output() {
$settings = $this->get('user_settings');
if (array_key_exists('enable_warn_contacts_cc_not_exist_in_list_contact', $settings) && $settings['enable_warn_contacts_cc_not_exist_in_list_contact']) {
$checked = ' checked="checked"';
$reset = '<span class="tooltip_restore" restore_aria_label="Restore default value"><i class="bi bi-arrow-counterclockwise fs-6 cursor-pointer refresh_list reset_default_value_checkbox"></i></span>';
}
else {
$checked = '';
$reset='';
}
return '<tr class="general_setting"><td><label class="form-check-label" for="enable_warn_contacts_cc_not_exist_in_list_contact">'.
$this->trans('Enable warn if contacts Cc not exist in list contact').'</label></td>'.
'<td><input class="form-check-input" type="checkbox" '.$checked.
' value="1" id="enable_warn_contacts_cc_not_exist_in_list_contact" name="enable_warn_contacts_cc_not_exist_in_list_contact" />'.$reset.'</td></tr>';
}
}

class Hm_Handler_process_enable_warn_contacts_cc_not_exist_in_list_contact extends Hm_Handler_Module {
public function process() {
function enable_warn_contacts_cc_not_exist_in_list_contact_callback($val) { return $val; }
process_site_setting('enable_warn_contacts_cc_not_exist_in_list_contact', $this, 'enable_warn_contacts_cc_not_exist_in_list_contact_callback', false, true);
}
}


/**
* @subpackage contacts/functions
*/
Expand Down
9 changes: 8 additions & 1 deletion modules/contacts/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
add_handler('export_contact', 'process_export_contacts', true, 'contacts', 'load_contacts', 'after');
add_handler('settings', 'process_contact_auto_collect_setting', true, 'contacts', 'date', 'after');

add_output('compose', 'load_contact_mails', true, 'contacts', 'compose_form_end', 'after');

add_handler('settings', 'process_enable_warn_contacts_cc_not_exist_in_list_contact', true, 'contacts', 'save_user_settings', 'before');
add_output('settings', 'enable_warn_contacts_cc_not_exist_in_list_contact', true, 'contacts', 'start_general_settings', 'after');

return array(
'allowed_pages' => array(
'contacts',
Expand Down Expand Up @@ -75,7 +80,9 @@
'add_contact' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'contact_source' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'contact_type' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'contact_auto_collect' => FILTER_VALIDATE_BOOLEAN
'contact_auto_collect' => FILTER_VALIDATE_BOOLEAN,
'enable_warn_contacts_cc_not_exist_in_list_contact' => FILTER_VALIDATE_INT

),
'allowed_get' => array(
'contact_id' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
Expand Down
5 changes: 2 additions & 3 deletions modules/contacts/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ var add_contact_from_popup = function(event) {


if (contact) {
var emailRegex = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
var email = contact.match(emailRegex)[0];
var name = contact.replace(emailRegex, "");
var email = contact.match(EMAIL_REGEX)[0];
var name = contact.replace(EMAIL_REGEX, "");

var saveContactContent = `<div><table>
<tr><td><strong>${hm_trans('Name')} :</strong></td><td>${name}</td></tr>
Expand Down
2 changes: 1 addition & 1 deletion modules/core/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ public function process() {
function warn_for_unsaved_changes_callback($val) {
return $val;
}
process_site_setting('warn_for_unsaved_changes', $this, 'warn_for_unsaved_changes_callback');
process_site_setting('warn_for_unsaved_changes', $this, 'warn_for_unsaved_changes_callback', false, true);
}
}

Expand Down
10 changes: 9 additions & 1 deletion modules/core/site.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
'use strict';

// Constants. To be used anywhere in the app via the window object.
const globalVars = {
EMAIL_REGEX: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,
}
Object.keys(globalVars).forEach(key => {
window[key] = globalVars[key];
});

/* extend cash.js with some useful bits */
$.inArray = function(item, list) {
for (var i in list) {
Expand Down Expand Up @@ -2644,7 +2652,7 @@ const handleExternalResources = (inline) => {
const messageContainer = document.querySelector('.msg_text_inner');
messageContainer.insertAdjacentHTML('afterbegin', '<div class="external_notices"></div>');

const sender = document.querySelector('#contact_info').textContent.trim().replace(/\s/g, '_') + 'external_resources_allowed';
const sender = document.querySelector('#contact_info').textContent.match(EMAIL_REGEX)[0] + '_external_resources_allowed';
const elements = messageContainer.querySelectorAll('[data-src]');
const blockedResources = [];
elements.forEach(function (element) {
Expand Down
7 changes: 5 additions & 2 deletions modules/pgp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,23 @@ protected function output() {
}
$pub_keys = $this->get('pgp_public_keys', array());
$res = '<script type="text/javascript" src="'.WEB_ROOT.'modules/pgp/assets/openpgp.min.js"></script>';
$res .= '<div class="container">';
$res .= '<div class="row justify-content-md-center">';
$res .= '<div class="col col-lg-8">';
$res .= '<div class="pgp_section">';

$res .= '<span class="pgp_sign"><label for="pgp_sign" class="form-label">'.$this->trans('PGP Sign as').'</label>';
$res .= '<select id="pgp_sign" size="1" class="form-control"></select></span>';

if (count($pub_keys) > 0) {
$res .= '<label for="pgp_encrypt" class="form-label">'.$this->trans('PGP Encrypt for').
$res .= '<label for="pgp_encrypt" class="form-label" style="margin-top:1rem">'.$this->trans('PGP Encrypt for').
'</label><select id="pgp_encrypt" size="1" class="form-control"><option disabled selected value=""></option>';
foreach ($pub_keys as $vals) {
$res .= '<option value="'.$vals['key'].'">'.$vals['email'].'</option>';
}
$res .= '</select>';
}
$res .= '<input type="button" class="pgp_apply" value="'.$this->trans('Apply').'" class="btn btn-primary" /></div>'.prompt_for_passhrase($this);
$res .= '</di></di></di></di>';
return $res;
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/pgp/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ $(function() {
if (($('#pgp_encrypt option').length + $('#pgp_sign option').length) == 0) {
$('.pgp_section').hide();
}
$('.pgp_apply').on("click", function() { Hm_Pgp.process_settings(); return false; });
$('.smtp_send_placeholder').on("click", function() { Hm_Pgp.process_settings(); return false; });
}
else if (hm_page_name() == 'message') {
Hm_Ajax.add_callback_hook('ajax_imap_message_content', Hm_Pgp.check_pgp_msg);
Expand Down
3 changes: 2 additions & 1 deletion modules/profiles/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
if (!defined('DEBUG_MODE')) { die(); }

if (!hm_exists('add_profile')) {
function add_profile($name, $signature, $reply_to, $is_default, $email, $server_mail, $smtp_server_id, $imap_server_id, $context) {
function add_profile($name, $signature, $reply_to, $is_default, $email, $server_mail, $smtp_server_id, $imap_server_id, $context, $remark = '') {
$profile = array(
'name' => $name,
'sig' => $signature,
'rmk' => $remark,
'smtp_id' => $smtp_server_id,
'replyto' => $reply_to,
'default' => $is_default,
Expand Down
9 changes: 9 additions & 0 deletions modules/sievefilters/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ function get_classic_filter_modal_content()
</table>
</div>
</div>
<hr/>
<div class="p-3">
<div class="d-flex">
<div class="col-sm-10">
<input type="checkbox" id="stop_filtering"/>
<label for="stop_filtering" class="form-label">Stop filtering</label>
</div>
</div>
</div>
</div>
</div>';
}
Expand Down
41 changes: 26 additions & 15 deletions modules/sievefilters/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ var hm_sieve_possible_actions = function() {
type: 'none',
extra_field: false
},
{
name: 'stop',
description: 'Stop Filtering',
type: 'none',
extra_field: false
},
{
name: 'copy',
description: 'Copy email to mailbox',
Expand Down Expand Up @@ -463,6 +457,16 @@ $(function () {
idx = idx + 1;
});

if ($('#stop_filtering').is(':checked')) {
actions_parsed.push(
{
'action': "stop",
'value': "",
'extra_option': "",
'extra_option_value': "",
}
)
}
if ($('.modal_sieve_filter_name').val() == "") {
Hm_Utils.add_sys_message(hm_trans('Filter name is required'), 'danger');
return false;
Expand Down Expand Up @@ -530,6 +534,9 @@ $(function () {
});
$('.add_filter').on('click', function () {
edit_filter_modal.setTitle('Add Filter');
$('.modal_sieve_filter_priority').val('');
$('.modal_sieve_filter_test').val('ALLOF');
$('#stop_filtering').prop('checked', false);
current_account = $(this).attr('account');
edit_filter_modal.open();

Expand Down Expand Up @@ -661,7 +668,6 @@ $(function () {
}
possible_actions_html += '<option value="'+value.name+'">' + value.description + '</option>';
});

let extra_options = '<td class="col-sm-3"><input type="hidden" class="condition_extra_action_value form-control form-control-sm" name="sieve_selected_extra_action_value[]" /></td>';
$('.filter_actions_modal_table').append(
'<tr class="border" default_value="'+default_value+'">' +
Expand Down Expand Up @@ -918,6 +924,7 @@ $(function () {
is_editing_filter = true;
current_editing_filter_name = $(this).attr('script_name');
current_account = $(this).attr('imap_account');
// $('#stop_filtering').prop('checked', false);
$('.modal_sieve_filter_name').val($(this).attr('script_name_parsed'));
$('.modal_sieve_filter_priority').val($(this).attr('priority'));
$('.sieve_list_conditions_modal').html('');
Expand All @@ -943,14 +950,18 @@ $(function () {
});

actions.forEach(function (action) {
add_filter_action(action.value);
$(".sieve_actions_select").last().val(action.action);
$(".sieve_actions_select").last().trigger('change');
$("[name^=sieve_selected_extra_action_value]").last().val(action.extra_option_value);
if ($("[name^=sieve_selected_action_value]").last().is('input')) {
$("[name^=sieve_selected_action_value]").last().val(action.value);
} else if ($("[name^=sieve_selected_action_value]").last().is('textarea')) {
$("[name^=sieve_selected_action_value]").last().text(action.value);
if (action.action === "stop") {
$('#stop_filtering').prop('checked', true);
} else {
add_filter_action(action.value);
$(".sieve_actions_select").last().val(action.action);
$(".sieve_actions_select").last().trigger('change');
$("[name^=sieve_selected_extra_action_value]").last().val(action.extra_option_value);
if ($("[name^=sieve_selected_action_value]").last().is('input')) {
$("[name^=sieve_selected_action_value]").last().val(action.value);
} else if ($("[name^=sieve_selected_action_value]").last().is('textarea')) {
$("[name^=sieve_selected_action_value]").last().text(action.value);
}
}
});
}
Expand Down
18 changes: 14 additions & 4 deletions modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -966,15 +966,25 @@ protected function output() {
}
}

/**
* @subpackage smtp/output
*/
class Hm_Output_compose_title extends Hm_Output_Module {
protected function output() {
return'<div class="content_title px-3">'.$this->trans('Compose').'</div>';
}
}

/**
* @subpackage smtp/output
*/
class Hm_Output_compose_form_start extends Hm_Output_Module {
protected function output() {
return'<div class="compose_page p-0"><div class="content_title px-3">'.$this->trans('Compose').'</div>'.
'<div class="container"><div class="row justify-content-md-center">'.
'<div class="col col-lg-8">'.
'<form class="compose_form p-4" method="post" action="?page=compose" data-reminder="' . $this->get('enable_attachment_reminder', 0) . '">';
$res = '<div class="container">';
$res .= '<div class="row justify-content-md-center">';
$res .= '<div class="col col-lg-8">';
$res .= '<form class="compose_form p-4" method="post" action="?page=compose" data-reminder="' . $this->get('enable_attachment_reminder', 0) . '">';
return $res;
}
}

Expand Down
3 changes: 2 additions & 1 deletion modules/smtp/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
add_handler('compose', 'load_smtp_servers_from_config', true, 'smtp', 'load_smtp_reply_to_details', 'after');
add_handler('compose', 'add_smtp_servers_to_page_data', true, 'smtp', 'load_smtp_servers_from_config', 'after');
add_handler('compose', 'process_compose_form_submit', true, 'smtp', 'load_smtp_servers_from_config', 'after');
add_output('compose', 'compose_form_start', true, 'smtp', 'content_section_start', 'after');
add_output('compose', 'compose_title', true, 'smtp', 'content_section_start', 'after');
add_output('compose', 'compose_form_start', true, 'smtp', 'compose_title', 'after');
add_output('compose', 'compose_form_draft_list', true, 'smtp', 'compose_form_start', 'before');
add_output('compose', 'compose_form_content', true, 'smtp', 'compose_form_start', 'after');
add_output('compose', 'compose_form_end', true, 'smtp', 'compose_form_content', 'after');
Expand Down
Loading