diff options
| author | Nathan Kinkade <nkinkade@nkinka.de> | 2009-03-15 20:00:02 +0000 |
|---|---|---|
| committer | Nathan Kinkade <nkinkade@nkinka.de> | 2009-03-15 20:00:02 +0000 |
| commit | 8018757b75262d009bc6611be76bf4696d549caa (patch) | |
| tree | a4d36e5c2f5de3137144362c8e27af2c8c2742e2 /roundcubemail/program | |
| parent | 945604dcb6805965ed498e690b003770fa619210 (diff) | |
Change-set to let the IMAP server do the sensible sorting of threads i.e. sort threads by newest in-thread messages rather than simply by the root thread message.
Diffstat (limited to 'roundcubemail/program')
| -rw-r--r-- | roundcubemail/program/include/rcube_imap.php | 23 | ||||
| -rw-r--r-- | roundcubemail/program/js/app.js | 11 | ||||
| -rw-r--r-- | roundcubemail/program/steps/mail/func.inc | 8 |
3 files changed, 33 insertions, 9 deletions
diff --git a/roundcubemail/program/include/rcube_imap.php b/roundcubemail/program/include/rcube_imap.php index 2f3a49cb1..b8c44fcae 100644 --- a/roundcubemail/program/include/rcube_imap.php +++ b/roundcubemail/program/include/rcube_imap.php @@ -48,8 +48,8 @@ class rcube_imap var $mailbox = 'INBOX'; var $list_page = 1; var $page_size = 10; - var $sort_field = 'date'; - var $sort_order = 'DESC'; + var $sort_field = NULL; + var $sort_order = NULL; var $delimiter = NULL; var $caching_enabled = FALSE; var $thread_caching_enabled = FALSE; @@ -545,7 +545,7 @@ class rcube_imap if ($sql_arr = $this->db->fetch_array($sql_result)) return $sql_arr[0]; } - list ($thread_tree, $msg_depth, $has_children) = iil_C_Thread($this->conn, $mailbox, 'REFERENCES', 'ALL'); + list ($thread_tree, $msg_depth, $has_children) = iil_C_Thread($this->conn, $mailbox, rcmail::get_instance()->config->get('imap_thread_algorithm'), 'ALL'); $this->update_thread_cache($mailbox, $thread_tree, $msg_depth, $has_children); return count($thread_tree); } @@ -620,7 +620,7 @@ class rcube_imap $msg_depth = $this->cache['__threads']['depth']; $has_children = $this->cache['__threads']['has_children']; } else { - list ($thread_tree, $msg_depth, $has_children) = iil_C_Thread($this->conn, $mailbox, 'REFERENCES', 'ALL'); + list ($thread_tree, $msg_depth, $has_children) = iil_C_Thread($this->conn, $mailbox, rcmail::get_instance()->config->get('imap_thread_algorithm'), 'ALL'); } $this->update_thread_cache($mailbox, $thread_tree, $msg_depth, $has_children); // the keys of thread_tree are the thread roots @@ -640,6 +640,8 @@ class rcube_imap // sort the roots according to the order defined by $sort_index $sorter = new rcube_thread_root_sorter(); $sorter->set_sequence_numbers($sort_index); + if (isset($this->sort_order)) + $sorter->default_sort = false; $sorter->sort_threads($roots); // get the roots for this page @@ -647,7 +649,7 @@ class rcube_imap } if ($thread_cache_status > 0) { - // get the children of $roots from the cache + // get the children of $roots from the cache $threads = $this->get_thread_cache_threads($mailbox, $roots); $msg_index = array (); $msg_depth = array (); @@ -3528,6 +3530,11 @@ class rcube_thread_root_sorter { var $sequence_numbers = array (); + // If this is true then we override any sorting + // and let the IMAP server do it, otherwise try + // to sort according to the user request. + var $default_sort = true; + /** * Set the predetermined sort order. * @@ -3545,6 +3552,12 @@ class rcube_thread_root_sorter */ function sort_threads(& $threads) { + if ($this->default_sort) + { + $threads = array_reverse($threads); + return; + } + usort($threads, array ( $this, "compare_seqnums" diff --git a/roundcubemail/program/js/app.js b/roundcubemail/program/js/app.js index 626756af6..9c0fafed9 100644 --- a/roundcubemail/program/js/app.js +++ b/roundcubemail/program/js/app.js @@ -3655,9 +3655,16 @@ function rcube_webmail() { for (var i=1;i<depth;i++) tree += '<div class="branch"> </div>'; - tree += flags.has_children?'<div id="rcmexpando' + uid + '" class="' + (message.expanded?'expanded':'collapsed') + '"> </div>':'<div class="leaf"> </div>'; + var toggle_exp = (message.unread_children > 0) ? 'expanded' : 'collapsed'; + tree += flags.has_children?'<div id="rcmexpando' + uid + '" class="' + toggle_exp + '"> </div>':'<div class="leaf"> </div>'; + //tree += flags.has_children?'<div id="rcmexpando' + uid + '" class="' + (message.expanded?'expanded':'collapsed') + '"> </div>':'<div class="leaf"> </div>'; if (depth > 1) - row.style.display = 'none'; + { + if (message.unread_children > 0 || message.unread) + row.style.display = ''; + else + row.style.display = 'none'; + } } tree += icon ? '<img src="'+icon+'" alt="" />' : ''; diff --git a/roundcubemail/program/steps/mail/func.inc b/roundcubemail/program/steps/mail/func.inc index bac49463e..f9c1d951d 100644 --- a/roundcubemail/program/steps/mail/func.inc +++ b/roundcubemail/program/steps/mail/func.inc @@ -297,7 +297,7 @@ function rcmail_message_list($attrib) $header->deleted ? ' deleted' : '', $header->flagged ? ' flagged' : '', $zebra_class, - ($header->depth > 1) ? ' style="display: none"' : ''); + ($header->depth > 1 && $header->unread_children == 0 && $header->seen) ? 'style="display: none"' : ''); $tree = ''; $depth = $header->depth; @@ -305,7 +305,11 @@ function rcmail_message_list($attrib) { for ($i=1;$i<$depth;$i++) $tree .= '<div class="branch"> </div>'; - $tree .= $header->has_children?'<div id="rcmexpando' . $header->uid . '" class="collapsed"> </div>':'<div class="leaf"> </div>'; + $toggle_expanded = $header->unread_children ? 'expanded' : 'collapsed'; + // mark the row as expanded for the JS code + if ($toggle_expanded == 'expanded') + $js_row_arr['expanded'] = true; + $tree .= $header->has_children?'<div id="rcmexpando' . $header->uid . '" class="' . $toggle_expanded . '"> </div>':'<div class="leaf"> </div>'; } $tree .= $message_icon ? sprintf($image_tag, $skin_path, $message_icon, '') : ''; |
