diff --git a/modules/core/site.js b/modules/core/site.js index 90474018b3..5fe125f50d 100644 --- a/modules/core/site.js +++ b/modules/core/site.js @@ -1560,6 +1560,12 @@ var Hm_Utils = { Hm_Ajax.request( [{'name': 'hm_ajax_hook', 'value': 'ajax_test'}], false, [], false, false, false); + }, + redirect: function (path) { + if (! path) { + path = window.location.href; + } + window.location.href = path; } }; diff --git a/modules/imap/hm-imap.php b/modules/imap/hm-imap.php index 15b63ec729..f7c8eb5d65 100644 --- a/modules/imap/hm-imap.php +++ b/modules/imap/hm-imap.php @@ -353,7 +353,7 @@ public function get_capability() { */ public function get_special_use_mailboxes($type=false) { $folders = array(); - $types = array('trash', 'sent', 'flagged', 'all', 'junk'); + $types = array('trash', 'sent', 'flagged', 'all', 'junk', 'archive', 'drafts'); $command = 'LIST (SPECIAL-USE) "" "*"'."\r\n"; $this->send_command($command); $res = $this->get_response(false, true); diff --git a/modules/imap_folders/modules.php b/modules/imap_folders/modules.php index 63d4efd98b..c59f967873 100644 --- a/modules/imap_folders/modules.php +++ b/modules/imap_folders/modules.php @@ -130,7 +130,7 @@ public function process() { class Hm_Handler_process_accept_special_folders extends Hm_Handler_Module { public function process() { list($success, $form) = $this->process_form(array('imap_server_id', 'imap_service_name')); - if ($success) { + if ($success) { $cache = Hm_IMAP_List::get_cache($this->cache, $form['imap_server_id']); $imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache); @@ -141,17 +141,23 @@ public function process() { $specials = $this->user_config->get('special_imap_folders', array()); if ($exposed = $imap->get_special_use_mailboxes()) { - $specials[$form['imap_server_id']] = array('sent' => $exposed['sent'], 'draft' => '', 'trash' => $exposed['trash'], 'archive' => '', 'junk' => ''); + $specials[$form['imap_server_id']] = array( + 'sent' => $exposed['sent'] ?? '', + 'draft' => $exposed['drafts'] ?? '', + 'trash' => $exposed['trash'] ?? '', + 'archive' => $exposed['archive'] ?? '', + 'junk' => $exposed['junk'] ?? '' + ); } else if ($form['imap_service_name'] == 'gandi') { $specials[$form['imap_server_id']] = array('sent' => 'Sent', 'draft' => 'Drafts', 'trash' => 'Trash', 'archive' => 'Archive', 'junk' => 'Junk'); } else { $specials[$form['imap_server_id']] = array('sent' => '', 'draft' => '', 'trash' => '', 'archive' => '', 'junk' => ''); - } + } $this->user_config->set('special_imap_folders', $specials); $user_data = $this->user_config->dump(); $this->session->set('user_data', $user_data); - + Hm_Msgs::add('Special folders assigned'); $this->session->record_unsaved('Special folders assigned'); $this->session->close_early(); @@ -225,7 +231,6 @@ function ($value) use($old_folder) { foreach ($script_names as $script_name) { $script_parsed = $client->getScript($script_name); $script_parsed = str_replace('"'.$old_folder.'"', '"'.$new_folder.'"', $script_parsed); - $old_actions = base64_decode(preg_split('#\r?\n#', $script_parsed, 0)[2]); $new_actions = base64_encode(str_replace('"'.$old_folder.'"', '"'.$new_folder.'"', $old_actions)); $script_parsed = str_replace(base64_encode($old_actions), $new_actions, $script_parsed); @@ -269,7 +274,7 @@ public function process() { if (is_mailbox_linked_with_filters($del_folder, $form['imap_server_id'], $this)) { Hm_Msgs::add('ERRThis folder can\'t be deleted because it is used in a filter.'); return; - } + } } if ($del_folder && $imap->delete_mailbox($del_folder)) { Hm_Msgs::add('Folder deleted'); @@ -639,6 +644,6 @@ function is_mailbox_linked_with_filters ($mailbox, $imap_server_id, $module) { $linked_mailboxes = get_sieve_linked_mailbox($imap_account, $module); return in_array($mailbox, $linked_mailboxes); } - return false; + return false; } } diff --git a/modules/nux/site.js b/modules/nux/site.js index f22cc3c25d..a381a1585a 100644 --- a/modules/nux/site.js +++ b/modules/nux/site.js @@ -52,12 +52,11 @@ var display_final_nux_step = function(res) { [{'name': 'hm_ajax_hook', 'value': 'ajax_imap_accept_special_folders'}, {'name': 'imap_server_id', value: res.nux_server_id}, {'name': 'imap_service_name', value: res.nux_service_name}], - function(res) { + function() { window.location.href = "?page=servers"; } ); } - window.location.href = "?page=servers"; } };