summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2014-05-21 19:11:49 +0200
committerAleksander Machniak <alec@alec.pl>2014-05-21 19:11:49 +0200
commitbb57fca320b95ed5537188bc77fceafc61123608 (patch)
tree5e9c913be68b35d9828562e7988bcb3d903d1f26 /program/steps/mail
parent8833432c61ff72d147cc0475074969771852c4b8 (diff)
Fix so current page is reset on list-mode change (#1489907)
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/func.inc90
1 files changed, 57 insertions, 33 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index a1d1a4163..54adf6b8b 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -23,39 +23,8 @@
// always instantiate storage object (but not connect to server yet)
$RCMAIL->storage_init();
-// set imap properties and session vars
-if (!strlen($mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true))) {
- $mbox = strlen($_SESSION['mbox']) ? $_SESSION['mbox'] : 'INBOX';
-}
-if (!($page = intval($_GET['_page']))) {
- $page = $_SESSION['page'] ? $_SESSION['page'] : 1;
-}
-
-$RCMAIL->storage->set_folder($_SESSION['mbox'] = $mbox);
-$RCMAIL->storage->set_page($_SESSION['page'] = $page);
-
-$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');
-
-// set default sort col/order to session
-if (!isset($_SESSION['sort_col'])) {
- $_SESSION['sort_col'] = $message_sort_col ? $message_sort_col : '';
-}
-if (!isset($_SESSION['sort_order'])) {
- $_SESSION['sort_order'] = strtoupper($message_sort_order) == 'ASC' ? 'ASC' : 'DESC';
-}
-
-// set threads mode
-if (isset($_GET['_threads'])) {
- if ($_GET['_threads'])
- $a_threading[$_SESSION['mbox']] = true;
- else
- unset($a_threading[$_SESSION['mbox']]);
-
- $RCMAIL->user->save_prefs(array('message_threading' => $a_threading));
-}
-$RCMAIL->storage->set_threading($a_threading[$_SESSION['mbox']]);
+// init environment - set current folder, page, list mode
+rcmail_init_env();
// set message set for search result
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'])
@@ -185,6 +154,61 @@ $RCMAIL->register_action_map(array(
/**
+ * Sets storage properties and session
+ */
+function rcmail_init_env()
+{
+ global $RCMAIL;
+
+ $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');
+
+ // set imap properties and session vars
+ if (!strlen($mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true))) {
+ $mbox = strlen($_SESSION['mbox']) ? $_SESSION['mbox'] : 'INBOX';
+ }
+ if (!($page = intval($_GET['_page']))) {
+ $page = $_SESSION['page'] ? $_SESSION['page'] : 1;
+ }
+
+ $RCMAIL->storage->set_folder($_SESSION['mbox'] = $mbox);
+ $RCMAIL->storage->set_page($_SESSION['page'] = $page);
+
+ // set default sort col/order to session
+ if (!isset($_SESSION['sort_col'])) {
+ $_SESSION['sort_col'] = $message_sort_col ? $message_sort_col : '';
+ }
+ if (!isset($_SESSION['sort_order'])) {
+ $_SESSION['sort_order'] = strtoupper($message_sort_order) == 'ASC' ? 'ASC' : 'DESC';
+ }
+
+ // set threads mode
+ if (isset($_GET['_threads'])) {
+ if ($_GET['_threads']) {
+ // re-set current page number when listing mode changes
+ if (!$a_threading[$_SESSION['mbox']]) {
+ $RCMAIL->storage->set_page($_SESSION['page'] = 1);
+ }
+
+ $a_threading[$_SESSION['mbox']] = true;
+ }
+ else {
+ // re-set current page number when listing mode changes
+ if ($a_threading[$_SESSION['mbox']]) {
+ $RCMAIL->storage->set_page($_SESSION['page'] = 1);
+ }
+
+ unset($a_threading[$_SESSION['mbox']]);
+ }
+
+ $RCMAIL->user->save_prefs(array('message_threading' => $a_threading));
+ }
+
+ $RCMAIL->storage->set_threading($a_threading[$_SESSION['mbox']]);
+}
+
+/**
* Returns default search mods
*/
function rcmail_search_mods()