Skip to content

Commit dd09731

Browse files
marclaportechrister77
authored andcommitted
Merge pull request #1762 from StevenMassaro/patch-1
fix: Change AOL SMTP port from 587 to 465
2 parents 00fffe2 + 6ecabef commit dd09731

File tree

9 files changed

+127
-4
lines changed

9 files changed

+127
-4
lines changed

language/en.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@
341341
'Move' => false,
342342
'Move to ...' => false,
343343
'Copy to ...' => false,
344+
'Restore' => false,
344345
'Removed non-IMAP messages from selection. They cannot be moved or copied' => false,
345346
'Messages moved' => false,
346347
'Messages copied' => false,

modules/core/message_list_functions.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,19 @@ function icon_callback($vals, $style, $output_mod) {
415415
if (!hm_exists('message_controls')) {
416416
function message_controls($output_mod) {
417417
$txt = '';
418-
$controls = ['read', 'unread', 'flag', 'unflag', 'delete', 'archive', 'junk'];
418+
$controls = ['read', 'unread', 'flag', 'unflag', 'delete', 'archive', 'junk', 'restore'];
419419
$controls = array_filter($controls, function($val) use ($output_mod) {
420420
if (in_array($val, [$output_mod->get('list_path', ''), strtolower($output_mod->get('core_msg_control_folder', ''))])) {
421421
return false;
422422
}
423423
if ($val == 'flag' && $output_mod->get('list_path', '') == 'flagged') {
424424
return false;
425425
}
426+
$is_trash_folder = $output_mod->get('is_trash_folder', false);
427+
428+
if ($val == 'restore' && !$is_trash_folder) {
429+
return false;
430+
}
426431
return true;
427432
});
428433

modules/imap/functions.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,3 +1668,13 @@ function is_imap_archive_folder($server_id, $user_config, $current_folder) {
16681668

16691669
return false;
16701670
}}
1671+
1672+
if (!hm_exists('is_imap_trash_folder')) {
1673+
function is_imap_trash_folder($handler, $server_id, $folder) {
1674+
$specials = get_special_folders($handler, $server_id);
1675+
if (array_key_exists('trash', $specials) && $specials['trash']) {
1676+
return $specials['trash'] === $folder;
1677+
}
1678+
return false;
1679+
}
1680+
}

modules/imap/handler_modules.php

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,9 @@ public function process() {
555555
if (array_key_exists(strtolower($folder), $spcial_folders)) {
556556
$this->out('core_msg_control_folder', $spcial_folders[strtolower($folder)]);
557557
}
558+
559+
$this->out('is_trash_folder', is_imap_trash_folder($this, $parts[1], $folder));
560+
558561
if (!empty($details)) {
559562
if (array_key_exists('folder_label', $this->request->get)) {
560563
$folder = $this->request->get['folder_label'];
@@ -1138,7 +1141,7 @@ class Hm_Handler_imap_message_action extends Hm_Handler_Module {
11381141
public function process() {
11391142
list($success, $form) = $this->process_form(array('action_type', 'message_ids'));
11401143
if ($success) {
1141-
if (in_array($form['action_type'], array('delete', 'read', 'unread', 'flag', 'unflag', 'archive', 'junk'))) {
1144+
if (in_array($form['action_type'], array('delete', 'read', 'unread', 'flag', 'unflag', 'archive', 'junk', 'restore'))) {
11421145
$ids = process_imap_message_ids($form['message_ids']);
11431146
$errs = 0;
11441147
$msgs = 0;
@@ -1196,6 +1199,9 @@ private function perform_action($mailbox, $action_type, $uids, $folder, $special
11961199
$moved = array();
11971200
$folder_name = hex2bin($folder);
11981201
$special_folder = $this->get_special_folder($action_type, $specials, $server_details);
1202+
if ($action_type == "restore" && !$special_folder) {
1203+
$special_folder = 'INBOX';
1204+
}
11991205

12001206
if ($special_folder && $special_folder != $folder_name) {
12011207
if ($this->user_config->get('original_folder_setting', false)) {
@@ -1225,7 +1231,7 @@ private function perform_action($mailbox, $action_type, $uids, $folder, $special
12251231
}
12261232

12271233
$folderNotFoundError = false;
1228-
if (!$special_folder && $action_type != 'read' && $action_type != 'unread' && $action_type != 'flag' && $action_type != 'unflag') {
1234+
if (!$special_folder && $action_type != 'read' && $action_type != 'unread' && $action_type != 'flag' && $action_type != 'unflag' && $action_type != 'restore') {
12291235
Hm_Msgs::add(sprintf('No %s folder configured for %s. Please go to <a href="?page=folders&imap_server_id=%s">Folders seetting</a> and configure one', $action_type, $server_details['name'], $server_details['id']), empty($moved) ? 'danger' : 'warning');
12301236
$folderNotFoundError = true;
12311237
}
@@ -1254,6 +1260,8 @@ private function get_special_folder($action_type, $specials, $server_details) {
12541260
$folder = $specials['archive'];
12551261
} elseif ($action_type == 'junk' && array_key_exists('junk', $specials)) {
12561262
$folder = $specials['junk'];
1263+
} elseif ($action_type == 'restore') {
1264+
$folder = $specials['inbox'];
12571265
}
12581266
return $folder;
12591267
}
@@ -1996,6 +2004,7 @@ public function process() {
19962004
$this->session->set(sprintf('reply_details_imap_%s_%s_%s', $form['imap_server_id'], $form['folder'], $form['imap_msg_uid']),
19972005
array('ts' => time(), 'msg_struct' => $msg_struct_current, 'msg_text' => ($save_reply_text ? $msg_text : ''), 'msg_headers' => $msg_headers));
19982006
}
2007+
$this->out('is_trash_folder', is_imap_trash_folder($this, $form['imap_server_id'], hex2bin($form['folder'])));
19992008
}
20002009
}
20012010
}
@@ -2177,3 +2186,51 @@ function process_ceo_amount_limit_callback($val) { return $val; }
21772186
process_site_setting('ceo_rate_limit', $this, 'process_ceo_amount_limit_callback');
21782187
}
21792188
}
2189+
2190+
/**
2191+
* Restore a message from trash to inbox
2192+
* @subpackage imap/handler
2193+
*/
2194+
class Hm_Handler_imap_restore_message extends Hm_Handler_Module {
2195+
public function process() {
2196+
list($success, $form) = $this->process_form(array('imap_msg_uid', 'imap_server_id', 'folder'));
2197+
2198+
if (!$success) {
2199+
return;
2200+
}
2201+
2202+
$restore_result = false;
2203+
$inbox_folder = 'INBOX';
2204+
$form_folder = hex2bin($form['folder']);
2205+
$errors = 0;
2206+
$status = false;
2207+
$mailbox = Hm_IMAP_List::get_connected_mailbox($form['imap_server_id'], $this->cache);
2208+
if ($mailbox && $mailbox->authed()) {
2209+
$inbox_exists = count($mailbox->get_folder_status($inbox_folder));
2210+
if (!$inbox_exists) {
2211+
Hm_Msgs::add('INBOX folder does not exist', 'danger');
2212+
$errors++;
2213+
}
2214+
2215+
if (!$errors) {
2216+
$result = $mailbox->message_action($form_folder, 'MOVE', array($form['imap_msg_uid']), $inbox_folder);
2217+
$status = $result['status'] ?? false;
2218+
}
2219+
2220+
$this->out('folder_status', array('imap_'.$form['imap_server_id'].'_'.$form['folder'] => $mailbox->get_folder_state()));
2221+
} else {
2222+
Hm_Msgs::add('Unable to connect to IMAP server', 'danger');
2223+
$errors++;
2224+
}
2225+
2226+
if ($status) {
2227+
$restore_result = true;
2228+
Hm_Msgs::add('Message restored to inbox');
2229+
} else {
2230+
Hm_Msgs::add('An error occurred restoring the message', 'danger');
2231+
}
2232+
2233+
$this->save_hm_msgs();
2234+
$this->out('restore_result', $restore_result);
2235+
}
2236+
}

modules/imap/hm-imap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,6 +1908,7 @@ public function message_action($action, $uids, $mailbox=false, $keyword=false) {
19081908
$command = "UID STORE $uid_string +FLAGS (\Deleted)\r\n";
19091909
break;
19101910
case 'UNDELETE':
1911+
case 'RESTORE':
19111912
$command = "UID STORE $uid_string -FLAGS (\Deleted)\r\n";
19121913
break;
19131914
case 'CUSTOM':

modules/imap/output_modules.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ protected function output() {
389389
$txt .= '<a class="archive_link hlink text-decoration-none btn btn-sm btn-outline-secondary" id="archive_message" href="#">'.$this->trans('Archive').'</a>';
390390
}
391391

392+
if ($this->get('is_trash_folder')) {
393+
$txt .= '<a class="restore_link hlink text-decoration-none btn btn-sm btn-outline-secondary" id="restore_message" href="#">'.$this->trans('Restore').'</a>';
394+
}
395+
392396
if($this->get('tags')){
393397
$txt .= tags_dropdown($this);
394398
}

modules/imap/setup.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@
219219
add_handler('ajax_imap_archive_message', 'close_session_early', true, 'core');
220220
add_handler('ajax_imap_archive_message', 'imap_archive_message', true);
221221

222+
/* restore message callback */
223+
setup_base_ajax_page('ajax_imap_restore_message', 'core');
224+
add_handler('ajax_imap_restore_message', 'message_list_type', true, 'core');
225+
add_handler('ajax_imap_restore_message', 'imap_message_list_type', true);
226+
add_handler('ajax_imap_restore_message', 'load_imap_servers_from_config', true);
227+
add_handler('ajax_imap_restore_message', 'imap_oauth2_token_check', true);
228+
add_handler('ajax_imap_restore_message', 'close_session_early', true, 'core');
229+
add_handler('ajax_imap_restore_message', 'imap_restore_message', true);
222230

223231
/* ajax message action callback */
224232
add_handler('ajax_message_action', 'load_imap_servers_from_config', true, 'imap', 'load_user_data', 'after');
@@ -312,6 +320,7 @@
312320
'ajax_imap_junk',
313321
'message_source',
314322
'ajax_share_folders',
323+
'ajax_imap_restore_message',
315324
),
316325

317326
'allowed_output' => array(

modules/imap/site.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ var imap_message_view_finished = function(msg_uid, detail, listParent, skip_link
796796
$('#move_message').on("click", function(e) { return imap_move_copy(e, 'move', 'message');});
797797
$('#copy_message').on("click", function(e) { return imap_move_copy(e, 'copy', 'message');});
798798
$('#archive_message').on("click", function(e) { return imap_archive_message();});
799+
$('#restore_message').on("click", function(e) { return imap_restore_message(e);});
799800
$('#unread_message').on("click", function() { return imap_unread_message(msg_uid, detail);});
800801
$('#block_sender').on("click", function(e) {
801802
e.preventDefault();
@@ -1334,6 +1335,41 @@ var imap_archive_message = function(state, supplied_uid, supplied_detail) {
13341335
return false;
13351336
};
13361337

1338+
var imap_restore_message = function(e, supplied_uid, supplied_detail) {
1339+
e.preventDefault();
1340+
var uid = getMessageUidParam();
1341+
var detail = Hm_Utils.parse_folder_path(getListPathParam(), 'imap');
1342+
if (supplied_uid) {
1343+
uid = supplied_uid;
1344+
}
1345+
if (supplied_detail) {
1346+
detail = supplied_detail;
1347+
}
1348+
if (detail && uid) {
1349+
Hm_Ajax.request(
1350+
[{'name': 'hm_ajax_hook', 'value': 'ajax_imap_restore_message'},
1351+
{'name': 'imap_msg_uid', 'value': uid},
1352+
{'name': 'imap_server_id', 'value': detail.server_id},
1353+
{'name': 'folder', 'value': detail.folder}],
1354+
function(res) {
1355+
if (res.restore_result) {
1356+
if (hm_list_parent() == 'message') {
1357+
if (hm_auto_advance_email_enabled()) {
1358+
Hm_Utils.redirect("?page=message_list&list_path="+getListPathParam());
1359+
} else if (hm_list_parent() == 'search') {
1360+
Hm_Utils.redirect("?page=search&list_path="+hm_list_parent());
1361+
} else {
1362+
Hm_Utils.redirect("?page=message_list&list_path="+hm_list_parent());
1363+
}
1364+
}
1365+
}
1366+
}
1367+
);
1368+
1369+
}
1370+
return false;
1371+
};
1372+
13371373
var imap_show_add_contact_popup = function() {
13381374
var popup = document.getElementById("contact_popup");
13391375
popup.classList.toggle("show");

modules/nux/services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
'auth' => 'login',
106106
'smtp' => array(
107107
'server' => 'smtp.aol.com',
108-
'port' => 587,
108+
'port' => 465,
109109
'tls' => true
110110
)
111111
));

0 commit comments

Comments
 (0)