#2689 Sort by 'TO' fails in Sent folder

closed-fixed
5
2010-01-12
2009-12-02
Pete Horn
No

Sort by 'TO' fails in Sent folder

Squirrelmail versions 1.4.20 SVN, Also 1.4.19, 1.4.15 (plus earlier 1.4.9a ?)
System: Apache 2.2.14 (debian) PHP 5.2.11-1 Courier IMAP 4.6.0

Config settings
$allow_thread_sort = false;
$allow_server_sort = false;

When in Sent folder, a sort by 'To' actually results in a sort by 'From', though the 'To' addresses are displayed.

This is because though the functions that write the message column header and the message list use the function 'handleAsSent()' to determine whether to use 'from' or 'to' data the associated sort function doesn't.

In 1.4.20 SVN:

First ommission is in /functions/imap_messages.php below '/* non server sort stuff */' there is no handling for a 'TO-SORT'

To fix:

/* non server sort stuff */
if (!$allow_server_sort) {
$from = parseAddress($from);
if ($from[0][1]) {
$from = decodeHeader($from[0][1], true, false);
} else {
$from = $from[0][0];
}
$messages[$msgi]['FROM-SORT'] = $from;

becomes:
/* non server sort stuff */
if (!$allow_server_sort) {
$from = parseAddress($from);
if ($from[0][1]) {
$from = decodeHeader($from[0][1], true, false);
} else {
$from = $from[0][0];
}
$messages[$msgi]['FROM-SORT'] = $from;

/* above section repeated to enable TO-SORT 'to' replaces 'from' (Pete Horn) *
* I'll confess to not knowing exactly what this is doing (Pete Horn */
$to = parseAddress($to);
if ($to[0][1]) {
$to = decodeHeader($to[0][1], true, false);
} else {
$to = $to[0][0];
}
$messages[$msgi]['TO-SORT'] = $to;
/* end of Pete Horn addition */

This is called from /functions/mailbox_display.php, namely from the function calc_msort() where FROM-SORT is called regardless of the type of mailbox folder. This needs an if..else.. to introduce the TO-SORT option.

To fix:

} elseif (($sort == 2) || ($sort == 3)) {
foreach ($msgs as $item) {
$msort[] = $item['FROM-SORT'];
}
}

becomes:

} elseif (($sort == 2) || ($sort == 3)) {

/* alternative sort needed for Sent folder (Pete Horn)
* '$mailbox' added to argument list for this function (line 548 - if this is line 570)
* and in calling function 'showMessagesForMailbox()' (line 490)
* and also in function 'printSearchMessages()' in /src/search.php (line 229)
*
* New if..else.. inserted in this elseif by Pete Horn
*/
if (handleAsSent($mailbox)) {
// new TO sort
foreach ($msgs as $item) {
$msort[] = $item['TO-SORT'];
}
} else {
// old FROM sort
foreach ($msgs as $item) {
$msort[] = $item['FROM-SORT'];
}
}
/* end of Pete Horn addition */

}

This uses the argument '$mailbox' so this needs including in the function declaration and in argument lists for the two functions that call 'calc_msort()', These are 'showMessagesForMailbox()' also in /functions/mailbox_display.php and 'printSearchMessages()' in /src/search.php

I am very amateur - this is the first time I have touched php, and the first time I have got involved in open source programming - so please be gentle with me :)

I'll try to attach gzip versions of the three 1.4.20 SVN files I modified. My changes are flagged with 'Pete Horn'.

Discussion

  • Pete Horn

    Pete Horn - 2009-12-02

    modified file

     
  • Pete Horn

    Pete Horn - 2009-12-02

    modified file

     
  • Pete Horn

    Pete Horn - 2009-12-02

    Someone suggested I should include a diff file. I've done that after stripping out my comments, It will be uploaded.

     
  • Pete Horn

    Pete Horn - 2009-12-02

    Diff file

     
  • Jonathan Angliss

    Modified fix committed to SVN. Thanks for the catch.

     
  • Jonathan Angliss

    • assigned_to: nobody --> jangliss
    • status: open --> open-fixed
     
  • Jonathan Angliss

    • status: open-fixed --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks