Only show new messages if they match the current search (#1484176)

release-0.6
thomascube 17 years ago
parent d5342aabcf
commit 1107480192

@ -12,7 +12,7 @@ CHANGELOG RoundCube Webmail
- Added Georgian localization by Zaza Zviadadze
- Updated Russian localization
- Fixed some potential security risks (audited by Andris)
- Only show new messages if they match the current search (#1484176)
2007/11/20 (tomekp)
----------

@ -441,7 +441,7 @@ class rcube_imap
$mailbox = $this->mailbox;
// count search set
if ($this->search_string && $mailbox == $this->mailbox && $mode == 'ALL')
if ($this->search_string && $mailbox == $this->mailbox && $mode == 'ALL' && !$force)
return count((array)$this->search_set);
$a_mailbox_cache = $this->get_cache('messagecount');
@ -934,6 +934,20 @@ class rcube_imap
return $this->get_search_set();
}
/**
* Check if the given message ID is part of the current search set
*
* @return True on match or if no search request is stored
*/
function in_searchset($msgid)
{
if (!empty($this->search_string))
return in_array("$msgid", (array)$this->search_set, true);
else
return true;
}
/**

@ -1143,6 +1143,8 @@ function rcube_webmail()
this.command('show');
else if (list.key_pressed == list.DELETE_KEY)
this.command('delete');
else
list.shiftkey = false;
};
@ -3483,7 +3485,7 @@ function rcube_webmail()
}
this.set_busy(true, 'checkingmail');
this.http_request('check-recent', '_t='+(new Date().getTime()), true);
this.http_request('check-recent', (this.env.search_request ? '_search='+this.env.search_request+'&' : '') + '_t='+(new Date().getTime()), true);
};

@ -535,8 +535,6 @@ key_press: function(e)
if (this.focused != true)
return true;
this.shiftkey = e.shiftKey;
var keyCode = document.layers ? e.which : document.all ? event.keyCode : document.getElementById ? e.keyCode : 0;
var mod_key = rcube_event.get_modifier(e);
switch (keyCode)
@ -547,6 +545,7 @@ key_press: function(e)
break;
default:
this.shiftkey = e.shiftKey;
this.key_pressed = keyCode;
this.trigger_event('keypress');
}

@ -27,18 +27,26 @@ foreach ($a_mailboxes as $mbox_name)
{
if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE))
{
$count = $IMAP->messagecount(NULL, 'ALL', TRUE);
// refresh saved search set
if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set)
$_SESSION['search'][$search_request] = $IMAP->refresh_search();
$count_all = $IMAP->messagecount(NULL, 'ALL', TRUE);
$unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
$OUTPUT->set_env('messagecount', $count);
$OUTPUT->set_env('messagecount', $IMAP->messagecount());
$OUTPUT->command('set_unread_count', $mbox_name, $unread_count, true);
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text());
$OUTPUT->command('set_quota', $IMAP->get_quota());
// add new message headers to list
$a_headers = array();
for ($i=$recent_count, $id=$count-$recent_count+1; $i>0; $i--, $id++)
for ($i=$recent_count, $id=$count_all-$recent_count+1; $i>0; $i--, $id++)
{
// skip message if it does not match the current search
if (!$IMAP->in_searchset($id))
continue;
$header = $IMAP->get_headers($id, NULL, FALSE);
if ($header->recent)
$a_headers[] = $header;

@ -40,9 +40,10 @@ else
$mbox_name = $IMAP->get_mailbox_name();
// fetch message headers
if ($count = $IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh'])))
if ($IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh'])))
$a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order);
$count = $IMAP->messagecount($mbox_name);
$unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_REQUEST['_refresh']));
// update message count display

@ -60,7 +60,7 @@ else if ($_action=='delete' && !empty($_POST['_uid']))
else
exit;
// refresh saved seach set after moving some messages
// refresh saved search set after moving some messages
if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set)
$_SESSION['search'][$search_request] = $IMAP->refresh_search();

Loading…
Cancel
Save