alecpl
2011-11-26 3e5c709fa719e2458df06e515fa4893ae743edda
- Fix so TEXT key will remove all HEADER keys in IMAP SEARCH (#1488208)


3 files modified
111 ■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/steps/mail/search.inc 20 ●●●●● patch | view | raw | blame | history
skins/default/functions.js 90 ●●●● patch | view | raw | blame | history
CHANGELOG
@@ -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)
program/steps/mail/search.inc
@@ -31,6 +31,7 @@
$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 @@
  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 @@
  }
}
$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);
skins/default/functions.js
@@ -192,28 +192,31 @@
  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['*'];
        for (n in mods)
          $('#s_mod_' + n).prop('checked', true);
        all = 'text';
      }
      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);
        }
        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);
      }
    }
  }
@@ -222,7 +225,7 @@
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 @@
  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;
    // mark all fields
    if (elem.value == '*') {
      $('input:checkbox[name="s_mods[]"]').map(function() {
        if (this == elem)
          return;
        if (elem.checked) {
          mods[this.value] = 1;
          this.checked = true;
          this.disabled = true;
        }
        else {
          this.disabled = false;
        }
      });
    }
    m = mods;
    all = '*';
  }
  rcmail.env.search_mods = mods;
  if (!elem.checked)
    delete(m[elem.value]);
  else
    m[elem.value] = 1;
  // mark all fields
  if (elem.value != all)
    return;
  $('input:checkbox[name="s_mods[]"]').map(function() {
    if (this == elem)
      return;
    this.checked = true;
    if (elem.checked) {
      this.disabled = true;
      delete m[this.value];
    }
    else {
      this.disabled = false;
      m[this.value] = 1;
    }
  });
},
listmenu: function(show)