summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-10-05 13:43:17 +0000
committeralecpl <alec@alec.pl>2011-10-05 13:43:17 +0000
commite9c47c612e9480754b3d647118f305147a3dad64 (patch)
treea4a59854ed6be6ff9480fd52a9dcf2e38eb9e747
parent8881766a9fc626585c9d00a139ff3dd5621745dd (diff)
- Fix bug where wrong search string was build when using filter together with search
-rw-r--r--program/js/app.js71
1 files changed, 42 insertions, 29 deletions
diff --git a/program/js/app.js b/program/js/app.js
index 3ddd55862..caae45d6b 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -1960,18 +1960,13 @@ function rcube_webmail()
// list messages of a specific mailbox using filter
this.filter_mailbox = function(filter)
{
- var search, lock = this.set_busy(true, 'searching');
-
- if (this.gui_objects.qsearchbox)
- search = this.gui_objects.qsearchbox.value;
+ var lock = this.set_busy(true, 'searching');
this.clear_message_list();
// reset vars
this.env.current_page = 1;
- this.http_request('search', '_filter='+filter
- + (search ? '&_q='+urlencode(search) : '')
- + (this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : ''), lock);
+ this.http_request('search', this.search_params(false, filter), lock);
};
// list messages of a specific mailbox
@@ -3426,40 +3421,58 @@ function rcube_webmail()
this.qsearch = function(value)
{
if (value != '') {
- var n, r, addurl = '', mods_arr = [],
- mods = this.env.search_mods,
- mbox = this.env.mailbox,
- lock = this.set_busy(true, 'searching');
+ var n, lock = this.set_busy(true, 'searching');
- if (this.message_list) {
+ if (this.message_list)
this.clear_message_list();
- if (mods)
- mods = mods[mbox] ? mods[mbox] : mods['*'];
- } else if (this.contact_list) {
+ else if (this.contact_list)
this.list_contacts_clear();
- }
-
- if (mods) {
- for (n in mods)
- mods_arr.push(n);
- addurl += '&_headers='+mods_arr.join(',');
- }
-
- if (this.gui_objects.search_filter)
- addurl += '&_filter=' + this.gui_objects.search_filter.value;
// reset vars
this.env.current_page = 1;
- r = this.http_request('search', '_q='+urlencode(value)
- + (mbox ? '&_mbox='+urlencode(mbox) : '')
+ r = this.http_request('search', this.search_params(value)
+ (this.env.source ? '&_source='+urlencode(this.env.source) : '')
- + (this.env.group ? '&_gid='+urlencode(this.env.group) : '')
- + (addurl ? addurl : ''), lock);
+ + (this.env.group ? '&_gid='+urlencode(this.env.group) : ''), lock);
this.env.qsearch = {lock: lock, request: r};
}
};
+ // build URL params for search
+ this.search_params = function(search, filter)
+ {
+ var n, url = [], mods_arr = [],
+ mods = this.env.search_mods,
+ mbox = this.env.mailbox;
+
+ if (!filter && this.gui_objects.search_filter)
+ filter = this.gui_objects.search_filter.value;
+
+ if (!search && this.gui_objects.qsearchbox)
+ search = this.gui_objects.qsearchbox.value;
+
+ if (filter)
+ url.push('_filter=' + urlencode(filter));
+
+ if (search) {
+ url.push('_q='+urlencode(search));
+
+ if (mods && this.message_list)
+ mods = mods[mbox] ? mods[mbox] : mods['*'];
+
+ if (mods) {
+ for (n in mods)
+ mods_arr.push(n);
+ url.push('_headers='+mods_arr.join(','));
+ }
+ }
+
+ if (mbox)
+ url.push('_mbox='+urlencode(mbox));
+
+ return url.join('&');
+ };
+
// reset quick-search form
this.reset_qsearch = function()
{