diff options
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | program/js/app.js | 11 | ||||
-rw-r--r-- | program/js/common.js | 14 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 9 | ||||
-rw-r--r-- | program/steps/mail/search.inc | 12 | ||||
-rw-r--r-- | skins/default/functions.js | 15 |
6 files changed, 47 insertions, 15 deletions
@@ -1,6 +1,7 @@ CHANGELOG RoundCube Webmail =========================== +- Remember search modifiers in user prefs (#1486146) - Added force_7bit option to force MIME encoding of plain/text messages (#1486510) - Use case sensitive check when checking for default folders (#1486346) - Fix checking for new mail: now checks unseen count of inbox (#1485794) diff --git a/program/js/app.js b/program/js/app.js index f03b0c5fb..ab70b024b 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -2616,10 +2616,13 @@ function rcube_webmail() if (this.message_list) { this.message_list.clear(); if (this.env.search_mods) { - var head_arr = new Array(); - for (var n in this.env.search_mods) - head_arr.push(n); - addurl += '&_headers='+head_arr.join(','); + var mods = this.env.search_mods[this.env.mailbox] ? this.env.search_mods[this.env.mailbox] : this.env.search_mods['*']; + if (mods) { + var head_arr = new Array(); + for (var n in mods) + head_arr.push(n); + addurl += '&_headers='+head_arr.join(','); + } } } else if (this.contact_list) { this.contact_list.clear(true); diff --git a/program/js/common.js b/program/js/common.js index c66ea7655..70ef4446b 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -490,6 +490,20 @@ function find_in_array() return -1; } +// recursively copy an object +function rcube_clone_object(obj) +{ + var out = {}; + + for (var key in obj) { + if (obj[key] && typeof obj[key] == 'object') + out[key] = clone_object(obj[key]); + else + out[key] = obj[key]; + } + + return out; +} // make a string URL safe function urlencode(str) diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 491f79a5e..3dab087b0 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -19,6 +19,11 @@ */ +// setup some global vars used by mail steps +$SENT_MBOX = $RCMAIL->config->get('sent_mbox'); +$DRAFTS_MBOX = $RCMAIL->config->get('drafts_mbox'); +$SEARCH_MODS_DEFAULT = array('*' => array('subject'=>1, 'from'=>1), $SENT_MBOX => array('subject'=>1, 'to'=>1), $DRAFTS_MBOX => array('subject'=>1, 'to'=>1)); + $EMAIL_ADDRESS_PATTERN = '([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9][a-z0-9\-\.]*\\.[a-z]{2,5})'; // actions that do not require imap connection @@ -79,7 +84,9 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') $OUTPUT->set_env('search_request', $search_request); } - $OUTPUT->set_env('search_mods', $_SESSION['search_mods'] ? $_SESSION['search_mods'] : array('subject'=>'subject')); + $search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT); + $OUTPUT->set_env('search_mods', $search_mods); + // make sure the message count is refreshed (for default view) $IMAP->messagecount($mbox_name, 'ALL', true); } diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc index 6a1c8c471..cfdb6fb96 100644 --- a/program/steps/mail/search.inc +++ b/program/steps/mail/search.inc @@ -72,12 +72,17 @@ else if (preg_match("/^body:.*/i", $str)) else if(trim($str)) { if ($headers) { - $headers = explode(',', $headers); - foreach($headers as $header) + foreach(explode(',', $headers) as $header) switch ($header) { case 'text': $subject['text'] = 'TEXT'; break; - default: $subject[$header] = 'HEADER '.$header; + default: $subject[$header] = 'HEADER '.strtoupper($header); } + + // save search modifiers for the current folder to user prefs + $search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT); + $search_mods[$mbox] = array_fill_keys(array_keys($subject), 1); + $RCMAIL->user->save_prefs(array('search_mods' => $search_mods)); + console($search_mods); } else { // search in subject by default $subject['subject'] = 'HEADER SUBJECT'; @@ -90,7 +95,6 @@ if ($subject) { $search_str .= str_repeat(' OR', count($subject)-1); foreach ($subject as $sub) $search_str .= sprintf(" %s {%d}\r\n%s", $sub, strlen($search), $search); - $_SESSION['search_mods'] = $subject; } $search_str = trim($search_str); diff --git a/skins/default/functions.js b/skins/default/functions.js index 28af2e7e7..3a295decb 100644 --- a/skins/default/functions.js +++ b/skins/default/functions.js @@ -161,12 +161,12 @@ show_searchmenu: function(show) if (show && ref) { var pos = $(ref).offset(); this.searchmenu.css({ left:pos.left, top:(pos.top + ref.offsetHeight + 2)}); + this.searchmenu.find(":checked").attr('checked', false); if (rcmail.env.search_mods) { - for (var n in rcmail.env.search_mods) { - box = rcube_find_object('s_mod_' + n); - box.checked = 'checked'; - } + var search_mods = rcmail.env.search_mods[rcmail.env.mailbox] ? rcmail.env.search_mods[rcmail.env.mailbox] : rcmail.env.search_mods['*']; + for (var n in search_mods) + $('#s_mod_' + n).attr('checked', true); } } this.searchmenu[show?'show':'hide'](); @@ -177,10 +177,13 @@ set_searchmod: function(elem) if (!rcmail.env.search_mods) rcmail.env.search_mods = new Object(); + if (!rcmail.env.search_mods[rcmail.env.mailbox]) + rcmail.env.search_mods[rcmail.env.mailbox] = rcube_clone_object(rcmail.env.search_mods['*']); + if (!elem.checked) - delete(rcmail.env.search_mods[elem.value]); + delete(rcmail.env.search_mods[rcmail.env.mailbox][elem.value]); else - rcmail.env.search_mods[elem.value] = elem.value; + rcmail.env.search_mods[rcmail.env.mailbox][elem.value] = elem.value; }, body_mouseup: function(evt, p) |