diff options
author | alecpl <alec@alec.pl> | 2008-11-15 14:29:45 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2008-11-15 14:29:45 +0000 |
commit | e2e745fb4ee52b11063a1654663c018084584586 (patch) | |
tree | 3ade8a7dad08cc8cd7f1eca6c90962a313ea60de /program/lib/imap.inc | |
parent | 3d1e777b39479b7593966a2ad2db3d266c28de34 (diff) |
- don't use SORT when SEARCH is better (sort field not specified)
Diffstat (limited to 'program/lib/imap.inc')
-rw-r--r-- | program/lib/imap.inc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/program/lib/imap.inc b/program/lib/imap.inc index 8704e78f5..fb971db68 100644 --- a/program/lib/imap.inc +++ b/program/lib/imap.inc @@ -902,10 +902,7 @@ function iil_StrToTime($str) { function iil_C_Sort(&$conn, $mailbox, $field, $add='', $is_uid=FALSE, $encoding = 'US-ASCII') { - /* Do "SELECT" command */ - if (!iil_C_Select($conn, $mailbox)) { - return false; - } + $field = strtoupper($field); if ($field == 'INTERNALDATE') { $field = 'ARRIVAL'; @@ -917,6 +914,11 @@ function iil_C_Sort(&$conn, $mailbox, $field, $add='', $is_uid=FALSE, if (!$fields[$field]) { return false; } + + /* Do "SELECT" command */ + if (!iil_C_Select($conn, $mailbox)) { + return false; + } $is_uid = $is_uid ? 'UID ' : ''; @@ -924,16 +926,15 @@ function iil_C_Sort(&$conn, $mailbox, $field, $add='', $is_uid=FALSE, $add = " $add"; } - $fp = $conn->fp; $command = 's ' . $is_uid . 'SORT (' . $field . ') '; - $command .= $encoding . ' ALL ' . $add; + $command .= $encoding . ' ALL' . $add; $line = $data = ''; - if (!iil_PutLineC($fp, $command)) { + if (!iil_PutLineC($conn->fp, $command)) { return false; } do { - $line = chop(iil_ReadLine($fp, 1024)); + $line = chop(iil_ReadLine($conn->fp, 1024)); if (iil_StartsWith($line, '* SORT')) { $data .= ($data ? ' ' : '') . substr($line, 7); } else if (preg_match('/^[0-9 ]+$/', $line)) { |