Use TUserContent
authorMatthias Schmidt <gravatronics@live.com>
Tue, 22 Dec 2015 10:39:30 +0000 (11:39 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 22 Dec 2015 10:39:30 +0000 (11:39 +0100)
files/lib/data/conversation/message/ConversationMessage.class.php

index a90af597b767e9e49cf219165367d0681ea4249b..048f132bf4c96f3fb4eed88746118ae51cb00332 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\attachment\GroupedAttachmentList;
 use wcf\data\conversation\Conversation;
 use wcf\data\DatabaseObject;
 use wcf\data\IMessage;
+use wcf\data\TUserContent;
 use wcf\system\bbcode\MessageParser;
 use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
 use wcf\system\request\LinkHandler;
@@ -21,24 +22,26 @@ use wcf\util\StringUtil;
  * @category   Community Framework
  */
 class ConversationMessage extends DatabaseObject implements IMessage {
+       use TUserContent;
+       
        /**
-        * @see \wcf\data\DatabaseObject::$databaseTableName
+        * @inheritdoc
         */
        protected static $databaseTableName = 'conversation_message';
        
        /**
-        * @see \wcf\data\DatabaseObject::$databaseIndexName
+        * @inheritdoc
         */
        protected static $databaseTableIndexName = 'messageID';
        
        /**
         * conversation object
-        * @var \wcf\data\conversation\Conversation
+        * @var Conversation
         */
        protected $conversation = null;
        
        /**
-        * @see \wcf\data\IMessage::getFormattedMessage()
+        * @inheritdoc
         */
        public function getFormattedMessage() {
                // assign embedded objects
@@ -63,17 +66,17 @@ class ConversationMessage extends DatabaseObject implements IMessage {
         * Assigns and returns the embedded attachments.
         * 
         * @param       boolean         $ignoreCache
-        * @return      \wcf\data\attachment\GroupedAttachmentList
+        * @return      GroupedAttachmentList
         */
        public function getAttachments($ignoreCache = false) {
                if (MODULE_ATTACHMENT == 1 && ($this->attachments || $ignoreCache)) {
                        $attachmentList = new GroupedAttachmentList('com.woltlab.wcf.conversation.message');
-                       $attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', array($this->messageID));
+                       $attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', [$this->messageID]);
                        $attachmentList->readObjects();
-                       $attachmentList->setPermissions(array(
+                       $attachmentList->setPermissions([
                                'canDownload' => true,
                                'canViewPreview' => true
-                       ));
+                       ]);
                        
                        if ($ignoreCache && !count($attachmentList)) {
                                return null;
@@ -86,10 +89,7 @@ class ConversationMessage extends DatabaseObject implements IMessage {
        }
        
        /**
-        * Returns an excerpt of this message.
-        * 
-        * @param       string          $maxLength
-        * @return      string
+        * @inheritdoc
         */
        public function getExcerpt($maxLength = 255) {
                return StringUtil::truncateHTML($this->getSimplifiedFormattedMessage(), $maxLength);
@@ -110,7 +110,7 @@ class ConversationMessage extends DatabaseObject implements IMessage {
        /**
         * Returns the conversation of this message.
         * 
-        * @return      \wcf\data\conversation\Conversation
+        * @return      Conversation
         */
        public function getConversation() {
                if ($this->conversation === null) {
@@ -123,7 +123,7 @@ class ConversationMessage extends DatabaseObject implements IMessage {
        /**
         * Sets the conversation of this message.
         * 
-        * @param       \wcf\data\conversation\Conversation     $conversation
+        * @param       Conversation    $conversation
         */
        public function setConversation(Conversation $conversation) {
                if ($this->conversationID == $conversation->conversationID) {
@@ -141,31 +141,24 @@ class ConversationMessage extends DatabaseObject implements IMessage {
        }
        
        /**
-        * @see \wcf\data\IMessage::getMessage()
+        * @inheritdoc
         */
        public function getMessage() {
                return $this->message;
        }
        
        /**
-        * @see \wcf\data\ILinkableObject::getLink()
+        * @inheritdoc
         */
        public function getLink() {
-               return LinkHandler::getInstance()->getLink('Conversation', array(
+               return LinkHandler::getInstance()->getLink('Conversation', [
                        'object' => $this->getConversation(),
                        'messageID' => $this->messageID
-               ), '#message'.$this->messageID);
-       }
-       
-       /**
-        * @see \wcf\data\IMessage::getTime()
-        */
-       public function getTime() {
-               return $this->time;
+               ], '#message'.$this->messageID);
        }
        
        /**
-        * @see \wcf\data\ITitledObject::getTitle()
+        * @inheritdoc
         */
        public function getTitle() {
                if ($this->messageID == $this->getConversation()->firstMessageID) {
@@ -176,28 +169,14 @@ class ConversationMessage extends DatabaseObject implements IMessage {
        }
        
        /**
-        * @see \wcf\data\IMessage::getUserID()
-        */
-       public function getUserID() {
-               return $this->userID;
-       }
-       
-       /**
-        * @see \wcf\data\IMessage::getUsername()
-        */
-       public function getUsername() {
-               return $this->username;
-       }
-       
-       /**
-        * @see \wcf\data\IMessage::isVisible()
+        * @inheritdoc
         */
        public function isVisible() {
                return true;
        }
        
        /**
-        * @see \wcf\data\IMessage::__toString()
+        * @inheritdoc
         */
        public function __toString() {
                return $this->getFormattedMessage();