/** * Updates the data of this post. * * @param string $subject new subject of this post * @param string $message new text of this post * @param array $options new options of this post * @param AttachmentsEditor $attachments * @param PollEditor $poll */ public function update($subject, $message, $options, $attachments = null, $poll = null, $additionalData = array()) { $updateSubject = $updateText = ''; $attachmentsAmount = $attachments != null ? count($attachments->getAttachments($this->postID)) : 0; // save subject if ($subject != $this->subject) { $updateSubject = "subject = '" . escapeString($subject) . "',"; } // save message $updateText = "message = '" . escapeString($message) . "',"; // assign attachments if ($attachments != null) { require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($attachments->getSortedAttachments()); } // update post cache require_once WCF_DIR . 'lib/data/message/bbcode/MessageParser.class.php'; $parser = MessageParser::getInstance(); $parser->setOutputType('text/html'); $sql = "UPDATE\twbb" . WBB_N . "_post_cache\n\t\t\tSET\tmessageCache = '" . escapeString($parser->parse($message, $options['enableSmilies'], $options['enableHtml'], $options['enableBBCodes'], false)) . "'\n\t\t\tWHERE\tpostID = " . $this->postID; WCF::getDB()->registerShutdownUpdate($sql); $additionalSql = ''; foreach ($additionalData as $key => $value) { $additionalSql .= ',' . $key . "='" . escapeString($value) . "'"; } // save post in database $sql = "UPDATE \twbb" . WBB_N . "_post\n\t\t\tSET\t{$updateSubject}\n\t\t\t\t{$updateText}\n\t\t\t\tattachments = " . $attachmentsAmount . ",\n\t\t\t\t" . ($poll != null ? "pollID = " . intval($poll->pollID) . "," : '') . "\n\t\t\t\tenableSmilies = " . $options['enableSmilies'] . ",\n\t\t\t\tenableHtml = " . $options['enableHtml'] . ",\n\t\t\t\tenableBBCodes = " . $options['enableBBCodes'] . ",\n\t\t\t\tshowSignature = " . $options['showSignature'] . "\n\t\t\t\t" . $additionalSql . "\n\t\t\tWHERE \tpostID = " . $this->postID; WCF::getDB()->sendQuery($sql); // update attachments if ($attachments != null) { $attachments->findEmbeddedAttachments($message); } // update poll if ($poll != null) { $poll->updateMessageID($this->postID); } // update first post preview $this->updateFirstPostPreview($this->threadID, $this->postID, $message, $options); // refresh thread data require_once WBB_DIR . 'lib/data/thread/ThreadEditor.class.php'; ThreadEditor::refreshAll($this->threadID, false); }