From ac0fc383fd43e8955b0ab22f70463159b14c74b0 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 23 Dec 2013 11:33:41 +0100 Subject: Fix so message flags modified by another client are applied on the list on refresh (#1485186) --- program/steps/mail/check_recent.inc | 18 ++++++++++++++++++ program/steps/mail/list.inc | 11 +++++++++-- program/steps/mail/search.inc | 7 +++++++ 3 files changed, 34 insertions(+), 2 deletions(-) (limited to 'program/steps') diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc index 3aa7b3e9c..60da68a96 100644 --- a/program/steps/mail/check_recent.inc +++ b/program/steps/mail/check_recent.inc @@ -114,6 +114,24 @@ foreach ($a_mailboxes as $mbox_name) { $OUTPUT->command('update_selection'); } } + // handle flag updates + else if ($is_current && ($uids = rcube_utils::get_input_value('_uids', rcube_utils::INPUT_GPC))) { + $data = $RCMAIL->storage->folder_data($mbox_name); + + if (empty($_SESSION['list_mod_seq']) || $_SESSION['list_mod_seq'] != $data['HIGHESTMODSEQ']) { + $flags = $RCMAIL->storage->list_flags($mbox_name, explode(',', $uids), $_SESSION['list_mod_seq']); + foreach ($flags as $idx => $row) { + $flags[$idx] = array_change_key_case(array_map('intval', $row)); + } + + // remember last HIGHESTMODSEQ value (if supported) + if (!empty($data['HIGHESTMODSEQ'])) { + $_SESSION['list_mod_seq'] = $data['HIGHESTMODSEQ']; + } + + $RCMAIL->output->set_env('recent_flags', $flags); + } + } } // trigger refresh hook diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc index fe7991c29..91c53e852 100644 --- a/program/steps/mail/list.inc +++ b/program/steps/mail/list.inc @@ -23,8 +23,8 @@ if (!$OUTPUT->ajax_call) { return; } -$save_arr = array(); -$dont_override = (array) $RCMAIL->config->get('dont_override'); +$save_arr = array(); +$dont_override = (array) $RCMAIL->config->get('dont_override'); // is there a sort type for this request? if ($sort = rcube_utils::get_input_value('_sort', rcube_utils::INPUT_GET)) { @@ -104,6 +104,13 @@ if (isset($a_headers) && count($a_headers)) { if ($search_request) { $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count)); } + + // remember last HIGHESTMODSEQ value (if supported) + // we need it for flag updates in check-recent + $data = $RCMAIL->storage->folder_data($mbox_name); + if (!empty($data['HIGHESTMODSEQ'])) { + $_SESSION['list_mod_seq'] = $data['HIGHESTMODSEQ']; + } } else { // handle IMAP errors (e.g. #1486905) diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc index 03d6de326..210bedbb8 100644 --- a/program/steps/mail/search.inc +++ b/program/steps/mail/search.inc @@ -131,6 +131,13 @@ if (!empty($result_h)) { rcmail_js_message_list($result_h); if ($search_str) $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $RCMAIL->storage->count(NULL, 'ALL'))); + + // remember last HIGHESTMODSEQ value (if supported) + // we need it for flag updates in check-recent + $data = $RCMAIL->storage->folder_data($mbox_name); + if (!empty($data['HIGHESTMODSEQ'])) { + $_SESSION['list_mod_seq'] = $data['HIGHESTMODSEQ']; + } } // handle IMAP errors (e.g. #1486905) else if ($err_code = $RCMAIL->storage->get_error_code()) { -- cgit v1.2.3