diff options
author | alecpl <alec@alec.pl> | 2011-05-05 12:46:54 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2011-05-05 12:46:54 +0000 |
commit | d08333ea578e3b6c6ab42bed05f808a2b7b93cf1 (patch) | |
tree | 58aa053d41963c5f452b614497d06aaf73c5a76a /program/steps | |
parent | 4764079c6af092a6dfa18306601e1b33482fb756 (diff) |
- Fix problems with subfolders of INBOX folder on some IMAP servers (#1487725)
- Fix handling of folders that doesn't belong to any namespace (#1487637)
Diffstat (limited to 'program/steps')
-rw-r--r-- | program/steps/mail/func.inc | 2 | ||||
-rw-r--r-- | program/steps/settings/edit_folder.inc | 20 | ||||
-rw-r--r-- | program/steps/settings/folders.inc | 40 | ||||
-rw-r--r-- | program/steps/settings/save_folder.inc | 3 |
4 files changed, 44 insertions, 21 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 0f25ec765..889406b15 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -130,7 +130,7 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') { 'movingmessage', 'copyingmessage', 'deletingmessage', 'markingmessage', 'copy', 'move', 'quota'); - $OUTPUT->set_pagetitle(rcmail_localize_foldername($mbox_name)); + $OUTPUT->set_pagetitle(rcmail_localize_foldername($IMAP->mod_mailbox($mbox_name))); } diff --git a/program/steps/settings/edit_folder.inc b/program/steps/settings/edit_folder.inc index 34dc064b5..c57ec69d7 100644 --- a/program/steps/settings/edit_folder.inc +++ b/program/steps/settings/edit_folder.inc @@ -54,6 +54,20 @@ function rcube_folder_form($attrib) else { $options = array(); $path = $parent_imap; + + // allow creating subfolders of INBOX folder + if ($path == 'INBOX') { + $path = $RCMAIL->imap->mod_mailbox($path, 'in'); + } + } + + // remove personal namespace prefix + if (strlen($path)) { + $path_id = $path; + $path = $RCMAIL->imap->mod_mailbox($path.$delimiter); + if ($path[strlen($path)-1] == $delimiter) { + $path = substr($path, 0, -1); + } } $form = array(); @@ -93,15 +107,15 @@ function rcube_folder_form($attrib) ); if (strlen($path)) { - if ($options['norename'] || $options['namespace'] != 'personal') { + if (!empty($options) && ($options['norename'] || $options['namespace'] != 'personal')) { // prevent user from moving folder $hidden_path = new html_hiddenfield(array('name' => '_parent', 'value' => $path)); $form['props']['fieldsets']['location']['content']['name']['value'] .= $hidden_path->show(); } else { $radio1 = new html_radiobutton(array('name' => '_parent', 'value' => '')); - $radio2 = new html_radiobutton(array('name' => '_parent', 'value' => $path)); - $selected = isset($_POST['_parent']) ? $_POST['_parent'] : $path; + $radio2 = new html_radiobutton(array('name' => '_parent', 'value' => $path_id)); + $selected = isset($_POST['_parent']) ? $_POST['_parent'] : $path_id; $html_path = str_replace($delimiter, ' » ', rcmail_localize_folderpath($path)); diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc index a215d008b..c4c221fb5 100644 --- a/program/steps/settings/folders.inc +++ b/program/steps/settings/folders.inc @@ -126,12 +126,11 @@ else if ($RCMAIL->action == 'rename-folder') // subfolders for ($x=sizeof($folderlist)-1; $x>=0; $x--) { if (preg_match($regexp, $folderlist[$x])) { - $oldfolder = $oldname . $delimiter . preg_replace($regexp, '', $folderlist[$x]); - $foldersplit = explode($delimiter, $folderlist[$x]); - $level = count($foldersplit) - 1; + $oldfolder = $oldname . $delimiter . preg_replace($regexp, '', $folderlist[$x]); + $foldersplit = explode($delimiter, $IMAP->mod_mailbox($folderlist[$x])); + $level = count($foldersplit) - 1; $display_rename = str_repeat(' ', $level) . rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP'); - $before = isset($folderlist[$x+1]) ? rcube_charset_convert($folderlist[$x+1], 'UTF7-IMAP') : false; $OUTPUT->command('replace_folder_row', rcube_charset_convert($oldfolder, 'UTF7-IMAP'), @@ -139,14 +138,14 @@ else if ($RCMAIL->action == 'rename-folder') } } + $index = array_search($name, $folderlist); + $name = $IMAP->mod_mailbox($name); $foldersplit = explode($delimiter, $name); - $level = count($foldersplit) - 1; + $level = count($foldersplit) - 1; $display_rename = str_repeat(' ', $level) . rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP'); - $index = array_search($name, $folderlist); - $before = $index !== false && isset($folderlist[$index+1]) ? rcube_charset_convert($folderlist[$index+1], 'UTF7-IMAP') : false; + $before = $index !== false && isset($folderlist[$index+1]) ? rcube_charset_convert($folderlist[$index+1], 'UTF7-IMAP') : false; - $OUTPUT->command('replace_folder_row', $oldname_utf8, - rcube_charset_convert($name, 'UTF7-IMAP'), $display_rename, $before); + $OUTPUT->command('replace_folder_row', $oldname_utf8, $name_utf8, $display_rename, $before); } else if (!$rename) { rcmail_display_server_error('errorsaving'); @@ -243,13 +242,15 @@ function rcube_subscription_form($attrib) // pre-process folders list foreach ($a_unsubscribed as $i => $folder) { - $foldersplit = explode($delimiter, $folder); - $name = rcube_charset_convert(array_pop($foldersplit), 'UTF7-IMAP'); + $folder_id = $folder; + $folder = $IMAP->mod_mailbox($folder); + $foldersplit = explode($delimiter, $folder); + $name = rcube_charset_convert(array_pop($foldersplit), 'UTF7-IMAP'); $parent_folder = join($delimiter, $foldersplit); - $level = count($foldersplit); + $level = count($foldersplit); // add any necessary "virtual" parent folders - if ($parent_folder && !$seen[$parent_folder]) { + if ($parent_folder && !isset($seen[$parent_folder])) { for ($i=1; $i<=$level; $i++) { $ancestor_folder = join($delimiter, array_slice($foldersplit, 0, $i)); if ($ancestor_folder && !$seen[$ancestor_folder]++) { @@ -263,11 +264,16 @@ function rcube_subscription_form($attrib) } } } - + + // Handle properly INBOX.INBOX situation + if (isset($seen[$folder])) { + continue; + } + $seen[$folder]++; $list_folders[] = array( - 'id' => $folder, + 'id' => $folder_id, 'name' => $name, 'level' => $level, ); @@ -354,11 +360,11 @@ function rcmail_rename_folder($oldname, $newname) foreach ($a_threaded as $key => $val) { if ($key == $oldname) { unset($a_threaded[$key]); - $a_threaded[$newname] = true; + $a_threaded[$newname] = true; } else if (preg_match($oldprefix, $key)) { unset($a_threaded[$key]); - $a_threaded[preg_replace($oldprefix, $newname.$delimiter, $key)] = true; + $a_threaded[preg_replace($oldprefix, $newname.$delimiter, $key)] = true; } } $RCMAIL->user->save_prefs(array('message_threading' => $a_threaded)); diff --git a/program/steps/settings/save_folder.inc b/program/steps/settings/save_folder.inc index 70aad6d82..c1120961b 100644 --- a/program/steps/settings/save_folder.inc +++ b/program/steps/settings/save_folder.inc @@ -65,6 +65,9 @@ else { else if (strlen($path)) { $name_imap = $path . $delimiter . $name_imap; } + else { + $name_imap = $RCMAIL->imap->mod_mailbox($name, 'in'); + } $folder['name'] = $name_imap; $folder['oldname'] = $old_imap; |