From 75c09e2a5dfaf8e04de6014b4e9450fe703007b7 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Tue, 30 Jul 2013 00:19:02 +0200 Subject: [PATCH] Fixup last commit #495680c3d359e504186c These changes should have been in the last commit too. --- file/lib/data/message/Message.class.php | 4 +- file/lib/data/message/MessageList.class.php | 19 +++++ file/lib/page/LogPage.class.php | 87 --------------------- language/de.xml | 8 ++ 4 files changed, 29 insertions(+), 89 deletions(-) delete mode 100644 file/lib/page/LogPage.class.php diff --git a/file/lib/data/message/Message.class.php b/file/lib/data/message/Message.class.php index f4f70e6..9464f31 100644 --- a/file/lib/data/message/Message.class.php +++ b/file/lib/data/message/Message.class.php @@ -70,7 +70,7 @@ public function __toString() { public function getFormattedMessage($type = 'text/html') { $message = $this->message; $messageParser = \wcf\system\bbcode\MessageParser::getInstance(); - $messageParser->setOutputType('text/html'); + $messageParser->setOutputType($type); switch ($this->type) { case self::TYPE_JOIN: @@ -91,7 +91,7 @@ public function getFormattedMessage($type = 'text/html') { case self::TYPE_NORMAL: case self::TYPE_ME: default: - if ($type !== 'text/html') return $message; + if ($type === 'text/plain') return $message; $message = $messageParser->parse($message, $this->enableSmilies, $this->enableHTML, true, false); break; diff --git a/file/lib/data/message/MessageList.class.php b/file/lib/data/message/MessageList.class.php index 07b6c7d..2cee65b 100644 --- a/file/lib/data/message/MessageList.class.php +++ b/file/lib/data/message/MessageList.class.php @@ -60,4 +60,23 @@ public static function getMessagesSince(\chat\data\room\Room $room, $since) { $messageList->readObjects(); return $messageList->getObjects(); } + + /** + * Reads the message between the given timestamps for the given room. + * + * @param \chat\data\room\Room $room + * @param integer $start + * @param integer $end + * @return array<\chat\data\message\Message> + */ + public static function getMessagesBetween(\chat\data\room\Room $room, $start, $end) { + $messageList = new static(); + $messageList->sqlOrderBy = "message.messageID ASC"; + $messageList->getConditionBuilder()->add('message.receiver IS NULL', array()); + $messageList->getConditionBuilder()->add('message.roomID = ?', array($room->roomID)); + $messageList->getConditionBuilder()->add('message.time BETWEEN ? AND ?', array($start, $end)); + + $messageList->readObjects(); + return $messageList->getObjects(); + } } diff --git a/file/lib/page/LogPage.class.php b/file/lib/page/LogPage.class.php deleted file mode 100644 index b528281..0000000 --- a/file/lib/page/LogPage.class.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @package be.bastelstu.chat - * @subpackage page - */ -class LogPage extends \wcf\page\AbstractPage { - /** - * @see wcf\page\AbstractPage::$loginRequired - */ - public $loginRequired = true; - - /** - * TODO: comment this - * - * @var array<\wcf\data\chat\message\ChatMessage> - */ - public $messages = array(); - - /** - * @see \wcf\page\AbstractPage::$neededModules - */ - public $neededModules = array('MODULE_CHAT'); - - /** - * @see \wcf\page\AbstractPage::$neededPermissions - */ - public $neededPermissions = array('mod.chat.canReadLog'); - - /** - * given roomID - * @var integer - */ - public $roomID = 0; - - /** - * given room - * @var \chat\data\room\Chat - */ - public $room = null; - - /** - * @see \wcf\page\IPage::assignVariables() - */ - public function assignVariables() { - parent::assignVariables(); - - WCF::getTPL()->assign(array( - 'messages' => $this->messages, - 'room' => $this->room, - 'roomID' => $this->roomID - )); - } - - /** - * @see \wcf\page\IPage::readParameters() - */ - public function readParameters() { - parent::readParameters(); - - if (isset($_REQUEST['id'])) $this->roomID = intval($_REQUEST['id']); - } - - /** - * @see \wcf\page\IPage::readData() - */ - public function readData() { - parent::readData(); - - $this->room = data\room\RoomCache::getInstance()->getRoom($this->roomID); - if (!$this->room) throw new IllegalLinkException(); - if (!$this->room->canEnter()) throw new PermissionDeniedException(); - - // TODO: actually read the correct messages - $this->messages = data\message\MessageList::getNewestMessages($this->room, 150); - } -} diff --git a/language/de.xml b/language/de.xml index c46fc3f..459c093 100644 --- a/language/de.xml +++ b/language/de.xml @@ -21,8 +21,16 @@ revokerUsername}]]> + + + + + + + +