summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2007-11-25 20:40:10 +0000
committerthomascube <thomas@roundcube.net>2007-11-25 20:40:10 +0000
commit11074801923807a9448f7427299ddba76e235e42 (patch)
treee674b11f1ead956a19b3eba3c132b5e0442fd53d
parentd5342aabcfeddb959cc286befe6de5bf35fe9d76 (diff)
Only show new messages if they match the current search (#1484176)
-rw-r--r--CHANGELOG2
-rw-r--r--program/include/rcube_imap.inc16
-rw-r--r--program/js/app.js4
-rw-r--r--program/js/list.js3
-rw-r--r--program/steps/mail/check_recent.inc14
-rw-r--r--program/steps/mail/list.inc3
-rw-r--r--program/steps/mail/move_del.inc2
7 files changed, 34 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f646061a2..131b720b4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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)
----------
diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index 5a9994c02..56859b300 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -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;
+ }
/**
diff --git a/program/js/app.js b/program/js/app.js
index 5b9265b69..9bb85689a 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -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);
};
diff --git a/program/js/list.js b/program/js/list.js
index de4d7c84a..06c355432 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -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');
}
diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc
index a2100f1d2..a392cd0e6 100644
--- a/program/steps/mail/check_recent.inc
+++ b/program/steps/mail/check_recent.inc
@@ -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;
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index 196144285..8caf4c06f 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -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
diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc
index ff6117d21..c78d6db51 100644
--- a/program/steps/mail/move_del.inc
+++ b/program/steps/mail/move_del.inc
@@ -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();