Skip to content

Commit

Permalink
Merge pull request #840 from josaphatim/added-missing-special-folders
Browse files Browse the repository at this point in the history
Added missing special folders types
  • Loading branch information
kroky authored Dec 20, 2023
2 parents 29e840b + d9d3dd2 commit ee014fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modules/imap/hm-imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 17 additions & 7 deletions modules/imap_folders/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,25 @@ public function process() {
Hm_Msgs('ERRUnable to connect to the selected IMAP server');
return;
}

$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' => '');
} else if ($form['imap_service_name'] == 'gandi') {
$specials[$form['imap_server_id']] = array('sent' => 'Sent', 'draft' => 'Drafts', 'trash' => 'Trash', 'archive' => 'Archive', 'junk' => 'Junk');
$exposed = $imap->get_special_use_mailboxes();
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' => '');
}
$specials[$form['imap_server_id']] = array(
'sent' => $exposed['sent'] ?? '',
'draft' => $exposed['drafts'] ?? '',
'trash' => $exposed['trash'] ?? '',
'archive' => $exposed['archive'] ?? '',
'junk' => $exposed['junk'] ?? ''
);
}
$this->user_config->set('special_imap_folders', $specials);

$user_data = $this->user_config->dump();
Expand Down

0 comments on commit ee014fd

Please sign in to comment.