) {
$part = $this->_getRfc822Attachment($attachment, $_message);
+ } else if (isset($attachment['type'])
+ && $attachment['type'] == 'filenode'
+ ) {
+ $part = $this->_getFileNodeAttachment($attachment);
+
} else if ($attachment instanceof Tinebase_Model_TempFile || isset($attachment['tempFile'])) {
$part = $this->_getTempFileAttachment($attachment);
}
/**
+ * get attachment defined by a file node (mailfiler or filemanager)
+ *
+ * @param $attachment
+ * @return null|Zend_Mime_Part
+ * @throws Tinebase_Exception_NotFound
+ *
+ * TODO support Filemanager files
+ * TODO allow to omit $messageuid, $partId
+ */
+ protected function _getFileNodeAttachment(&$attachment)
+ {
+ list($appname, $path, $messageuid, $partId) = explode('|', $attachment['id']);
+
+ $nodeController = Tinebase_Core::getApplicationInstance($appname . '_Model_Node');
+
+ // remove filename from path
+ // TODO remove DRY with \MailFiler_Frontend_Http::downloadAttachment
+ $pathParts = explode('/', $path);
+ array_pop($pathParts);
+ $path = implode('/', $pathParts);
+
+ $filter = array(
+ array(
+ 'field' => 'path',
+ 'operator' => 'equals',
+ 'value' => $path
+ ),
+ array(
+ 'field' => 'messageuid',
+ 'operator' => 'equals',
+ 'value' => $messageuid
+ ));
+ $node = $nodeController->search(new MailFiler_Model_NodeFilter($filter))->getFirstRecord();
+ if ($node) {
+ $mailpart = $nodeController->getPartFromNode($node, $partId);
+ // TODO use streams
+ $content = $content = Felamimail_Message::getDecodedContent($mailpart);
+ $part = new Zend_Mime_Part($content);
+ $part->encoding = Zend_Mime::ENCODING_BASE64;
+ } else {
+ if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__
+ . ' Could not find file node attachment');
+ $part = null;
+ }
+
+ return $part;
+ }
+
+ /**
* get attachment defined by temp file
*
* @param $attachment
onMessageReplyTo: function(toAll) {
var sm = this.getGrid().getSelectionModel(),
- msg = sm.getSelected().get('message');
+ node = sm.getSelected();
+ msg = node.get('message'),
+ msgBody = msg.body;
- // TODO pass all relevant params (body, subject, ...) to prevent mail loading in Felamimail
+ msgBody = '<br/>'
+ + '<blockquote class="felamimail-body-blockquote">' + msgBody + '</blockquote><br/>';
+
+ var date = msg.sent
+ ? msg.sent
+ : (msg.received) ? msg.received : new Date();
+
+ var quote = String.format(this.app.i18n._('On {0}, {1} wrote'),
+ Tine.Tinebase.common.dateTimeRenderer(date),
+ Ext.util.Format.htmlEncode(msg.from_name)
+ ) + ':';
+
+ // pass all relevant params (body, subject, ...) to prevent mail loading in Felamimail
var win = Tine.Felamimail.MessageEditDialog.openWindow({
+ //record: msg,
replyTo : Ext.encode(msg),
- replyToAll: toAll
+ replyToAll: toAll,
+ msgBody: quote + msgBody
});
},
onMessageForward: function() {
var sm = this.getGrid().getSelectionModel(),
- msg = sm.getSelected().get('message');
+ node = sm.getSelected();
+ msg = node.get('message'),
+ msgBody = msg.body,
+ quote = String.format('{0}-----' + this.app.i18n._('Original message') + '-----{1}',
+ '<br /><b>',
+ '</b><br />'),
+ attachments = msg.attachments;
+
+ Ext.each(attachments, function(attachment) {
+ // set name and MailFiler path for fetching attachment from filesystem when sending
+ attachment.name = attachment.filename;
+ attachment.type = 'filenode';
+ attachment.id = 'MailFiler' + '|' + node.get('path') + '|' + msg.messageuid + '|' + attachment.partId
+ }, this);
- // TODO pass all relevant params (body, subject, ...) to prevent mail loading in Felamimail
+ // pass all relevant params (body, subject, ...) to prevent mail loading in Felamimail
var win = Tine.Felamimail.MessageEditDialog.openWindow({
- forwardMsgs : Ext.encode([msg])
+ forwardMsgs : Ext.encode([msg]),
+ attachments: attachments,
+ msgBody: quote + msgBody
});
},