- fix save/delete draft message with enabled threading (#1486596)

- performance improvement using UID SEARCH intead of SEARCH + FETCH
- re-fix r3445
release-0.6
alecpl 15 years ago
parent 024f05762a
commit 6f31b356b2

@ -1414,6 +1414,27 @@ class rcube_imap
return $a_messages; return $a_messages;
} }
/**
* Direct (real and simple) SEARCH request to IMAP server,
* without result sorting and caching
*
* @param string Mailbox name to search in
* @param string Search string
* @param boolean True if UIDs should be returned
* @return array Search results as list of message IDs or UIDs
* @access public
*/
function search_once($mbox_name='', $str=NULL, $ret_uid=false)
{
if (!$str)
return false;
$mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox;
return $this->conn->search($mailbox, $str, $ret_uid);
}
/** /**
* Sort thread * Sort thread

@ -366,7 +366,7 @@ class rcube_imap_generic
} }
// generate hash // generate hash
$hash = md5($this->xor($pass,$opad) . pack("H*", md5($this->xor($pass, $ipad) . base64_decode($encChallenge)))); $hash = md5($this->_xor($pass,$opad) . pack("H*", md5($this->_xor($pass, $ipad) . base64_decode($encChallenge))));
// generate reply // generate reply
$reply = base64_encode($user . ' ' . $hash); $reply = base64_encode($user . ' ' . $hash);
@ -1553,18 +1553,19 @@ class rcube_imap_generic
return false; return false;
} }
function search($folder, $criteria) function search($folder, $criteria, $return_uid=false)
{ {
if (!$this->select($folder)) { if (!$this->select($folder)) {
return false; return false;
} }
$data = ''; $data = '';
$query = "srch1 SEARCH " . chop($criteria); $query = 'srch1 ' . ($return_uid ? 'UID ' : '') . 'SEARCH ' . chop($criteria);
if (!$this->putLineC($query)) { if (!$this->putLineC($query)) {
return false; return false;
} }
do { do {
$line = trim($this->readLine()); $line = trim($this->readLine());
if ($this->startsWith($line, '* SEARCH')) { if ($this->startsWith($line, '* SEARCH')) {
@ -2150,7 +2151,7 @@ class rcube_imap_generic
return $result; return $result;
} }
private function xor($string, $string2) private function _xor($string, $string2)
{ {
$result = ''; $result = '';
$size = strlen($string); $size = strlen($string);

@ -617,9 +617,9 @@ if ($store_target)
if ($olddraftmessageid) if ($olddraftmessageid)
{ {
// delete previous saved draft // delete previous saved draft
$a_deleteid = $IMAP->search($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$olddraftmessageid); $a_deleteid = $IMAP->search_once($CONFIG['drafts_mbox'],
'HEADER Message-ID '.$olddraftmessageid, true);
$deleted = $IMAP->delete_message($IMAP->get_uid($a_deleteid[0], $CONFIG['drafts_mbox']), $CONFIG['drafts_mbox']); $deleted = $IMAP->delete_message($a_deleteid, $CONFIG['drafts_mbox']);
// raise error if deletion of old draft failed // raise error if deletion of old draft failed
if (!$deleted) if (!$deleted)
@ -639,8 +639,8 @@ if ($savedraft)
$msgid = strtr($message_id, array('>' => '', '<' => '')); $msgid = strtr($message_id, array('>' => '', '<' => ''));
// remember new draft-uid // remember new draft-uid
$draftids = $IMAP->search($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid); $draftuids = $IMAP->search_once($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid, true);
$_SESSION['compose']['param']['_draft_uid'] = $IMAP->get_uid($draftids[0], $CONFIG['drafts_mbox']); $_SESSION['compose']['param']['_draft_uid'] = $draftuids[0];
// display success // display success
$OUTPUT->show_message('messagesaved', 'confirmation'); $OUTPUT->show_message('messagesaved', 'confirmation');

Loading…
Cancel
Save