summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/folders.inc4
-rw-r--r--program/steps/mail/func.inc26
-rw-r--r--program/steps/mail/getunread.inc13
-rw-r--r--program/steps/mail/mark.inc4
-rw-r--r--program/steps/mail/move_del.inc6
-rw-r--r--program/steps/mail/show.inc7
6 files changed, 43 insertions, 17 deletions
diff --git a/program/steps/mail/folders.inc b/program/steps/mail/folders.inc
index 26f464b0c..a74e61615 100644
--- a/program/steps/mail/folders.inc
+++ b/program/steps/mail/folders.inc
@@ -53,7 +53,7 @@ else if ($RCMAIL->action=='purge')
|| preg_match($trash_regexp, $mbox) || preg_match($junk_regexp, $mbox))
{
$success = $IMAP->clear_mailbox($mbox);
-
+
if ($success && !empty($_REQUEST['_reload']))
{
$OUTPUT->set_env('messagecount', 0);
@@ -62,7 +62,7 @@ else if ($RCMAIL->action=='purge')
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text());
$OUTPUT->command('set_unread_count', $mbox, 0);
$OUTPUT->command('set_quota', rcmail_quota_content());
- $_SESSION['unseen_count'][$mbox] = 0;
+ rcmail_set_unseen_count($mbox, 0);
}
else
$commands = "// purged: $success";
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index c7498d5b1..4803956b6 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -545,7 +545,7 @@ function rcmail_send_unread_count($mbox_name, $force=false, $count=null)
{
global $RCMAIL;
- $old_unseen = $_SESSION['unseen_count'][$mbox_name];
+ $old_unseen = rcmail_get_unseen_count($mbox_name);
if ($count === null)
$unseen = $RCMAIL->imap->messagecount($mbox_name, 'UNSEEN', $force);
@@ -555,13 +555,33 @@ function rcmail_send_unread_count($mbox_name, $force=false, $count=null)
if ($unseen != $old_unseen || ($mbox_name == 'INBOX'))
$RCMAIL->output->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX'));
- // @TODO: this data is doubled (session and cache tables) if caching is enabled
- $_SESSION['unseen_count'][$mbox_name] = $unseen;
+ rcmail_set_unseen_count($mbox_name, $unseen);
return $unseen;
}
+function rcmail_set_unseen_count($mbox_name, $count)
+{
+ // @TODO: this data is doubled (session and cache tables) if caching is enabled
+
+ // Make sure we have an array here (#1487066)
+ if (!is_array($_SESSION['unseen_count']))
+ $_SESSION['unseen_count'] = array();
+
+ $_SESSION['unseen_count'][$mbox_name] = $count;
+}
+
+
+function rcmail_get_unseen_count($mbox_name)
+{
+ if (is_array($_SESSION['unseen_count']) && array_key_exists($mbox_name, $_SESSION['unseen_count']))
+ return $_SESSION['unseen_count'][$mbox_name];
+ else
+ return null;
+}
+
+
/**
* Sets message is_safe flag according to 'show_images' option value
*
diff --git a/program/steps/mail/getunread.inc b/program/steps/mail/getunread.inc
index a035f5204..e60f36cae 100644
--- a/program/steps/mail/getunread.inc
+++ b/program/steps/mail/getunread.inc
@@ -28,15 +28,18 @@ if (!empty($a_folders))
$check_all = (bool)$RCMAIL->config->get('check_all_folders');
foreach ($a_folders as $mbox_row) {
- if (!$check_all && isset($_SESSION['unseen_count'][$mbox_row]) && $mbox_row != $current)
- $unseen = $_SESSION['unseen_count'][$mbox_row];
+ $unseen_old = rcmail_get_unseen_count($mbox_row);
+
+ if (!$check_all && $unseen_old !== null && $mbox_row != $current)
+ $unseen = $unseen_old;
else
- $unseen = $IMAP->messagecount($mbox_row, 'UNSEEN', !isset($_SESSION['unseen_count'][$mbox_row]));
+ $unseen = $IMAP->messagecount($mbox_row, 'UNSEEN', $unseen_old === null);
- if ($unseen || !isset($_SESSION['unseen_count'][$mbox_row])) {
+ if ($unseen || $unseen_old === null) {
$OUTPUT->command('set_unread_count', $mbox_row, $unseen, $inbox && $mbox_row == 'INBOX');
}
- $_SESSION['unseen_count'][$mbox_row] = $unseen;
+
+ rcmail_set_unseen_count($mbox_row, $unseen);
}
}
diff --git a/program/steps/mail/mark.inc b/program/steps/mail/mark.inc
index 5411e3f46..65a8fc6ba 100644
--- a/program/steps/mail/mark.inc
+++ b/program/steps/mail/mark.inc
@@ -98,11 +98,11 @@ if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_va
// update mailboxlist
$mbox = $IMAP->get_mailbox_name();
$unseen_count = $msg_count ? $IMAP->messagecount($mbox, 'UNSEEN') : 0;
- $old_unseen = $_SESSION['unseen_count'][$mbox];
+ $old_unseen = rcmail_get_unseen_count($mbox);
if ($old_unseen != $unseen_count) {
$OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
- $_SESSION['unseen_count'][$mbox] = $unseen_count;
+ rcmail_set_unseen_count($mbox, $unseen_count);
}
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc
index 3940b6db9..06bef0dc6 100644
--- a/program/steps/mail/move_del.inc
+++ b/program/steps/mail/move_del.inc
@@ -109,11 +109,11 @@ else
// update mailboxlist
$mbox = $IMAP->get_mailbox_name();
$unseen_count = $msg_count ? $IMAP->messagecount($mbox, 'UNSEEN') : 0;
- $old_unseen = $_SESSION['unseen_count'][$mbox];
-
+ $old_unseen = rcmail_get_unseen_count($mbox);
+
if ($old_unseen != $unseen_count) {
$OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
- $_SESSION['unseen_count'][$mbox] = $unseen_count;
+ rcmail_set_unseen_count($mbox, $unseen_count);
}
if ($RCMAIL->action=='moveto' && strlen($target)) {
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index e660207cd..45dd8e168 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -196,8 +196,11 @@ else
if ($MESSAGE && $MESSAGE->headers && !$MESSAGE->headers->seen &&
($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0)))
{
- if ($IMAP->set_flag($MESSAGE->uid, 'SEEN') && $_SESSION['unseen_count'][$mbox_name])
- $_SESSION['unseen_count'][$mbox_name] -= 1;
+ if ($IMAP->set_flag($MESSAGE->uid, 'SEEN')) {
+ if ($count = rcmail_get_unseen_count($mbox_name)) {
+ rcmail_set_unseen_count($mbox_name, $count - 1);
+ }
+ }
}
exit;