diff options
Diffstat (limited to 'program/steps/settings')
-rw-r--r-- | program/steps/settings/func.inc | 24 | ||||
-rw-r--r-- | program/steps/settings/manage_folders.inc | 84 | ||||
-rw-r--r-- | program/steps/settings/save_prefs.inc | 2 |
3 files changed, 95 insertions, 15 deletions
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index 44225c715..421fb37bf 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -248,17 +248,6 @@ function rcmail_user_prefs($current=null) ); } - // Show checkbox for toggling 'index_sort' - if (!isset($no_override['index_sort'])) { - $field_id = 'rcmfd_indexsort'; - $input_indexsort = new html_checkbox(array('name' => '_index_sort', 'id' => $field_id, 'value' => 1)); - - $blocks['list']['options']['index_sort'] = array( - 'title' => html::label($field_id, Q(rcube_label('indexsort'))), - 'content' => $input_indexsort->show($config['index_sort']?1:0), - ); - } - // show drop-down for available skins if (!isset($no_override['skin'])) { $skins = rcmail_get_skins(); @@ -311,6 +300,19 @@ function rcmail_user_prefs($current=null) ); } + if (!isset($no_override['autoexpand_threads'])) { + $field_id = 'rcmfd_autoexpand_threads'; + $select_autoexpand_threads = new html_select(array('name' => '_autoexpand_threads', 'id' => $field_id)); + $select_autoexpand_threads->add(rcube_label('never'), 0); + $select_autoexpand_threads->add(rcube_label('do_expand'), 1); + $select_autoexpand_threads->add(rcube_label('expand_only_unread'), 2); + + $blocks['main']['options']['autoexpand_threads'] = array( + 'title' => html::label($field_id, Q(rcube_label('autoexpand_threads'))), + 'content' => $select_autoexpand_threads->show($config['autoexpand_threads']), + ); + } + 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/program/steps/settings/manage_folders.inc b/program/steps/settings/manage_folders.inc index 06fee7a87..fa5a4db70 100644 --- a/program/steps/settings/manage_folders.inc +++ b/program/steps/settings/manage_folders.inc @@ -38,6 +38,20 @@ 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, 'UTF7-IMAP')) + rcube_set_threading($mbox, true); + } + +// enable threading for one or more mailboxes +else if ($RCMAIL->action=='disable-threading') + { + if ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST, false, 'UTF7-IMAP')) + rcube_set_threading($mbox, false); + } + // create a new mailbox else if ($RCMAIL->action=='create-folder') { @@ -79,6 +93,24 @@ else if ($RCMAIL->action=='rename-folder') $rename = $IMAP->rename_mailbox($oldname, $name); } + // update per-folder options for modified folder and its subfolders + if ($rename) { + $a_threaded = $RCMAIL->config->get('message_threading', array()); + $delimiter = $IMAP->get_hierarchy_delimiter(); + $oldprefix = '/^' . preg_quote($oldname . $delimiter, '/') . '/'; + foreach ($a_threaded as $key => $val) + if ($key == $oldname) { + unset($a_threaded[$key]); + $a_threaded[$name] = true; + } + else if (preg_match($oldprefix, $key)) { + unset($a_threaded[$key]); + $a_threaded[preg_replace($oldprefix, $name.$delimiter, $key)] = true; + } + + $RCMAIL->user->save_prefs(array('message_threading' => $a_threaded)); + } + if ($rename && $OUTPUT->ajax_call) { $folderlist = $IMAP->list_unsubscribed(); @@ -159,7 +191,11 @@ if ($OUTPUT->ajax_call) // build table with all folders listed by server function rcube_subscription_form($attrib) { - global $IMAP, $CONFIG, $OUTPUT; + global $RCMAIL, $IMAP, $CONFIG, $OUTPUT; + + $threading_supported = $IMAP->get_capability('thread=references') + || $IMAP->get_capability('thread=orderedsubject') + || $IMAP->get_capability('thread=refs'); list($form_start, $form_end) = get_form_tags($attrib, 'folders'); unset($attrib['form']); @@ -173,15 +209,17 @@ 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', ' '); - // get folders from server $IMAP->clear_cache('mailboxes'); $a_unsubscribed = $IMAP->list_unsubscribed(); $a_subscribed = $IMAP->list_mailboxes(); + $a_threaded = $a_threaded_copy = $RCMAIL->config->get('message_threading', array()); $delimiter = $IMAP->get_hierarchy_delimiter(); $a_js_folders = $seen_folders = $list_folders = array(); @@ -203,14 +241,28 @@ function rcube_subscription_form($attrib) } } + unset($a_threaded_copy[$folder]); + $list_folders[] = array('id' => $folder, 'name' => $name, 'level' => $level); $seen[$folder]++; } + // remove 'message_threading' option for not existing folders + if ($a_threaded_copy) { + foreach ($a_threaded_copy as $key => $val) + unset($a_threaded[$key]); + unset($a_threaded_copy); + $RCMAIL->user->save_prefs(array('message_threading' => $a_threaded)); + } + $checkbox_subscribe = new html_checkbox(array( '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'))); @@ -226,6 +278,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']); @@ -238,9 +291,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']) { @@ -335,6 +392,27 @@ function rcube_rename_folder_form($attrib) return $out; } + +// (un)set 'threading' for selected folder +function rcube_set_threading($mbox, $state=true) + { + global $RCMAIL; + $mbox = (array)$mbox; + $a_prefs = (array)$RCMAIL->config->get('message_threading'); + + if ($state) { + foreach ($mbox as $box) + $a_prefs[$box] = true; + } + else { + foreach ($mbox as $box) + unset($a_prefs[$box]); + } + + $RCMAIL->user->save_prefs(array('message_threading' => $a_prefs)); + } + + $OUTPUT->set_pagetitle(rcube_label('folders')); $OUTPUT->include_script('list.js'); diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc index eeb64034c..4eebef291 100644 --- a/program/steps/settings/save_prefs.inc +++ b/program/steps/settings/save_prefs.inc @@ -32,7 +32,6 @@ switch ($CURR_SECTION) 'timezone' => isset($_POST['_timezone']) ? (is_numeric($_POST['_timezone']) ? floatval($_POST['_timezone']) : get_input_value('_timezone', RCUBE_INPUT_POST)) : $CONFIG['timezone'], 'dst_active' => isset($_POST['_dst_active']) ? TRUE : FALSE, 'pagesize' => is_numeric($_POST['_pagesize']) ? max(2, intval($_POST['_pagesize'])) : $CONFIG['pagesize'], - 'index_sort' => isset($_POST['_index_sort']) ? TRUE : FALSE, 'prettydate' => isset($_POST['_pretty_date']) ? TRUE : FALSE, 'skin' => isset($_POST['_skin']) ? get_input_value('_skin', RCUBE_INPUT_POST) : $CONFIG['skin'], ); @@ -42,6 +41,7 @@ switch ($CURR_SECTION) $a_user_prefs = array( 'focus_on_new_message' => isset($_POST['_focus_on_new_message']) ? TRUE : FALSE, 'preview_pane' => isset($_POST['_preview_pane']) ? TRUE : FALSE, + 'autoexpand_threads' => isset($_POST['_autoexpand_threads']) ? intval($_POST['_autoexpand_threads']) : 0, 'mdn_requests' => isset($_POST['_mdn_requests']) ? intval($_POST['_mdn_requests']) : 0, 'keep_alive' => isset($_POST['_keep_alive']) ? intval($_POST['_keep_alive'])*60 : $CONFIG['keep_alive'], 'check_all_folders' => isset($_POST['_check_all_folders']) ? TRUE : FALSE, |