mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-02-20 01:21:20 +01:00
Fix folder list sorting when using personal namespace prefix of INBOX/ (#9452)
This commit is contained in:
@@ -4452,6 +4452,26 @@ class rcube_imap extends rcube_storage
|
||||
}
|
||||
}
|
||||
|
||||
// If special folders are INBOX's subfolders we need to place them after INBOX, otherwise
|
||||
// they won't be displayed in proper order in UI after we remove the namespace prefix (#9452)
|
||||
// FIXME: All this looks complicated and fragile, other options?
|
||||
if (!empty($special) && !empty($inbox) && $inbox[0] == 'INBOX'
|
||||
&& !empty($this->namespace['personal'])
|
||||
&& count($this->namespace['personal']) == 1
|
||||
) {
|
||||
$insert = [];
|
||||
foreach ($special as $idx => $spec_folder) {
|
||||
if (str_starts_with($spec_folder, 'INBOX' . $this->delimiter)) {
|
||||
$insert[] = $spec_folder;
|
||||
unset($special[$idx]);
|
||||
}
|
||||
}
|
||||
if (!empty($insert)) {
|
||||
array_shift($inbox);
|
||||
$inbox = array_merge(['INBOX'], $insert, $inbox);
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge(
|
||||
$inbox, // INBOX and its subfolders
|
||||
$special, // special folders and their subfolders
|
||||
|
||||
@@ -49,7 +49,7 @@ class ImapTest extends TestCase
|
||||
{
|
||||
// The sorting requires this locale.
|
||||
if (setlocale(\LC_ALL, 'en_US.UTF-8', 'en_US.utf8', 'en_US', 'en-US') === false) {
|
||||
throw new \Error('This test requires `en_US` to be settable as locale, but those appear to not be present in your environment!');
|
||||
throw new \Error('This test requires `en_US` to be settable as locale.');
|
||||
}
|
||||
|
||||
$_SESSION['imap_delimiter'] = '.';
|
||||
@@ -151,6 +151,50 @@ class ImapTest extends TestCase
|
||||
$result = $object->sort_folder_list($folders);
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
|
||||
// Test sorting when using INBOX/ as a personal namespace prefix (#9452)
|
||||
$_SESSION['imap_delimiter'] = '/';
|
||||
$_SESSION['imap_namespace'] = [
|
||||
'personal' => [['INBOX/', '/']],
|
||||
'other' => [['Other Users/', '/']],
|
||||
'shared' => [['Shared/', '/']],
|
||||
];
|
||||
|
||||
foreach (['drafts', 'sent', 'junk', 'trash'] as $mbox) {
|
||||
\rcube::get_instance()->config->set("{$mbox}_mbox", 'INBOX/' . ucfirst($mbox));
|
||||
}
|
||||
|
||||
$object = new \rcube_imap();
|
||||
|
||||
$folders = [
|
||||
'INBOX',
|
||||
'INBOX/Joker',
|
||||
'INBOX/Junk',
|
||||
'INBOX/Trash',
|
||||
'INBOX/Contacts',
|
||||
'INBOX/Sent',
|
||||
'INBOX/Sent/RIPE',
|
||||
'INBOX/Calendar',
|
||||
'INBOX/AJunk',
|
||||
'INBOX/Drafts',
|
||||
];
|
||||
|
||||
$expected = [
|
||||
'INBOX',
|
||||
'INBOX/Drafts',
|
||||
'INBOX/Sent',
|
||||
'INBOX/Sent/RIPE',
|
||||
'INBOX/Junk',
|
||||
'INBOX/Trash',
|
||||
'INBOX/AJunk',
|
||||
'INBOX/Calendar',
|
||||
'INBOX/Contacts',
|
||||
'INBOX/Joker',
|
||||
];
|
||||
|
||||
$result = $object->sort_folder_list($folders);
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user