Changeset 2448 in subversion


Ignore:
Timestamp:
May 2, 2009 3:19:39 PM (4 years ago)
Author:
alec
Message:
  • Use UID STORE/COPY commands
Location:
trunk/roundcubemail/program
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcube_imap.php

    r2436 r2448  
    15501550    { 
    15511551    $flag = strtoupper($flag); 
    1552     $msg_ids = array(); 
    15531552    if (!is_array($uids)) 
    15541553      $uids = explode(',',$uids); 
    15551554       
    1556     foreach ($uids as $uid) { 
    1557       $msg_ids[$uid] = $this->_uid2id($uid); 
    1558     } 
    1559        
    15601555    if ($flag=='UNDELETED') 
    1561       $result = iil_C_Undelete($this->conn, $this->mailbox, join(',', array_values($msg_ids))); 
     1556      $result = iil_C_Undelete($this->conn, $this->mailbox, join(',', $uids)); 
    15621557    else if ($flag=='UNSEEN') 
    1563       $result = iil_C_Unseen($this->conn, $this->mailbox, join(',', array_values($msg_ids))); 
     1558      $result = iil_C_Unseen($this->conn, $this->mailbox, join(',', $uids)); 
    15641559    else if ($flag=='UNFLAGGED') 
    1565       $result = iil_C_UnFlag($this->conn, $this->mailbox, join(',', array_values($msg_ids)), 'FLAGGED'); 
     1560      $result = iil_C_UnFlag($this->conn, $this->mailbox, join(',', $uids), 'FLAGGED'); 
    15661561    else 
    1567       $result = iil_C_Flag($this->conn, $this->mailbox, join(',', array_values($msg_ids)), $flag); 
     1562      $result = iil_C_Flag($this->conn, $this->mailbox, join(',', $uids), $flag); 
    15681563 
    15691564    // reload message headers if cached 
     
    15711566    if ($this->caching_enabled) 
    15721567      { 
    1573       foreach ($msg_ids as $uid => $id) 
    1574         { 
    1575         if ($cached_headers = $this->get_cached_message($cache_key, $uid)) 
     1568      foreach ($uids as $uid) 
     1569        { 
     1570        $id = $this->_uid2id($uid); 
     1571        if ($cached_headers = $this->get_cached_message($cache_key, $id)) 
    15761572          { 
    15771573          $this->remove_message_cache($cache_key, $id); 
     
    15861582 
    15871583    // set nr of messages that were flaged 
    1588     $count = count($msg_ids); 
     1584    $count = count($uids); 
    15891585 
    15901586    // clear message count cache 
     
    16511647     
    16521648    // exit if no message uids are specified 
    1653     if (!is_array($a_uids)) 
     1649    if (!is_array($a_uids) || empty($a_uids)) 
    16541650      return false; 
    16551651 
    1656     // convert uids to message ids 
    1657     $a_mids = array(); 
    1658     foreach ($a_uids as $uid) 
    1659       $a_mids[] = $this->_uid2id($uid, $from_mbox); 
    1660  
    1661     $iil_move = iil_C_Move($this->conn, join(',', $a_mids), $from_mbox, $to_mbox); 
     1652    $iil_move = iil_C_Move($this->conn, join(',', $a_uids), $from_mbox, $to_mbox); 
    16621653    $moved = !($iil_move === false || $iil_move < 0); 
    16631654     
     
    16751666    // moving failed 
    16761667    else if (rcmail::get_instance()->config->get('delete_always', false)) { 
    1677       return iil_C_Delete($this->conn, $from_mbox, join(',', $a_mids)); 
     1668      return iil_C_Delete($this->conn, $from_mbox, join(',', $a_uids)); 
    16781669    } 
    16791670       
    16801671    // remove message ids from search set 
    1681     if ($moved && $this->search_set && $from_mbox == $this->mailbox) 
     1672    if ($moved && $this->search_set && $from_mbox == $this->mailbox) { 
     1673      foreach ($a_uids as $uid) 
     1674        $a_mids[] = $this->_uid2id($uid, $from_mbox); 
    16821675      $this->search_set = array_diff($this->search_set, $a_mids); 
    1683  
     1676    } 
    16841677    // update cached message headers 
    16851678    $cache_key = $from_mbox.'.msg'; 
     
    17161709     
    17171710    // exit if no message uids are specified 
    1718     if (!is_array($a_uids)) 
     1711    if (!is_array($a_uids) || empty($a_uids)) 
    17191712      return false; 
    17201713 
    1721     // convert uids to message ids 
    1722     $a_mids = array(); 
    1723     foreach ($a_uids as $uid) 
    1724       $a_mids[] = $this->_uid2id($uid, $mailbox); 
    1725          
    1726     $deleted = iil_C_Delete($this->conn, $mailbox, join(',', $a_mids)); 
     1714    $deleted = iil_C_Delete($this->conn, $mailbox, join(',', $a_uids)); 
    17271715     
    17281716    // send expunge command in order to have the deleted message 
     
    17361724 
    17371725    // remove message ids from search set 
    1738     if ($deleted && $this->search_set && $mailbox == $this->mailbox) 
     1726    if ($deleted && $this->search_set && $mailbox == $this->mailbox) { 
     1727      foreach ($a_uids as $uid) 
     1728        $a_mids[] = $this->_uid2id($uid, $mailbox); 
    17391729      $this->search_set = array_diff($this->search_set, $a_mids); 
    1740  
     1730    } 
     1731     
    17411732    // remove deleted messages from cache 
    17421733    $cache_key = $mailbox.'.msg'; 
  • trunk/roundcubemail/program/lib/imap.inc

    r2401 r2448  
    20812081        if (iil_C_Select($conn, $mailbox)) { 
    20822082                $c = 0; 
    2083                 iil_PutLine($fp, "flg STORE $messages " . $mod . "FLAGS (" . $flag . ")"); 
     2083                iil_PutLine($fp, "flg UID STORE $messages " . $mod . "FLAGS (" . $flag . ")"); 
    20842084                do { 
    20852085                        $line=chop(iil_ReadLine($fp, 100)); 
     
    21302130                $c=0; 
    21312131                 
    2132                 iil_PutLine($fp, "cpy1 COPY $messages \"".iil_Escape($to)."\""); 
     2132                iil_PutLine($fp, "cpy1 UID COPY $messages \"".iil_Escape($to)."\""); 
    21332133                $line=iil_ReadReply($fp); 
    21342134                return iil_ParseResult($line); 
     
    28442844        $num_in_trash = iil_C_CountMessages($conn, $folder); 
    28452845        if ($num_in_trash > 0) { 
    2846                 iil_C_Delete($conn, $folder, '1:' . $num_in_trash); 
     2846                iil_C_Delete($conn, $folder, '1:*'); 
    28472847        } 
    28482848        return (iil_C_Expunge($conn, $folder) >= 0); 
Note: See TracChangeset for help on using the changeset viewer.