summaryrefslogtreecommitdiff
path: root/program/steps/mail/func.inc
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:16:39 +0200
commit54b4790fcdfee4f66cb3aa5a1613906c2284016c (patch)
tree097ad5ca91d784a16000a39462aed8269508cfe0 /program/steps/mail/func.inc
parent2d233bf49c7d1eee76c2d0b9591a4576a99b5e66 (diff)
Fix so current page is reset on list-mode change (#1489907)
Conflicts: program/steps/mail/func.inc
Diffstat (limited to 'program/steps/mail/func.inc')
-rw-r--r--program/steps/mail/func.inc91
1 files changed, 57 insertions, 34 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 20ba29171..3f4362e00 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -23,40 +23,8 @@
// always instantiate storage object (but not connect to server yet)
$RCMAIL->storage_init();
-// set imap properties and session vars
-if (strlen(trim($mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true)))) {
- $RCMAIL->storage->set_folder(($_SESSION['mbox'] = $mbox));
-}
-else if ($RCMAIL->storage) {
- $_SESSION['mbox'] = $RCMAIL->storage->get_folder();
-}
-
-if (!empty($_GET['_page'])) {
- $RCMAIL->storage->set_page(($_SESSION['page'] = intval($_GET['_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'])
@@ -168,6 +136,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()