Skip to content
Snippets Groups Projects
Commit afa31e93 authored by Peter Rotich's avatar Peter Rotich Committed by GitHub
Browse files

Merge pull request #3757 from protich/feature/max-text

Chunk long text body
parents 86424933 7b68c994
No related branches found
No related tags found
No related merge requests found
......@@ -601,6 +601,7 @@ implements TemplateVariable {
const PERM_EDIT = 'thread.edit';
var $_headers;
var $_body;
var $_thread;
var $_actions;
var $is_autoreply;
......@@ -676,9 +677,21 @@ implements TemplateVariable {
}
function getBody() {
return ThreadEntryBody::fromFormattedText($this->body, $this->format,
array('balanced' => $this->hasFlag(self::FLAG_BALANCED))
);
if (!isset($this->_body)) {
$body = $this->body;
if ($body == null && $this->getNumAttachments()) {
foreach ($this->attachments as $a)
if ($a->inline && ($f=$a->getFile()))
$body .= $f->getData();
}
$this->_body = ThreadEntryBody::fromFormattedText($body, $this->format,
array('balanced' => $this->hasFlag(self::FLAG_BALANCED))
);
}
return $this->_body;
}
function setBody($body) {
......@@ -1396,14 +1409,36 @@ implements TemplateVariable {
// Set body here after it was rewritten to capture the stored file
// keys (above)
$entry->body = $body;
if (!$entry->save())
// Store body as an attachment if bigger than allowed packet size
if (mb_strlen($body) >= 65000) { // 65,535 chars in text field.
$entry->body = NULL;
$file = array(
'type' => 'text/html',
'name' => md5($body).'.txt',
'data' => $body,
);
if (($AF = AttachmentFile::create($file))) {
$attached_files[$file['key']] = array(
'id' => $AF->getId(),
'inline' => true,
'file' => $AF);
} else {
$entry->body = $body;
}
} else {
$entry->body = $body;
}
if (!$entry->save(true))
return false;
// Associate the attached files with this new entry
$entry->createAttachments($attached_files);
// Save mail message id, if available
$entry->saveEmailInfo($vars);
......
......@@ -123,7 +123,7 @@ JS
$old = $this->entry;
$new = ThreadEntryBody::fromFormattedText($_POST['body'], $old->format);
if ($new->getClean() == $old->body)
if ($new->getClean() == $old->getBody())
// No update was performed
return $old;
......
......@@ -34,7 +34,8 @@
class="large <?php
if ($cfg->isRichTextEnabled() && $this->entry->format == 'html')
echo 'richtext';
?>"><?php echo htmlspecialchars(Format::viewableImages($this->entry->body));
?>"><?php echo htmlspecialchars(Format::viewableImages(
(string) $this->entry->getBody()));
?></textarea>
<?php if ($this->entry->type == 'R') { ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment