From 32ea464bdfe5f8a22f46bfac50dcdc26c36fc497 Mon Sep 17 00:00:00 2001 From: Nathan Kinkade Date: Thu, 5 Mar 2009 20:48:46 +0000 Subject: Applied message threading patch from Chris January: http://www.atomice.com/blog/?p=33 --- roundcubemail/program/steps/settings/func.inc | 2 ++ .../program/steps/settings/manage_folders.inc | 38 +++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'roundcubemail/program/steps/settings') diff --git a/roundcubemail/program/steps/settings/func.inc b/roundcubemail/program/steps/settings/func.inc index d0a3ae69c..6515ae4f6 100644 --- a/roundcubemail/program/steps/settings/func.inc +++ b/roundcubemail/program/steps/settings/func.inc @@ -168,6 +168,8 @@ function rcmail_user_prefs_block($part, $no_override, $attrib) case 'mailbox': $table = new html_table(array('cols' => 2)); + $RCMAIL->imap_init(true); + if (!isset($no_override['focus_on_new_message'])) { $field_id = 'rcmfd_focus_on_new_message'; $input_focus_on_new_message = new html_checkbox(array('name' => '_focus_on_new_message', 'id' => $field_id, 'value' => 1)); diff --git a/roundcubemail/program/steps/settings/manage_folders.inc b/roundcubemail/program/steps/settings/manage_folders.inc index 9affded98..80a6b7c65 100644 --- a/roundcubemail/program/steps/settings/manage_folders.inc +++ b/roundcubemail/program/steps/settings/manage_folders.inc @@ -38,6 +38,28 @@ else if ($RCMAIL->action=='unsubscribe') $IMAP->unsubscribe(array($mbox)); } +// enable threading for one or more mailboxes +else if ($RCMAIL->action=='enable-threading') + { + if ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST, false, 'UTF-7')) + $a_user_prefs = $USER->get_prefs(); + if (!is_array($a_user_prefs['message_threading'])) + $a_user_prefs['message_threading'] = array(); + $a_user_prefs['message_threading'][$mbox] = true; + $USER->save_prefs($a_user_prefs); + } + +// enable threading for one or more mailboxes +else if ($RCMAIL->action=='disable-threading') + { + if ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST, false, 'UTF-7')) + $a_user_prefs = $USER->get_prefs(); + if (!is_array($a_user_prefs['message_threading'])) + $a_user_prefs['message_threading'] = array(); + unset($a_user_prefs['message_threading'][$mbox]); + $USER->save_prefs($a_user_prefs); + } + // create a new mailbox else if ($RCMAIL->action=='create-folder') { @@ -162,6 +184,8 @@ function rcube_subscription_form($attrib) { global $IMAP, $CONFIG, $OUTPUT; + $threading_supported = $IMAP->get_capability('thread=references'); + list($form_start, $form_end) = get_form_tags($attrib, 'folders'); unset($attrib['form']); @@ -174,6 +198,8 @@ function rcube_subscription_form($attrib) $table->add_header('name', rcube_label('foldername')); $table->add_header('msgcount', rcube_label('messagecount')); $table->add_header('subscribed', rcube_label('subscribed')); + if ($threading_supported) + $table->add_header('threaded', rcube_label('threaded')); $table->add_header('rename', ' '); $table->add_header('delete', ' '); @@ -183,6 +209,7 @@ function rcube_subscription_form($attrib) $a_unsubscribed = $IMAP->list_unsubscribed(); $a_subscribed = $IMAP->list_mailboxes(); + $a_threaded =rcmail::get_instance()->config->get('message_threading', array()); $delimiter = $IMAP->get_hierarchy_delimiter(); $a_js_folders = $seen_folders = $list_folders = array(); @@ -212,6 +239,10 @@ function rcube_subscription_form($attrib) 'name' => '_subscribed[]', 'onclick' => JS_OBJECT_NAME.".command(this.checked?'subscribe':'unsubscribe',this.value)", )); + $checkbox_threaded = new html_checkbox(array( + 'name' => '_threaded[]', + 'onclick' => JS_OBJECT_NAME.".command(this.checked?'enable-threading':'disable-threading',this.value)", + )); if (!empty($attrib['deleteicon'])) $del_button = html::img(array('src' => $CONFIG['skin_path'] . $attrib['deleteicon'], 'alt' => rcube_label('delete'))); @@ -227,6 +258,7 @@ function rcube_subscription_form($attrib) foreach ($list_folders as $i => $folder) { $idx = $i + 1; $subscribed = in_array($folder['id'], $a_subscribed); + $threaded = $a_threaded[$folder['id']]; $protected = ($CONFIG['protect_default_folders'] == true && in_array($folder['id'], $CONFIG['default_imap_folders'])); $classes = array($i%2 ? 'even' : 'odd'); $folder_js = JQ($folder['id']); @@ -239,9 +271,13 @@ function rcube_subscription_form($attrib) $table->add_row(array('id' => 'rcmrow'.$idx, 'class' => join(' ', $classes))); $table->add('name', Q($display_folder)); - $table->add('msgcount', ($folder['virtual'] ? '' : $IMAP->messagecount($folder['id']))); + $table->add('msgcount', ($folder['virtual'] ? '' : $IMAP->messagecount($folder['id']))); // XXX: Use THREADS or ALL? $table->add('subscribed', ($protected || $folder['virtual']) ? ($subscribed ? ' •' : ' ') : $checkbox_subscribe->show(($subscribed ? $folder_utf8 : ''), array('value' => $folder_utf8))); + if ($IMAP->get_capability('thread=references')) { + $table->add('threaded', + $checkbox_threaded->show(($threaded ? $folder_utf8 : ''), array('value' => $folder_utf8))); + } // add rename and delete buttons if (!$protected && !$folder['virtual']) { -- cgit v1.2.3