Skip to content

Commit 28a10ba

Browse files
authored
Merge pull request #1077 from christer77/special-folder-in-1.4.x
[FIX]add special folders migadu
2 parents 0ec2139 + 38e025a commit 28a10ba

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

modules/core/site.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,12 @@ var Hm_Utils = {
15601560
Hm_Ajax.request(
15611561
[{'name': 'hm_ajax_hook', 'value': 'ajax_test'}],
15621562
false, [], false, false, false);
1563+
},
1564+
redirect: function (path) {
1565+
if (! path) {
1566+
path = window.location.href;
1567+
}
1568+
window.location.href = path;
15631569
}
15641570
};
15651571

modules/imap/hm-imap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public function get_capability() {
353353
*/
354354
public function get_special_use_mailboxes($type=false) {
355355
$folders = array();
356-
$types = array('trash', 'sent', 'flagged', 'all', 'junk');
356+
$types = array('trash', 'sent', 'flagged', 'all', 'junk', 'archive', 'drafts');
357357
$command = 'LIST (SPECIAL-USE) "" "*"'."\r\n";
358358
$this->send_command($command);
359359
$res = $this->get_response(false, true);

modules/imap_folders/modules.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function process() {
130130
class Hm_Handler_process_accept_special_folders extends Hm_Handler_Module {
131131
public function process() {
132132
list($success, $form) = $this->process_form(array('imap_server_id', 'imap_service_name'));
133-
if ($success) {
133+
if ($success) {
134134
$cache = Hm_IMAP_List::get_cache($this->cache, $form['imap_server_id']);
135135
$imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache);
136136

@@ -141,17 +141,23 @@ public function process() {
141141

142142
$specials = $this->user_config->get('special_imap_folders', array());
143143
if ($exposed = $imap->get_special_use_mailboxes()) {
144-
$specials[$form['imap_server_id']] = array('sent' => $exposed['sent'], 'draft' => '', 'trash' => $exposed['trash'], 'archive' => '', 'junk' => '');
144+
$specials[$form['imap_server_id']] = array(
145+
'sent' => $exposed['sent'] ?? '',
146+
'draft' => $exposed['drafts'] ?? '',
147+
'trash' => $exposed['trash'] ?? '',
148+
'archive' => $exposed['archive'] ?? '',
149+
'junk' => $exposed['junk'] ?? ''
150+
);
145151
} else if ($form['imap_service_name'] == 'gandi') {
146152
$specials[$form['imap_server_id']] = array('sent' => 'Sent', 'draft' => 'Drafts', 'trash' => 'Trash', 'archive' => 'Archive', 'junk' => 'Junk');
147153
} else {
148154
$specials[$form['imap_server_id']] = array('sent' => '', 'draft' => '', 'trash' => '', 'archive' => '', 'junk' => '');
149-
}
155+
}
150156
$this->user_config->set('special_imap_folders', $specials);
151157

152158
$user_data = $this->user_config->dump();
153159
$this->session->set('user_data', $user_data);
154-
160+
155161
Hm_Msgs::add('Special folders assigned');
156162
$this->session->record_unsaved('Special folders assigned');
157163
$this->session->close_early();
@@ -225,7 +231,6 @@ function ($value) use($old_folder) {
225231
foreach ($script_names as $script_name) {
226232
$script_parsed = $client->getScript($script_name);
227233
$script_parsed = str_replace('"'.$old_folder.'"', '"'.$new_folder.'"', $script_parsed);
228-
229234
$old_actions = base64_decode(preg_split('#\r?\n#', $script_parsed, 0)[2]);
230235
$new_actions = base64_encode(str_replace('"'.$old_folder.'"', '"'.$new_folder.'"', $old_actions));
231236
$script_parsed = str_replace(base64_encode($old_actions), $new_actions, $script_parsed);
@@ -269,7 +274,7 @@ public function process() {
269274
if (is_mailbox_linked_with_filters($del_folder, $form['imap_server_id'], $this)) {
270275
Hm_Msgs::add('ERRThis folder can\'t be deleted because it is used in a filter.');
271276
return;
272-
}
277+
}
273278
}
274279
if ($del_folder && $imap->delete_mailbox($del_folder)) {
275280
Hm_Msgs::add('Folder deleted');
@@ -639,6 +644,6 @@ function is_mailbox_linked_with_filters ($mailbox, $imap_server_id, $module) {
639644
$linked_mailboxes = get_sieve_linked_mailbox($imap_account, $module);
640645
return in_array($mailbox, $linked_mailboxes);
641646
}
642-
return false;
647+
return false;
643648
}
644649
}

modules/nux/site.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ var display_final_nux_step = function(res) {
5252
[{'name': 'hm_ajax_hook', 'value': 'ajax_imap_accept_special_folders'},
5353
{'name': 'imap_server_id', value: res.nux_server_id},
5454
{'name': 'imap_service_name', value: res.nux_service_name}],
55-
function(res) {
55+
function() {
5656
window.location.href = "?page=servers";
5757
}
5858
);
5959
}
60-
6160
window.location.href = "?page=servers";
6261
}
6362
};

0 commit comments

Comments
 (0)