summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-09-18 09:02:35 +0000
committeralecpl <alec@alec.pl>2011-09-18 09:02:35 +0000
commit609d3923d7dc674263ddea990387dbf5488fabc6 (patch)
tree8d7be69aa280e7d5848a23d2215fb85688514d4e /program/steps/mail
parent30f50556c130e272d9eb6ddcd11ea70a18a4e711 (diff)
- Cache synchronization using QRESYNC/CONDSTORE
- Fixed message ID updates in cache - Changed message flags handling + some fixes (e.g. fixed messages listing after delete)
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/check_recent.inc12
-rw-r--r--program/steps/mail/compose.inc6
-rw-r--r--program/steps/mail/func.inc15
-rw-r--r--program/steps/mail/list.inc5
-rw-r--r--program/steps/mail/move_del.inc2
-rw-r--r--program/steps/mail/show.inc20
6 files changed, 32 insertions, 28 deletions
diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc
index 0eab345ec..c7d607cf9 100644
--- a/program/steps/mail/check_recent.inc
+++ b/program/steps/mail/check_recent.inc
@@ -34,16 +34,24 @@ else {
// check recent/unseen counts
foreach ($a_mailboxes as $mbox_name) {
+ $is_current = $mbox_name == $current;
+ if ($is_current) {
+ // Synchronize mailbox cache, handle flag changes
+ $IMAP->mailbox_sync($mbox_name);
+ }
+
+ // Get mailbox status
$status = $IMAP->mailbox_status($mbox_name);
if ($status & 1) {
// trigger plugin hook
- $RCMAIL->plugins->exec_hook('new_messages', array('mailbox' => $mbox_name));
+ $RCMAIL->plugins->exec_hook('new_messages',
+ array('mailbox' => $mbox_name, 'is_current' => $is_current));
}
rcmail_send_unread_count($mbox_name, true);
- if ($status && $mbox_name == $current) {
+ if ($status && $is_current) {
// refresh saved search set
$search_request = get_input_value('_search', RCUBE_INPUT_GPC);
if ($search_request && isset($_SESSION['search'])
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 4307c36d0..ade2738db 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -156,14 +156,14 @@ if (!empty($msg_uid))
// re-set 'prefer_html' to have possibility to use html part for compose
$CONFIG['prefer_html'] = $CONFIG['prefer_html'] || $CONFIG['htmleditor'] || $compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT;
$MESSAGE = new rcube_message($msg_uid);
-
+
// make sure message is marked as read
- if ($MESSAGE && $MESSAGE->headers && !$MESSAGE->headers->seen)
+ if ($MESSAGE && $MESSAGE->headers && empty($MESSAGE->headers->flags['SEEN']))
$IMAP->set_flag($msg_uid, 'SEEN');
if (!empty($MESSAGE->headers->charset))
$IMAP->set_charset($MESSAGE->headers->charset);
-
+
if ($compose_mode == RCUBE_COMPOSE_REPLY)
{
$_SESSION['compose']['reply_uid'] = $msg_uid;
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 36b18ce48..cbcc71afa 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -287,6 +287,7 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null
$a_msg_cols[$col] = $cont;
}
+ $a_msg_flags = array_change_key_case(array_map('intval', (array) $header->flags));
if ($header->depth)
$a_msg_flags['depth'] = $header->depth;
else if ($header->has_children)
@@ -297,16 +298,6 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null
$a_msg_flags['has_children'] = $header->has_children;
if ($header->unread_children)
$a_msg_flags['unread_children'] = $header->unread_children;
- if ($header->deleted)
- $a_msg_flags['deleted'] = 1;
- if (!$header->seen)
- $a_msg_flags['unread'] = 1;
- if ($header->answered)
- $a_msg_flags['replied'] = 1;
- if ($header->forwarded)
- $a_msg_flags['forwarded'] = 1;
- if ($header->flagged)
- $a_msg_flags['flagged'] = 1;
if ($header->others['list-post'])
$a_msg_flags['ml'] = 1;
if ($header->priority)
@@ -315,7 +306,7 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null
$a_msg_flags['ctype'] = Q($header->ctype);
$a_msg_flags['mbox'] = $mbox;
- // merge with plugin result
+ // merge with plugin result (Deprecated, use $header->flags)
if (!empty($header->list_flags) && is_array($header->list_flags))
$a_msg_flags = array_merge($a_msg_flags, $header->list_flags);
if (!empty($header->list_cols) && is_array($header->list_cols))
@@ -1454,7 +1445,7 @@ function rcmail_send_mdn($message, &$smtp_error)
if (!is_object($message) || !is_a($message, 'rcube_message'))
$message = new rcube_message($message);
- if ($message->headers->mdn_to && !$message->headers->mdnsent &&
+ if ($message->headers->mdn_to && empty($message->headers->flags['MDNSENT']) &&
($IMAP->check_permflag('MDNSENT') || $IMAP->check_permflag('*')))
{
$identity = $RCMAIL->user->get_identity();
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index dac7ff5e2..1f6c21e43 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -53,6 +53,9 @@ if ($save_arr)
$mbox_name = $IMAP->get_mailbox_name();
+// Synchronize mailbox cache, handle flag changes
+$IMAP->mailbox_sync($mbox_name);
+
// initialize searching result if search_filter is used
if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL')
{
@@ -116,5 +119,3 @@ else {
// send response
$OUTPUT->send();
-
-
diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc
index 8ce770102..e77979add 100644
--- a/program/steps/mail/move_del.inc
+++ b/program/steps/mail/move_del.inc
@@ -116,7 +116,7 @@ else
rcmail_set_unseen_count($mbox, $unseen_count);
}
- if ($RCMAIL->action=='moveto' && strlen($target)) {
+ if ($RCMAIL->action == 'moveto' && strlen($target)) {
rcmail_send_unread_count($target, true);
}
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index ba172c7ae..0766583a4 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -76,12 +76,13 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
'movingmessage', 'deletingmessage');
// check for unset disposition notification
- if ($MESSAGE->headers->mdn_to &&
- !$MESSAGE->headers->mdnsent && !$MESSAGE->headers->seen &&
- ($IMAP->check_permflag('MDNSENT') || $IMAP->check_permflag('*')) &&
- $mbox_name != $CONFIG['drafts_mbox'] &&
- $mbox_name != $CONFIG['sent_mbox'])
- {
+ if ($MESSAGE->headers->mdn_to
+ && empty($MESSAGE->headers->flags['MDNSENT'])
+ && empty($MESSAGE->headers->flags['SEEN'])
+ && ($IMAP->check_permflag('MDNSENT') || $IMAP->check_permflag('*'))
+ && $mbox_name != $CONFIG['drafts_mbox']
+ && $mbox_name != $CONFIG['sent_mbox']
+ ) {
$mdn_cfg = intval($CONFIG['mdn_requests']);
if ($mdn_cfg == 1 || (($mdn_cfg == 3 || $mdn_cfg == 4) && rcmail_contact_exists($MESSAGE->sender['mailto']))) {
@@ -100,9 +101,12 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
}
}
- if (!$MESSAGE->headers->seen && ($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0)))
+ if (empty($MESSAGE->headers->flags['SEEN'])
+ && ($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0))
+ ) {
$RCMAIL->plugins->exec_hook('message_read', array('uid' => $MESSAGE->uid,
'mailbox' => $mbox_name, 'message' => $MESSAGE));
+ }
}
@@ -199,7 +203,7 @@ else
// mark message as read
-if ($MESSAGE && $MESSAGE->headers && !$MESSAGE->headers->seen &&
+if ($MESSAGE && $MESSAGE->headers && empty($MESSAGE->headers->flags['SEEN']) &&
($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0)))
{
if ($IMAP->set_flag($MESSAGE->uid, 'SEEN')) {