alecpl
2009-05-02 aeed58d5af0d56ec489d15cdbdffa3f95b353a90
- Use UID STORE/COPY commands


2 files modified
59 ■■■■■ changed files
program/include/rcube_imap.php 53 ●●●●● patch | view | raw | blame | history
program/lib/imap.inc 6 ●●●● patch | view | raw | blame | history
program/include/rcube_imap.php
@@ -1549,30 +1549,26 @@
  function set_flag($uids, $flag)
    {
    $flag = strtoupper($flag);
    $msg_ids = array();
    if (!is_array($uids))
      $uids = explode(',',$uids);
      
    foreach ($uids as $uid) {
      $msg_ids[$uid] = $this->_uid2id($uid);
    }
    if ($flag=='UNDELETED')
      $result = iil_C_Undelete($this->conn, $this->mailbox, join(',', array_values($msg_ids)));
      $result = iil_C_Undelete($this->conn, $this->mailbox, join(',', $uids));
    else if ($flag=='UNSEEN')
      $result = iil_C_Unseen($this->conn, $this->mailbox, join(',', array_values($msg_ids)));
      $result = iil_C_Unseen($this->conn, $this->mailbox, join(',', $uids));
    else if ($flag=='UNFLAGGED')
      $result = iil_C_UnFlag($this->conn, $this->mailbox, join(',', array_values($msg_ids)), 'FLAGGED');
      $result = iil_C_UnFlag($this->conn, $this->mailbox, join(',', $uids), 'FLAGGED');
    else
      $result = iil_C_Flag($this->conn, $this->mailbox, join(',', array_values($msg_ids)), $flag);
      $result = iil_C_Flag($this->conn, $this->mailbox, join(',', $uids), $flag);
    // reload message headers if cached
    $cache_key = $this->mailbox.'.msg';
    if ($this->caching_enabled)
      {
      foreach ($msg_ids as $uid => $id)
      foreach ($uids as $uid)
        {
        if ($cached_headers = $this->get_cached_message($cache_key, $uid))
    $id = $this->_uid2id($uid);
        if ($cached_headers = $this->get_cached_message($cache_key, $id))
          {
          $this->remove_message_cache($cache_key, $id);
          //$this->get_headers($uid);
@@ -1585,7 +1581,7 @@
      }
    // set nr of messages that were flaged
    $count = count($msg_ids);
    $count = count($uids);
    // clear message count cache
    if ($result && $flag=='SEEN')
@@ -1650,15 +1646,10 @@
    $a_uids = is_string($uids) ? explode(',', $uids) : (is_array($uids) ? $uids : NULL);
    
    // exit if no message uids are specified
    if (!is_array($a_uids))
    if (!is_array($a_uids) || empty($a_uids))
      return false;
    // convert uids to message ids
    $a_mids = array();
    foreach ($a_uids as $uid)
      $a_mids[] = $this->_uid2id($uid, $from_mbox);
    $iil_move = iil_C_Move($this->conn, join(',', $a_mids), $from_mbox, $to_mbox);
    $iil_move = iil_C_Move($this->conn, join(',', $a_uids), $from_mbox, $to_mbox);
    $moved = !($iil_move === false || $iil_move < 0);
    
    // send expunge command in order to have the moved message
@@ -1674,13 +1665,15 @@
    }
    // moving failed
    else if (rcmail::get_instance()->config->get('delete_always', false)) {
      return iil_C_Delete($this->conn, $from_mbox, join(',', $a_mids));
      return iil_C_Delete($this->conn, $from_mbox, join(',', $a_uids));
    }
      
    // remove message ids from search set
    if ($moved && $this->search_set && $from_mbox == $this->mailbox)
    if ($moved && $this->search_set && $from_mbox == $this->mailbox) {
      foreach ($a_uids as $uid)
        $a_mids[] = $this->_uid2id($uid, $from_mbox);
      $this->search_set = array_diff($this->search_set, $a_mids);
    }
    // update cached message headers
    $cache_key = $from_mbox.'.msg';
    if ($moved && ($a_cache_index = $this->get_message_cache_index($cache_key)))
@@ -1715,15 +1708,10 @@
    $a_uids = is_string($uids) ? explode(',', $uids) : (is_array($uids) ? $uids : NULL);
    
    // exit if no message uids are specified
    if (!is_array($a_uids))
    if (!is_array($a_uids) || empty($a_uids))
      return false;
    // convert uids to message ids
    $a_mids = array();
    foreach ($a_uids as $uid)
      $a_mids[] = $this->_uid2id($uid, $mailbox);
    $deleted = iil_C_Delete($this->conn, $mailbox, join(',', $a_mids));
    $deleted = iil_C_Delete($this->conn, $mailbox, join(',', $a_uids));
    
    // send expunge command in order to have the deleted message
    // really deleted from the mailbox
@@ -1735,9 +1723,12 @@
      }
    // remove message ids from search set
    if ($deleted && $this->search_set && $mailbox == $this->mailbox)
    if ($deleted && $this->search_set && $mailbox == $this->mailbox) {
      foreach ($a_uids as $uid)
        $a_mids[] = $this->_uid2id($uid, $mailbox);
      $this->search_set = array_diff($this->search_set, $a_mids);
    }
    // remove deleted messages from cache
    $cache_key = $mailbox.'.msg';
    if ($deleted && ($a_cache_index = $this->get_message_cache_index($cache_key)))
program/lib/imap.inc
@@ -2080,7 +2080,7 @@
    
    if (iil_C_Select($conn, $mailbox)) {
        $c = 0;
        iil_PutLine($fp, "flg STORE $messages " . $mod . "FLAGS (" . $flag . ")");
        iil_PutLine($fp, "flg UID STORE $messages " . $mod . "FLAGS (" . $flag . ")");
        do {
            $line=chop(iil_ReadLine($fp, 100));
            if ($line[0] == '*') {
@@ -2129,7 +2129,7 @@
    if (iil_C_Select($conn, $from)) {
        $c=0;
        
        iil_PutLine($fp, "cpy1 COPY $messages \"".iil_Escape($to)."\"");
        iil_PutLine($fp, "cpy1 UID COPY $messages \"".iil_Escape($to)."\"");
        $line=iil_ReadReply($fp);
        return iil_ParseResult($line);
    } else {
@@ -2843,7 +2843,7 @@
function iil_C_ClearFolder(&$conn, $folder) {
    $num_in_trash = iil_C_CountMessages($conn, $folder);
    if ($num_in_trash > 0) {
        iil_C_Delete($conn, $folder, '1:' . $num_in_trash);
        iil_C_Delete($conn, $folder, '1:*');
    }
    return (iil_C_Expunge($conn, $folder) >= 0);
}