Skip to content

Commit

Permalink
Should be off by default | Address the controversial part in read rec…
Browse files Browse the repository at this point in the history
…eipts
  • Loading branch information
Shadow243 committed Aug 20, 2024
1 parent 8b0ed3a commit f2890b9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
41 changes: 37 additions & 4 deletions modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ public function process() {
}

$this->out('uploaded_files', get_uploaded_files($draft_id, $this->session));
$compose_type = $this->user_config->get('smtp_compose_type_setting', 0);
$settings = $this->user_config;
$compose_type = $settings->get('smtp_compose_type_setting', 0);
if ($this->get('is_mobile', false)) {
$compose_type = 0;
}
Expand All @@ -407,6 +408,7 @@ public function process() {
$this->out('compose_draft', $draft);
}
$this->out('smtp_compose_type', $compose_type);
$this->out('user_settings', $settings);
}
}

Expand Down Expand Up @@ -726,7 +728,7 @@ public function process() {
/* msg details */
list($body, $cc, $bcc, $in_reply_to, $draft) = get_outbound_msg_detail($this->request->post, $draft, $body_type);

if (!empty($this->request->post['compose_delivery_receipt'])) {
if ($this->user_config->get('enable_compose_delivery_receipt_setting', false) && !empty($this->request->post['compose_delivery_receipt'])) {
$from_params = 'RET=HDRS';
$recipients_params = 'NOTIFY=SUCCESS,FAILURE';
}
Expand Down Expand Up @@ -899,6 +901,34 @@ public function process() {
}
}

/**
* @subpackage keyboard_shortcuts/handler
*/
class Hm_Handler_process_enable_compose_delivery_receipt_setting extends Hm_Handler_Module {
public function process() {
function compose_delivery_receipt_enabled_callback($val) { return $val; }
process_site_setting('enable_compose_delivery_receipt', $this, 'compose_delivery_receipt_enabled_callback', false, true);
}
}

class Hm_Output_enable_compose_delivery_receipt_setting extends Hm_Output_Module {
protected function output() {
$settings = $this->get('user_settings');
if (array_key_exists('enable_compose_delivery_receipt', $settings) && $settings['enable_compose_delivery_receipt']) {
$checked = ' checked="checked"';
$reset = '<span class="tooltip_restore" restore_aria_label="Restore default value"><i class="bi bi-arrow-repeat refresh_list reset_default_value_checkbox"></i></span>';
}
else {
$checked = '';
$reset = '';
}
return '<tr class="general_setting"><td><label class="form-check-label" for="enable_compose_delivery_receipt">'.
$this->trans('Enable delivery receipt').'</label></td>'.
'<td><input class="form-check-input" type="checkbox" '.$checked.
' value="1" id="enable_compose_delivery_receipt" name="enable_compose_delivery_receipt" />'.$reset.'</td></tr>';
}
}

/**
* @subpackage keyboard_shortcuts/output
*/
Expand Down Expand Up @@ -1181,8 +1211,11 @@ protected function output() {
'<div class="form-floating mb-3">'.
'<textarea id="compose_body" name="compose_body" class="compose_body form-control" placeholder="'.$this->trans('Message').'">'.$this->html_safe($body).'</textarea>'.
(!$html ? '<label for="compose_body">'.$this->trans('Message').'</label>': '').
'</div>'.
'<div class="form-check mb-3"><input value="0" name="compose_delivery_receipt" id="compose_delivery_receipt" type="checkbox" class="form-check-input" /><label for="compose_delivery_receipt" class="form-check-label">'.$this->trans('Request a delivery receipt').'</label></div>';
'</div>';
$settings = $this->get('user_settings');
if($settings->get('enable_compose_delivery_receipt_setting')) {
$res .= '<div class="form-check mb-3"><input value="0" name="compose_delivery_receipt" id="compose_delivery_receipt" type="checkbox" class="form-check-input" /><label for="compose_delivery_receipt" class="form-check-label">'.$this->trans('Request a delivery receipt').'</label></div>';
}
if ($html == 2) {
$res .= '<link href="'.WEB_ROOT.'modules/smtp/assets/markdown/editor.css" rel="stylesheet" />'.
'<script type="text/javascript" src="'.WEB_ROOT.'modules/smtp/assets/markdown/editor.js"></script>'.
Expand Down
4 changes: 4 additions & 0 deletions modules/smtp/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
add_handler('ajax_clear_attachment_chunks', 'load_user_data', true, 'core');
add_handler('ajax_clear_attachment_chunks', 'clear_attachment_chunks', true);

add_handler('settings', 'process_enable_compose_delivery_receipt_setting', true, 'core', 'save_user_settings', 'before');
add_output('settings', 'enable_compose_delivery_receipt_setting', true, 'core', 'start_general_settings', 'after');

return array(
'allowed_pages' => array(
'ajax_clear_attachment_chunks',
Expand Down Expand Up @@ -169,6 +172,7 @@
'compose_cc' => FILTER_UNSAFE_RAW,
'compose_bcc' => FILTER_UNSAFE_RAW,
'compose_delivery_receipt' => FILTER_VALIDATE_BOOLEAN,
'enable_compose_delivery_receipt' => FILTER_VALIDATE_INT,
'compose_smtp_id' => FILTER_DEFAULT,
'draft_id' => FILTER_VALIDATE_INT,
'draft_body' => FILTER_UNSAFE_RAW,
Expand Down

0 comments on commit f2890b9

Please sign in to comment.