prevent marking a message as seen by using PEEK, when trying to gather information about an attachment; fix problem with dovecot ->too long argument<-

This commit is contained in:
Klaus Leithoff 2012-07-10 14:47:53 +00:00
parent bb6cf03bc8
commit 94cf7e00ae

View File

@ -729,31 +729,42 @@
switch($_flag) { switch($_flag) {
case "flagged": case "flagged":
$this->icServer->setFlags($_messageUID, '\\Flagged', 'add', true); $ret = $this->icServer->setFlags($_messageUID, '\\Flagged', 'add', true);
break; break;
case "read": case "read":
$this->icServer->setFlags($_messageUID, '\\Seen', 'add', true); $ret = $this->icServer->setFlags($_messageUID, '\\Seen', 'add', true);
break; break;
case "forwarded": case "forwarded":
$this->icServer->setFlags($_messageUID, '$Forwarded', 'add', true); $ret = $this->icServer->setFlags($_messageUID, '$Forwarded', 'add', true);
case "answered": case "answered":
$this->icServer->setFlags($_messageUID, '\\Answered', 'add', true); $ret = $this->icServer->setFlags($_messageUID, '\\Answered', 'add', true);
break; break;
case "unflagged": case "unflagged":
$this->icServer->setFlags($_messageUID, '\\Flagged', 'remove', true); $ret = $this->icServer->setFlags($_messageUID, '\\Flagged', 'remove', true);
break; break;
case "unread": case "unread":
$this->icServer->setFlags($_messageUID, '\\Seen', 'remove', true); $ret = $this->icServer->setFlags($_messageUID, '\\Seen', 'remove', true);
$this->icServer->setFlags($_messageUID, '\\Answered', 'remove', true); $ret = $this->icServer->setFlags($_messageUID, '\\Answered', 'remove', true);
$this->icServer->setFlags($_messageUID, '$Forwarded', 'remove', true); $ret = $this->icServer->setFlags($_messageUID, '$Forwarded', 'remove', true);
break; break;
case "mdnsent": case "mdnsent":
$this->icServer->setFlags($_messageUID, 'MDNSent', 'add', true); $ret = $this->icServer->setFlags($_messageUID, 'MDNSent', 'add', true);
break; break;
case "mdnnotsent": case "mdnnotsent":
$this->icServer->setFlags($_messageUID, 'MDNnotSent', 'add', true); $ret = $this->icServer->setFlags($_messageUID, 'MDNnotSent', 'add', true);
break; break;
} }
if (PEAR::isError($ret))
{
if (stripos($ret->message,'Too long argument'))
{
$c = count($_messageUID);
$h =ceil($c/2);
error_log(__METHOD__.__LINE__.$ret->message." $c messages given for flagging. Trying with chunks of $h");
$this->flagMessages($_flag, array_slice($_messageUID,0,$h));
$this->flagMessages($_flag, array_slice($_messageUID,$h));
}
}
$this->sessionData['folderStatus'][$this->profileID][$this->sessionData['mailbox']]['uidValidity'] = 0; $this->sessionData['folderStatus'][$this->profileID][$this->sessionData['mailbox']]['uidValidity'] = 0;
$this->saveSessionData(); $this->saveSessionData();
@ -1164,7 +1175,7 @@
$structure = $this->_getSubStructure($structure, $_partID); $structure = $this->_getSubStructure($structure, $_partID);
} }
$filename = self::getFileNameFromStructure($structure); $filename = self::getFileNameFromStructure($structure);
$attachment = $this->icServer->getBodyPart($_uid, $_partID, true); $attachment = $this->icServer->getBodyPart($_uid, $_partID, true, true);
if (PEAR::isError($attachment)) if (PEAR::isError($attachment))
{ {
@ -1764,7 +1775,7 @@
return $charSet; return $charSet;
} }
function getMultipartAlternative($_uid, $_structure, $_htmlMode) function getMultipartAlternative($_uid, $_structure, $_htmlMode, $_preserveSeen = false)
{ {
// a multipart/alternative has exactly 2 parts (text and html OR text and something else) // a multipart/alternative has exactly 2 parts (text and html OR text and something else)
@ -1783,7 +1794,7 @@
$partHTML = $mimePart; $partHTML = $mimePart;
} elseif ($mimePart->type == 'MULTIPART' && $mimePart->subType == 'ALTERNATIVE' && is_array($mimePart->subParts)) { } elseif ($mimePart->type == 'MULTIPART' && $mimePart->subType == 'ALTERNATIVE' && is_array($mimePart->subParts)) {
//cascading multipartAlternative structure, assuming only the first one is to be used //cascading multipartAlternative structure, assuming only the first one is to be used
return $this->getMultipartAlternative($_uid,$mimePart->subParts,$_htmlMode); return $this->getMultipartAlternative($_uid,$mimePart->subParts,$_htmlMode, $_preserveSeen);
} }
} }
@ -1791,23 +1802,23 @@
case 'always_display': case 'always_display':
if(is_object($partHTML)) { if(is_object($partHTML)) {
if($partHTML->subType == 'RELATED') { if($partHTML->subType == 'RELATED') {
return $this->getMultipartRelated($_uid, $partHTML, 'always_display'); return $this->getMultipartRelated($_uid, $partHTML, 'always_display', $_preserveSeen);
} else { } else {
return $this->getTextPart($_uid, $partHTML, 'always_display'); return $this->getTextPart($_uid, $partHTML, 'always_display',$_preserveSeen);
} }
} elseif(is_object($partText)) { } elseif(is_object($partText)) {
return $this->getTextPart($_uid, $partText); return $this->getTextPart($_uid, $partTexti, $_htmlMode, $_preserveSeen);
} }
break; break;
case 'only_if_no_text': case 'only_if_no_text':
if(is_object($partText)) { if(is_object($partText)) {
return $this->getTextPart($_uid, $partText); return $this->getTextPart($_uid, $partText, $_htmlMode, $_preserveSeen);
} elseif(is_object($partHTML)) { } elseif(is_object($partHTML)) {
if($partHTML->type) { if($partHTML->type) {
return $this->getMultipartRelated($_uid, $partHTML, $_htmlMode); return $this->getMultipartRelated($_uid, $partHTML, $_htmlMode, $_preserveSeen);
} else { } else {
return $this->getTextPart($_uid, $partHTML, 'always_display'); return $this->getTextPart($_uid, $partHTML, 'always_display', $_preserveSeen);
} }
} }
@ -1815,7 +1826,7 @@
default: default:
if(is_object($partText)) { if(is_object($partText)) {
return $this->getTextPart($_uid, $partText); return $this->getTextPart($_uid, $partText, $_htmlMode, $_preserveSeen);
} else { } else {
$bodyPart = array( $bodyPart = array(
'body' => lang("no plain text part found"), 'body' => lang("no plain text part found"),
@ -1830,7 +1841,7 @@
return $bodyPart; return $bodyPart;
} }
function getMultipartMixed($_uid, $_structure, $_htmlMode) function getMultipartMixed($_uid, $_structure, $_htmlMode, $_preserveSeen = false)
{ {
if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>"; if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>";
$bodyPart = array(); $bodyPart = array();
@ -1842,16 +1853,16 @@
case 'MULTIPART': case 'MULTIPART':
switch($part->subType) { switch($part->subType) {
case 'ALTERNATIVE': case 'ALTERNATIVE':
$bodyPart[] = $this->getMultipartAlternative($_uid, $part->subParts, $_htmlMode); $bodyPart[] = $this->getMultipartAlternative($_uid, $part->subParts, $_htmlMode, $_preserveSeen);
break; break;
case 'MIXED': case 'MIXED':
case 'SIGNED': case 'SIGNED':
$bodyPart = array_merge($bodyPart, $this->getMultipartMixed($_uid, $part->subParts, $_htmlMode)); $bodyPart = array_merge($bodyPart, $this->getMultipartMixed($_uid, $part->subParts, $_htmlMode, $_preserveSeen));
break; break;
case 'RELATED': case 'RELATED':
$bodyPart = array_merge($bodyPart, $this->getMultipartRelated($_uid, $part->subParts, $_htmlMode)); $bodyPart = array_merge($bodyPart, $this->getMultipartRelated($_uid, $part->subParts, $_htmlMode, $_preserveSeen));
break; break;
} }
break; break;
@ -1861,7 +1872,7 @@
case 'PLAIN': case 'PLAIN':
case 'HTML': case 'HTML':
if($part->disposition != 'ATTACHMENT') { if($part->disposition != 'ATTACHMENT') {
$bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode); $bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen);
} }
break; break;
} }
@ -1869,7 +1880,7 @@
case 'MESSAGE': case 'MESSAGE':
if($part->subType == 'delivery-status') { if($part->subType == 'delivery-status') {
$bodyPart[] = $this->getTextPart($_uid, $part); $bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen);
} }
break; break;
@ -1886,17 +1897,17 @@
return $bodyPart; return $bodyPart;
} }
function getMultipartRelated($_uid, $_structure, $_htmlMode) function getMultipartRelated($_uid, $_structure, $_htmlMode, $_preserveSeen = false)
{ {
return $this->getMultipartMixed($_uid, $_structure, $_htmlMode); return $this->getMultipartMixed($_uid, $_structure, $_htmlMode, $_preserveSeen);
} }
function getTextPart($_uid, $_structure, $_htmlMode = '') function getTextPart($_uid, $_structure, $_htmlMode = '', $_preserveSeen = false)
{ {
$bodyPart = array(); $bodyPart = array();
#_debug_array($_structure); #_debug_array($_structure);
$partID = $_structure->partID; $partID = $_structure->partID;
$mimePartBody = $this->icServer->getBodyPart($_uid, $partID, true); $mimePartBody = $this->icServer->getBodyPart($_uid, $partID, true, $_preserveSeen);
if (PEAR::isError($mimePartBody)) if (PEAR::isError($mimePartBody))
{ {
error_log(__METHOD__.__LINE__.' failed:'.$mimePartBody->message); error_log(__METHOD__.__LINE__.' failed:'.$mimePartBody->message);
@ -2405,7 +2416,7 @@
} }
} }
function getMessageBody($_uid, $_htmlOptions='', $_partID='', $_structure = '') function getMessageBody($_uid, $_htmlOptions='', $_partID='', $_structure = '', $_preserveSeen = false)
{ {
if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>"; if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>";
if($_htmlOptions != '') { if($_htmlOptions != '') {
@ -2433,18 +2444,18 @@
case 'MULTIPART': case 'MULTIPART':
switch($structure->subType) { switch($structure->subType) {
case 'ALTERNATIVE': case 'ALTERNATIVE':
$bodyParts = array($this->getMultipartAlternative($_uid, $structure->subParts, $this->htmlOptions)); $bodyParts = array($this->getMultipartAlternative($_uid, $structure->subParts, $this->htmlOptions, $_preserveSeen));
break; break;
case 'MIXED': case 'MIXED':
case 'REPORT': case 'REPORT':
case 'SIGNED': case 'SIGNED':
$bodyParts = $this->getMultipartMixed($_uid, $structure->subParts, $this->htmlOptions); $bodyParts = $this->getMultipartMixed($_uid, $structure->subParts, $this->htmlOptions, $_preserveSeen);
break; break;
case 'RELATED': case 'RELATED':
$bodyParts = $this->getMultipartRelated($_uid, $structure->subParts, $this->htmlOptions); $bodyParts = $this->getMultipartRelated($_uid, $structure->subParts, $this->htmlOptions, $_preserveSeen);
break; break;
} }
return self::normalizeBodyParts($bodyParts); return self::normalizeBodyParts($bodyParts);
@ -2471,7 +2482,7 @@
case 'HTML': case 'HTML':
case 'PLAIN': case 'PLAIN':
default: default:
$bodyPart = array($this->getTextPart($_uid, $structure, $this->htmlOptions)); $bodyPart = array($this->getTextPart($_uid, $structure, $this->htmlOptions, $_preserveSeen));
} }
} else { } else {
// what if the structure->disposition is attachment ,... // what if the structure->disposition is attachment ,...