summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG3
-rw-r--r--program/js/app.js9
-rw-r--r--program/steps/mail/func.inc4
-rw-r--r--program/steps/mail/search.inc3
-rw-r--r--program/steps/mail/show.inc33
5 files changed, 46 insertions, 6 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 145ad28b0..cda9d8ef0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
CHANGELOG RoundCube Webmail
---------------------------
+2008/01/31 (robin)
+- Remember search results (closes #1483883), patch by the_glu
+
2008/01/08 (tomekp)
----------
- add he (Hebrew) localization (#1484713)
diff --git a/program/js/app.js b/program/js/app.js
index 5c2aecd21..0288fad79 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -149,6 +149,9 @@ function rcube_webmail()
// enable mail commands
this.enable_command('list', 'checkmail', 'compose', 'add-contact', 'search', 'reset-search', true);
+
+ if (this.env.search_text != null && document.getElementById('quicksearchbox') != null)
+ document.getElementById('quicksearchbox').value = this.env.search_text;
if (this.env.action=='show' || this.env.action=='preview')
{
@@ -497,7 +500,7 @@ function rcube_webmail()
case 'list':
if (this.task=='mail')
{
- if (this.env.search_request<0 || (this.env.search_request && props != this.env.mailbox))
+ if (this.env.search_request<0 || (props != '' && (this.env.search_request && props != this.env.mailbox)))
this.reset_qsearch();
this.list_mailbox(props);
@@ -1199,6 +1202,10 @@ function rcube_webmail()
if (safe)
add_url = '&_safe=1';
+ // also send search request to get the right messages
+ if (this.env.search_request)
+ add_url += '&_search='+this.env.search_request;
+
if (id)
{
var url = '&_action='+action+'&_uid='+id+'&_mbox='+urlencode(this.env.mailbox)+add_url;
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index de8987248..b508a1fcb 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -48,7 +48,11 @@ if (!isset($_SESSION['sort_order']))
// set message set for search result
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
+ {
$IMAP->set_search_set($_SESSION['search'][$_REQUEST['_search']]);
+ $OUTPUT->set_env('search_request', $_REQUEST['_search']);
+ $OUTPUT->set_env('search_text', $_SESSION['last_text_search']);
+ }
// define url for getting message parts
diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc
index 5ed6627ef..66fcf47a3 100644
--- a/program/steps/mail/search.inc
+++ b/program/steps/mail/search.inc
@@ -89,6 +89,7 @@ if (is_array($result) && $result[0] != '')
if ($result_h != NULL)
{
$_SESSION['search'][$search_request] = $IMAP->get_search_set();
+ $_SESSION['last_text_search'] = $str;
rcmail_js_message_list($result_h);
$OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count));
}
@@ -107,4 +108,4 @@ $OUTPUT->set_env('pagecount', $pages);
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count, 1));
$OUTPUT->send();
-?> \ No newline at end of file
+?>
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 1aab3302c..9a94a9493 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -80,10 +80,18 @@ if ($_GET['_uid'])
$OUTPUT->set_env('mdn_request', true);
}
- $next = $prev = -1;
+ // set message set for search result
+ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
+ {
+ $IMAP->set_search_set($_SESSION['search'][$_REQUEST['_search']]);
+ $OUTPUT->set_env('search_request', $_REQUEST['_search']);
+ }
+
+ $next = $prev = $first = $last = -1;
// get previous, first, next and last message UID
- if (!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') &&
- $IMAP->get_capability('sort'))
+ if ((!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') &&
+ $IMAP->get_capability('sort') ) && !(!empty($_REQUEST['_search']) &&
+ isset($_SESSION['search'][$_REQUEST['_search']])) )
{
// Only if we use custom sorting
$a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']);
@@ -94,6 +102,23 @@ if ($_GET['_uid'])
$next = isset($a_msg_index[$MESSAGE['index']+1]) ? $a_msg_index[$MESSAGE['index']+1] : -1 ;
$last = count($a_msg_index)>0 ? $a_msg_index[count($a_msg_index)-1] : -1;
}
+ elseif (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
+ {
+ $search_data = $_SESSION['search'][$_REQUEST['_search']];
+ $result = $IMAP->search(NULL, $search_data[0], $search_data[1],$search_data[3]);
+ $result = array_reverse($result);
+ foreach ($result as $key=>$rid)
+ {
+ $result[$key] = $IMAP->get_uid($rid);
+ if ($MESSAGE['UID'] == $result[$key])
+ $seq = $key;
+ }
+ $prev = isset($result[$seq-1]) ? $result[$seq-1] : -1 ;
+ $first = count($result)>0 ? $result[0] : -1;
+ $next = isset($result[$seq+1]) ? $result[$seq+1] : -1 ;
+ $last = count($result)>0 ? $result[count($result)-1] : -1;
+ $MESSAGE['index'] = $seq;
+ }
else
{
// this assumes that we are sorted by date_DESC
@@ -184,4 +209,4 @@ else if ($_action=='preview' && template_exists('messagepreview'))
parse_template('messagepreview');
else
parse_template('message');
-?> \ No newline at end of file
+?>