Fixed display or comment/response author for reported content
authorAlexander Ebert <ebert@woltlab.com>
Tue, 17 Feb 2015 13:24:34 +0000 (14:24 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 17 Feb 2015 13:24:34 +0000 (14:24 +0100)
wcfsetup/install/files/lib/data/comment/ViewableComment.class.php
wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponse.class.php
wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponseList.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/moderation/queue/report/CommentCommentModerationQueueReportHandler.class.php
wcfsetup/install/files/lib/system/moderation/queue/report/CommentResponseModerationQueueReportHandler.class.php

index 8dba394343dcb72727ab4e5a29c5e55a1b97e723..2036c37b718ea46c3f9192bb945c09030226e498 100644 (file)
@@ -8,7 +8,7 @@ use wcf\data\DatabaseObjectDecorator;
  * Represents a viewable comment.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2014 WoltLab GmbH
+ * @copyright  2001-2015 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage data.comment
@@ -38,4 +38,19 @@ class ViewableComment extends DatabaseObjectDecorator {
                
                return $this->userProfile;
        }
+       
+       /**
+        * Gets a specific comment decorated as comment entry.
+        * 
+        * @param       integer         $commentID
+        * @return      \wcf\data\comment\ViewableComment
+        */
+       public static function getComment($commentID) {
+               $list = new ViewableCommentList();
+               $list->setObjectIDs(array($commentID));
+               $list->readObjects();
+               $objects = $list->getObjects();
+               if (isset($objects[$commentID])) return $objects[$commentID];
+               return null;
+       }
 }
index d2ea03e4f394a9d4131c5fee092a78d02df7b8df..a90ae1c9532923c3b5f6a4a1efffbf74378a0a4b 100644 (file)
@@ -8,7 +8,7 @@ use wcf\data\DatabaseObjectDecorator;
  * Represents a viewable comment response.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2014 WoltLab GmbH
+ * @copyright  2001-2015 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage data.comment.response
@@ -38,4 +38,19 @@ class ViewableCommentResponse extends DatabaseObjectDecorator {
                
                return $this->userProfile;
        }
+       
+       /**
+        * Gets a specific comment response decorated as viewable comment response.
+        * 
+        * @param       integer         $responseID
+        * @return      \wcf\data\comment\response\ViewableCommentResponse
+        */
+       public static function getResponse($responseID) {
+               $list = new ViewableCommentResponseList();
+               $list->setObjectIDs(array($responseID));
+               $list->readObjects();
+               $objects = $list->getObjects();
+               if (isset($objects[$responseID])) return $objects[$responseID];
+               return null;
+       }
 }
diff --git a/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponseList.class.php b/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponseList.class.php
new file mode 100644 (file)
index 0000000..e39253b
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+namespace wcf\data\comment\response;
+
+/**
+ * Represents a list of decorated comment response objects.
+ * 
+ * @author     Alexander Ebert
+ * @copyright  2001-2015 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage data.comment.response
+ * @category   Community Framework
+ */
+class ViewableCommentResponseList extends CommentResponseList {
+       /**
+        * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+        */
+       public $decoratorClassName = 'wcf\data\comment\response\ViewableCommentResponse';
+
+       /**
+        * Creates a new ViewableCommentResponseList object.
+        */
+       public function __construct() {
+               parent::__construct();
+       
+               // get avatars
+               if (!empty($this->sqlSelects)) $this->sqlSelects .= ',';
+               $this->sqlSelects .= "user_avatar.*, user_table.*";
+               $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table ON (user_table.userID = comment_response.userID)";
+               $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user_avatar user_avatar ON (user_avatar.avatarID = user_table.avatarID)";
+       }
+}
index 0be0e8f670a7c3ea7cadbad4bf6c57017d381135..2c9df5b307c9206993e893eaaed7d5ea19f3fd86 100644 (file)
@@ -16,7 +16,7 @@ use wcf\system\WCF;
  * An implementation of IModerationQueueReportHandler for comments.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2014 WoltLab GmbH
+ * @copyright  2001-2015 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage system.moderation.queue
@@ -124,7 +124,7 @@ class CommentCommentModerationQueueReportHandler extends AbstractModerationQueue
         */
        public function getReportedContent(ViewableModerationQueue $queue) {
                WCF::getTPL()->assign(array(
-                       'message' => new ViewableComment($queue->getAffectedObject())
+                       'message' => ViewableComment::getComment($queue->objectID)
                ));
                
                return WCF::getTPL()->fetch('moderationComment');
index 0e347595360bbd31febfd06eae94e1962c9d581f..76b155b0f0ac0563693ec1dd4047af1aace57646 100644 (file)
@@ -16,7 +16,7 @@ use wcf\system\WCF;
  * An implementation of IModerationQueueReportHandler for comment responses.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2014 WoltLab GmbH
+ * @copyright  2001-2015 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage system.moderation.queue
@@ -117,7 +117,7 @@ class CommentResponseModerationQueueReportHandler extends CommentCommentModerati
         */
        public function getReportedContent(ViewableModerationQueue $queue) {
                WCF::getTPL()->assign(array(
-                       'message' => new ViewableCommentResponse($queue->getAffectedObject())
+                       'message' => ViewableCommentResponse::getResponse($queue->objectID)
                ));
                
                return WCF::getTPL()->fetch('moderationComment');