6.0.0-git
2021-01-18

[#1291] Folder dropdown sorted incorrectly
Summary Folder dropdown sorted incorrectly
Queue IMP
Queue Version 4.0.1
Type Bug
State Resolved
Priority 1. Low
Owners slusarz (at) horde (dot) org
Requester alex (at) milivojevic (dot) org
Created 2005-02-01 (5830 days ago)
Due
Updated 2005-02-08 (5823 days ago)
Assigned 2005-02-04 (5827 days ago)
Resolved 2005-02-07 (5824 days ago)
Milestone
Patch No

History
2005-02-08 01:29:29 alex (at) milivojevic (dot) org Comment #7 Reply to this comment
Thank you for resolving this bug.
2005-02-07 19:59:39 Michael Slusarz Comment #6
State ⇒ Resolved
Reply to this comment
Merged to Horde 3.0.3.



(As for #2, there are several cases that your patch will do unneeded 
comparisions while the committed code won't - for example, consider 
the comparision of two mailboxes 'INBOX.foo1' and 'INBOX.foo2' )
2005-02-04 16:48:18 alex (at) milivojevic (dot) org Comment #5 Reply to this comment
I agree with 2 (although, not sure if RFC says that INBOX is always 
uppercase, if it is the case, than string comparation should be case 
sensitive for both this check and the previously existing check for 
INBOX folder itself at the beggining of fucntion).



As for 1 (speed improvement), it is dependent on IMAP server used, and 
the way user organized his folders.  On Cyrus with alternate_namespace 
turned off, I clearly see the benefit and performance improvement.  On 
everything else, hm, it's doubtfull.  If alternate_namespace is turned 
on, and user has a flat folder structure (for example, only top-level 
folders: INBOX, Folder1, Folder2, and so on), it will be actually 
slower.  In that case you only introduced one additional 
if($this->_sortinbox && ($i == 0)) check, case that is already checked 
at the beggining of function.



Anyhow, your patch worked for me.  If you commit it, maybe replace 
[$i] with [0].  $i is always zero in that part of code (because of 
"if" statement).  Or using full folder name instead of array component 
(like in my patch, is there case insensitive version of strpos?).
2005-02-04 06:55:16 Michael Slusarz Comment #4
State ⇒ Feedback
Reply to this comment
Can you try what I committed to HEAD?

http://cvs.horde.org/diff.php/framework/IMAP/IMAP/Sort.php?r1=1.7&r2=1.8&ty=u



It is similar to what you proposed with several enhancements. 1) it is 
more efficient as the INBOX folder searching code is not evauated on 
every function call, and 2) it correctly searches for the 
case-insensitive inbox string instead of exclusively for 'INBOX'.



If this works for you, I will commit to Horde 3.0.3.
2005-02-03 18:17:07 alex (at) milivojevic (dot) org Comment #3
New Attachment: folder_dropdown.patch Download
Reply to this comment
The bug is in _mbox_cmp function in 
horde-3.0.2/lib/Horde/IMAP/Sort.php.  When sorting, it checks only if 
one of the arguments is INBOX itself.  Folders that are subfolders of 
INBOX are sorted just like any other folders (ignoring _sortinbox 
setting).



The attached patch fixes this.  Even when using namespace or similar 
options, this should be good thing to do.  Sorted list will contain 
INBOX, than subfolders of INBOX (with INBOX. part displayed or hidden, 
depending on used options), and than all other folders.  In some 
cases, this might result in the folder list that might not look 
completely sorted on the first look, but it will be more logical 
(because user's folders will not be mixed with shared or other users 
folders).
2005-02-01 20:05:50 alex (at) milivojevic (dot) org Comment #2 Reply to this comment
I've just found that the bug is also present in every other dropdown 
box that contains folder listing.  Example would be dropdown boxes 
used in Server and Folder Information preferences dialogs.  I guess 
same code is used to generate those dropdown boxes.
2005-02-01 18:48:45 Jan Schneider Assigned to Michael Slusarz
State ⇒ Assigned
 
2005-02-01 18:15:16 alex (at) milivojevic (dot) org Comment #1
Type ⇒ Bug
State ⇒ Unconfirmed
Priority ⇒ 1. Low
Summary ⇒ Folder dropdown sorted incorrectly
Queue ⇒ IMP
Reply to this comment
I've first noticed this bug with IMP 2.2, and later confirmed that it 
is still present in the current version of IMP, 4.0.1.



On my testing Cyrus IMAPD server, I created following mailbox 
structure on the Cyrus IMAPD server for testing shared mailboxes (as 
printed by cyradm's listmailbox command):



bureq (\HasNoChildren)

shared.foobar (\HasNoChildren)

user.amilivojevic (\HasChildren)

user.amilivojevic.Drafts (\HasNoChildren)

user.amilivojevic.Sent Items (\HasNoChildren)

user.amilivojevic.Spam (\HasNoChildren)

user.amilivojevic.Templates (\HasNoChildren)

user.foobar (\HasChildren)

user.foobar.shared (\HasNoChildren)

user.foobar.shared-to-all (\HasNoChildren)

user.user2 (\HasChildren)

user.user2.shr (\HasNoChildren)



user.amilivojevic is my INBOX folder.  bureq and shared.* folders are, 
well, shared folders.  Some of the other user's folders inside user 
are also shared (folders with names ending with shared, shared-to-all, 
and shr).



The alternate namespace on Cyrus IMAPD is turned off.  In IMP's 
servers.php, folders and namespace are set to empty strings (I do want 
users to see folders as subfolders of INBOX, since that is the way 
their "normal" mail clients are set up).



There were two problems with folder dropdown list.  The first one 
seems to be solved in current version (user top-level folder was not 
displayed).



The second problem is still present.  The sorting is incorrect.   
Dropdown box looks like this:



INBOX

bureq

    Drafts

    Sent Items

    Spam

    Templates

shared.

    foobar

user.

    foobar.

       shared

       shared-to-all

    user2.

       shr



Clearly, this is not correct display.  Subfolders of INBOX are 
displayed as if they were subfolders of top-level "bureq" folder.



If I expand the list of folders on the left pane, than I get correct 
sorting and indentation.  The bug seems to be present only in the 
dropdown box that is located in the upper right corner of the page.



BTW, would it be possible to have non-selectable mailboxes rendered in 
different style (in left pane) and non-selectable in dropdown box?   
For example, top-level user and shared, as well as user.foobar and 
user.user2 are not selectable when I'm connected to Cyrus IMAPD as 
amilivojevic (for example, Mozilla Thunderbird renders those folders 
in grey, not allowing me to select them).

Saved Queries