thomascube
2007-11-25 11074801923807a9448f7427299ddba76e235e42
Only show new messages if they match the current search (#1484176)

7 files modified
44 ■■■■ changed files
CHANGELOG 2 ●●● patch | view | raw | blame | history
program/include/rcube_imap.inc 16 ●●●●● patch | view | raw | blame | history
program/js/app.js 4 ●●● patch | view | raw | blame | history
program/js/list.js 3 ●●●● patch | view | raw | blame | history
program/steps/mail/check_recent.inc 14 ●●●● patch | view | raw | blame | history
program/steps/mail/list.inc 3 ●●●● patch | view | raw | blame | history
program/steps/mail/move_del.inc 2 ●●● patch | view | raw | blame | history
CHANGELOG
@@ -12,7 +12,7 @@
- Added Georgian localization by Zaza Zviadadze
- Updated Russian localization
- Fixed some potential security risks (audited by Andris)
- Only show new messages if they match the current search (#1484176)
2007/11/20 (tomekp)
----------
program/include/rcube_imap.inc
@@ -441,7 +441,7 @@
      $mailbox = $this->mailbox;
      
    // count search set
    if ($this->search_string && $mailbox == $this->mailbox && $mode == 'ALL')
    if ($this->search_string && $mailbox == $this->mailbox && $mode == 'ALL' && !$force)
      return count((array)$this->search_set);
    $a_mailbox_cache = $this->get_cache('messagecount');
@@ -934,6 +934,20 @@
      
    return $this->get_search_set();
    }
  /**
   * Check if the given message ID is part of the current search set
   *
   * @return True on match or if no search request is stored
   */
  function in_searchset($msgid)
  {
    if (!empty($this->search_string))
      return in_array("$msgid", (array)$this->search_set, true);
    else
      return true;
  }
  /**
program/js/app.js
@@ -1143,6 +1143,8 @@
      this.command('show');
    else if (list.key_pressed == list.DELETE_KEY)
      this.command('delete');
    else
      list.shiftkey = false;
    };
@@ -3483,7 +3485,7 @@
      }
    this.set_busy(true, 'checkingmail');
    this.http_request('check-recent', '_t='+(new Date().getTime()), true);
    this.http_request('check-recent', (this.env.search_request ? '_search='+this.env.search_request+'&' : '') + '_t='+(new Date().getTime()), true);
    };
program/js/list.js
@@ -535,8 +535,6 @@
  if (this.focused != true) 
    return true;
  this.shiftkey = e.shiftKey;
  var keyCode = document.layers ? e.which : document.all ? event.keyCode : document.getElementById ? e.keyCode : 0;
  var mod_key = rcube_event.get_modifier(e);
  switch (keyCode)
@@ -547,6 +545,7 @@
      break;
    default:
      this.shiftkey = e.shiftKey;
      this.key_pressed = keyCode;
      this.trigger_event('keypress');
  }
program/steps/mail/check_recent.inc
@@ -27,18 +27,26 @@
    {
    if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE))
      {
      $count = $IMAP->messagecount(NULL, 'ALL', TRUE);
      // refresh saved search set
      if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set)
        $_SESSION['search'][$search_request] = $IMAP->refresh_search();
      $count_all = $IMAP->messagecount(NULL, 'ALL', TRUE);
      $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
      $OUTPUT->set_env('messagecount', $count);
      $OUTPUT->set_env('messagecount', $IMAP->messagecount());
      $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, true);
      $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text());
      $OUTPUT->command('set_quota', $IMAP->get_quota());
      // add new message headers to list
      $a_headers = array();
      for ($i=$recent_count, $id=$count-$recent_count+1; $i>0; $i--, $id++)
      for ($i=$recent_count, $id=$count_all-$recent_count+1; $i>0; $i--, $id++)
        {
        // skip message if it does not match the current search
        if (!$IMAP->in_searchset($id))
          continue;
        $header = $IMAP->get_headers($id, NULL, FALSE);
        if ($header->recent)
          $a_headers[] = $header;
program/steps/mail/list.inc
@@ -40,9 +40,10 @@
$mbox_name = $IMAP->get_mailbox_name();
// fetch message headers
if ($count = $IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh'])))
if ($IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh'])))
  $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order);
$count = $IMAP->messagecount($mbox_name);
$unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_REQUEST['_refresh']));
// update message count display
program/steps/mail/move_del.inc
@@ -60,7 +60,7 @@
else
  exit;
// refresh saved seach set after moving some messages
// refresh saved search set after moving some messages
if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set)
  $_SESSION['search'][$search_request] = $IMAP->refresh_search();