Skip to content

Commit

Permalink
Add option to set default message list mode - default_list_mode (#148…
Browse files Browse the repository at this point in the history
…7312)
  • Loading branch information
alecpl committed Jun 21, 2014
1 parent fc6dab3 commit cd01dc0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================

- Add option to set default message list mode - default_list_mode (#1487312)
- Close "no subject" prompt with Enter key (#1489580)
- Add config option to specify IMAP connection socket parameters - imap_conn_options (#1489948)
- Password: Add option to force new users to change their password (#1486884)
Expand Down
9 changes: 6 additions & 3 deletions config/defaults.inc.php
Expand Up @@ -978,9 +978,12 @@
// If true, after message delete/move, the next message will be displayed
$config['display_next'] = true;

// 0 - Do not expand threads
// 1 - Expand all threads automatically
// 2 - Expand only threads with unread messages
// Default messages listing mode. One of 'threads' or 'list'.
$config['default_list_mode'] = 'list';

// 0 - Do not expand threads
// 1 - Expand all threads automatically
// 2 - Expand only threads with unread messages
$config['autoexpand_threads'] = 0;

// When replying:
Expand Down
7 changes: 5 additions & 2 deletions program/steps/mail/func.inc
Expand Up @@ -166,6 +166,7 @@ function rcmail_init_env()
{
global $RCMAIL;

$default_threading = $RCMAIL->config->get('default_list_mode', 'list') == 'threads';
$a_threading = $RCMAIL->config->get('message_threading', array());
$message_sort_col = $RCMAIL->config->get('message_sort_col');
$message_sort_order = $RCMAIL->config->get('message_sort_order');
Expand Down Expand Up @@ -205,13 +206,15 @@ function rcmail_init_env()
$RCMAIL->storage->set_page($_SESSION['page'] = 1);
}

unset($a_threading[$_SESSION['mbox']]);
$a_threading[$_SESSION['mbox']] = false;
}

$RCMAIL->user->save_prefs(array('message_threading' => $a_threading));
}

$RCMAIL->storage->set_threading($a_threading[$_SESSION['mbox']]);
$threading = isset($a_threading[$_SESSION['mbox']]) ? $a_threading[$_SESSION['mbox']] : $default_threading;

$RCMAIL->storage->set_threading($threading);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions program/steps/settings/edit_folder.inc
Expand Up @@ -163,8 +163,10 @@ function rcmail_folder_form($attrib)
$value = (int) $_POST['_viewmode'];
}
else if (strlen($mbox_imap)) {
$a_threaded = $RCMAIL->config->get('message_threading', array());
$value = (int) isset($a_threaded[$mbox_imap]);
$a_threaded = $RCMAIL->config->get('message_threading', array());
$default_mode = $RCMAIL->config->get('default_list_mode', 'list');

$value = (int) (isset($a_threaded[$mbox_imap]) ? $a_threaded[$mbox_imap] : $default_mode == 'threads');
}

$form['props']['fieldsets']['settings']['content']['viewmode'] = array(
Expand Down
7 changes: 4 additions & 3 deletions program/steps/settings/folders.inc
Expand Up @@ -406,16 +406,17 @@ function rcmail_rename_folder($oldname, $newname)
$a_threaded = (array) $RCMAIL->config->get('message_threading', array());
$oldprefix = '/^' . preg_quote($oldname . $delimiter, '/') . '/';

foreach (array_keys($a_threaded) as $key) {
foreach ($a_threaded as $key => $val) {
if ($key == $oldname) {
unset($a_threaded[$key]);
$a_threaded[$newname] = true;
$a_threaded[$newname] = $val;
}
else if (preg_match($oldprefix, $key)) {
unset($a_threaded[$key]);
$a_threaded[preg_replace($oldprefix, $newname.$delimiter, $key)] = true;
$a_threaded[preg_replace($oldprefix, $newname.$delimiter, $key)] = $val;
}
}

$RCMAIL->user->save_prefs(array('message_threading' => $a_threaded));

// #1488692: update session
Expand Down
14 changes: 5 additions & 9 deletions program/steps/settings/save_folder.inc
Expand Up @@ -115,15 +115,13 @@ if (!$error && !strlen($old)) {
if (isset($_POST['_viewmode'])) {
$a_threaded = (array) $RCMAIL->config->get('message_threading', array());

if ($_POST['_viewmode'])
$a_threaded[$folder['name']] = true;
else
unset($a_threaded[$folder['name']]);
$a_threaded[$folder['name']] = (bool) $_POST['_viewmode'];

$RCMAIL->user->save_prefs(array('message_threading' => $a_threaded));
}

rcmail_update_folder_row($folder['name'], null, $folder['subscribe'], $folder['class']);

$OUTPUT->show_message('foldercreated', 'confirmation');
// reset folder preview frame
$OUTPUT->command('subscription_select');
Expand Down Expand Up @@ -167,14 +165,12 @@ else if (!$error) {
}
else if (preg_match($oldprefix, $key)) {
unset($a_threaded[$key]);
$a_threaded[preg_replace($oldprefix, $folder['name'].$delimiter, $key)] = true;
$a_threaded[preg_replace($oldprefix, $folder['name'].$delimiter, $key)] = $val;
}
}
}
if ($_POST['_viewmode'])
$a_threaded[$folder['name']] = true;
else
unset($a_threaded[$folder['name']]);

$a_threaded[$folder['name']] = (bool) $_POST['_viewmode'];

$RCMAIL->user->save_prefs(array('message_threading' => $a_threaded));
}
Expand Down

0 comments on commit cd01dc0

Please sign in to comment.