public function forwardMessage($type, $contents, $attach = true, array $opts = array())
{
global $prefs;
if (!$contents instanceof IMP_Contents) {
throw new IMP_Exception(_("Could not retrieve message data from the mail server."));
}
if ($type == self::FORWARD_AUTO) {
switch ($prefs->getValue('forward_default')) {
case 'body':
$type = self::FORWARD_BODY;
break;
case 'both':
$type = self::FORWARD_BOTH;
break;
case 'editasnew':
$ret = $this->editAsNew(new IMP_Indices($contents));
$ret['title'] = _("New Message");
return $ret;
case 'attach':
default:
$type = self::FORWARD_ATTACH;
break;
}
}
$h = $contents->getHeader();
$this->_replytype = $type;
$this->_setMetadata('indices', $contents->getIndicesOb());
if (strlen($s = $h['Subject'])) {
$s = strval(new Horde_Imap_Client_Data_BaseSubject($s, array('keepblob' => true)));
$subject = 'Fwd: ' . $s;
$title = _("Forward") . ': ' . $s;
} else {
$subject = 'Fwd:';
$title = _("Forward");
}
$fwd_attach = false;
if ($attach && in_array($type, array(self::FORWARD_ATTACH, self::FORWARD_BOTH))) {
try {
$this->attachImapMessage(new IMP_Indices($contents));
$fwd_attach = true;
} catch (IMP_Exception $e) {
}
}
if (in_array($type, array(self::FORWARD_BODY, self::FORWARD_BOTH))) {
$ret = $this->forwardMessageText($contents, array('format' => isset($opts['format']) ? $opts['format'] : null));
unset($ret['charset']);
} else {
$ret = array('body' => '', 'format' => $prefs->getValue('compose_html') ? 'html' : 'text');
}
return array_merge(array('attach' => $fwd_attach, 'identity' => $this->_getMatchingIdentity($h), 'subject' => $subject, 'title' => $title, 'type' => $type), $ret);
}