diff options
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | program/steps/mail/search.inc | 20 | ||||
-rw-r--r-- | skins/default/functions.js | 86 |
3 files changed, 59 insertions, 48 deletions
@@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Fix so TEXT key will remove all HEADER keys in IMAP SEARCH (#1488208) - Fix handling contact photo url with https:// prefix (#1488202) - Prevent from memory_limit exceeding when trying to parse big messages bodies (#1487424) - Add possibility to add SASL mechanisms for SMTP in smtp_connect hook (#1487937) diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc index 2e7fd130c..593eac427 100644 --- a/program/steps/mail/search.inc +++ b/program/steps/mail/search.inc @@ -31,6 +31,7 @@ $str = get_input_value('_q', RCUBE_INPUT_GET, true); $mbox = get_input_value('_mbox', RCUBE_INPUT_GET, true); $filter = get_input_value('_filter', RCUBE_INPUT_GET); $headers = get_input_value('_headers', RCUBE_INPUT_GET); +$subject = array(); $search_request = md5($mbox.$filter.$str); @@ -70,14 +71,19 @@ else if (preg_match("/^body:.*/i", $str)) list(,$srch) = explode(":", $str); $subject['text'] = "TEXT"; } -else if(trim($str)) +else if (strlen(trim($str))) { if ($headers) { - foreach(explode(',', $headers) as $header) - switch ($header) { - case 'text': $subject['text'] = 'TEXT'; break; - default: $subject[$header] = 'HEADER '.strtoupper($header); + foreach (explode(',', $headers) as $header) { + if ($header == 'text') { + // #1488208: get rid of other headers when searching by "TEXT" + $subject = array('text' => 'TEXT'); + break; } + else { + $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); @@ -89,9 +95,9 @@ else if(trim($str)) } } -$search = $srch ? trim($srch) : trim($str); +$search = isset($srch) ? trim($srch) : trim($str); -if ($subject) { +if (!empty($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); diff --git a/skins/default/functions.js b/skins/default/functions.js index 6f22bb6c2..5d55447d6 100644 --- a/skins/default/functions.js +++ b/skins/default/functions.js @@ -192,29 +192,32 @@ searchmenu: function(show) if (show && ref) { var pos = $(ref).offset(); - obj.css({ left:pos.left, top:(pos.top + ref.offsetHeight + 2)}) - .find(':checked').prop('checked', false); + obj.css({left:pos.left, top:(pos.top + ref.offsetHeight + 2)}); if (rcmail.env.search_mods) { - var n, mbox = rcmail.env.mailbox, mods = rcmail.env.search_mods; + var n, all, + list = $('input:checkbox[name="s_mods[]"]', obj), + mbox = rcmail.env.mailbox, + mods = rcmail.env.search_mods; - if (rcmail.env.task != 'addressbook') { + if (rcmail.env.task == 'mail') { mods = mods[mbox] ? mods[mbox] : mods['*']; + all = 'text'; + } + else { + all = '*'; + } + if (mods[all]) + list.map(function() { + this.checked = true; + this.disabled = this.value != all; + }); + else { + list.prop('disabled', false).prop('checked', false); for (n in mods) $('#s_mod_' + n).prop('checked', true); } - else { - if (mods['*']) - $('input:checkbox[name="s_mods[]"]').map(function() { - this.checked = true; - this.disabled = this.value != '*'; - }); - else { - for (n in mods) - $('#s_mod_' + n).prop('checked', true); - } - } } } obj[show?'show':'hide'](); @@ -222,7 +225,7 @@ searchmenu: function(show) set_searchmod: function(elem) { - var task = rcmail.env.task, + var all, m, task = rcmail.env.task, mods = rcmail.env.search_mods, mbox = rcmail.env.mailbox; @@ -232,36 +235,37 @@ set_searchmod: function(elem) if (task == 'mail') { if (!mods[mbox]) mods[mbox] = rcube_clone_object(mods['*']); - if (!elem.checked) - delete(mods[mbox][elem.value]); - else - mods[mbox][elem.value] = 1; + m = mods[mbox]; + all = 'text'; } else { //addressbook - if (!elem.checked) - delete(mods[elem.value]); - else - mods[elem.value] = 1; + m = mods; + all = '*'; + } + + if (!elem.checked) + delete(m[elem.value]); + else + m[elem.value] = 1; - // mark all fields - if (elem.value == '*') { - $('input:checkbox[name="s_mods[]"]').map(function() { - if (this == elem) - return; + // mark all fields + if (elem.value != all) + return; - if (elem.checked) { - mods[this.value] = 1; - this.checked = true; - this.disabled = true; - } - else { - this.disabled = false; - } - }); - } - } + $('input:checkbox[name="s_mods[]"]').map(function() { + if (this == elem) + return; - rcmail.env.search_mods = mods; + this.checked = true; + if (elem.checked) { + this.disabled = true; + delete m[this.value]; + } + else { + this.disabled = false; + m[this.value] = 1; + } + }); }, listmenu: function(show) |