Fixes comments/comment responses of deleted users
authorMatthias Schmidt <gravatronics@live.com>
Sat, 1 Jun 2013 17:38:43 +0000 (19:38 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 1 Jun 2013 17:38:43 +0000 (19:38 +0200)
com.woltlab.wcf/template/commentList.tpl
com.woltlab.wcf/template/commentResponseList.tpl
wcfsetup/install/files/lib/data/comment/StructuredComment.class.php
wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponse.class.php

index 093b956bb50486134198bd3f99e1dff1cf738e44..38814db6e736a790321de14ef36c5b5cafc572cc 100644 (file)
@@ -1,14 +1,26 @@
 {foreach from=$commentList item=comment}
        <li class="comment jsComment" data-comment-id="{@$comment->commentID}" data-object-type="com.woltlab.wcf.comment" data-like-liked="{if $likeData[comment][$comment->commentID]|isset}{@$likeData[comment][$comment->commentID]->liked}{/if}" data-like-likes="{if $likeData[comment][$comment->commentID]|isset}{@$likeData[comment][$comment->commentID]->likes}{else}0{/if}" data-like-dislikes="{if $likeData[comment][$comment->commentID]|isset}{@$likeData[comment][$comment->commentID]->dislikes}{else}0{/if}" data-like-users='{if $likeData[comment][$comment->commentID]|isset}{ {implode from=$likeData[comment][$comment->commentID]->getUsers() item=likeUser}"{@$likeUser->userID}": { "username": "{$likeUser->username|encodeJSON}" }{/implode} }{else}{ }{/if}' data-can-edit="{if $comment->isEditable()}true{else}false{/if}" data-can-delete="{if $comment->isDeletable()}true{else}false{/if}" data-responses="{@$comment->responses}" data-last-response-time="{@$comment->getLastResponseTime()}" data-user-id="{@$comment->userID}">
                <div class="box32">
-                       <a href="{link controller='User' object=$comment->getUserProfile()}{/link}" title="{$comment->getUserProfile()->username}" class="framed">
-                               {@$comment->getUserProfile()->getAvatar()->getImageTag(32)}
-                       </a>
+                       {if $comment->userID}
+                               <a href="{link controller='User' object=$comment->getUserProfile()}{/link}" title="{$comment->getUserProfile()->username}" class="framed">
+                                       {@$comment->getUserProfile()->getAvatar()->getImageTag(32)}
+                               </a>
+                       {else}
+                               <span class="framed">{@$comment->getUserProfile()->getAvatar()->getImageTag(32)}</span>
+                       {/if}
                        
                        <div>
                                <div class="commentContent">
                                        <div class="containerHeadline">
-                                               <h3><a href="{link controller='User' object=$comment->getUserProfile()}{/link}" class="userLink" data-user-id="{@$comment->userID}">{$comment->username}</a><small> - {@$comment->time|time}</small></h3> 
+                                               <h3>
+                                                       {if $comment->userID}
+                                                               <a href="{link controller='User' object=$comment->getUserProfile()}{/link}" class="userLink" data-user-id="{@$comment->userID}">{$comment->username}</a>
+                                                       {else}
+                                                               {$comment->username}
+                                                       {/if}
+                                                       
+                                                       <small> - {@$comment->time|time}</small>
+                                               </h3>
                                        </div>
                                        
                                        <p class="userMessage">{@$comment->getFormattedMessage()}</p>
index b5482e16bc26a4bb5087ec7e8fe461e7fe0be2d4..458140a204d382135d6fa4591664745716026dc4 100644 (file)
@@ -1,15 +1,25 @@
 {foreach from=$responseList item=response}
        <li class="commentResponse jsCommentResponse" data-response-id="{@$response->responseID}" data-object-type="com.woltlab.wcf.comment.response" data-like-liked="{if $likeData[response][$response->responseID]|isset}{@$likeData[response][$response->responseID]->liked}{/if}" data-like-likes="{if $likeData[response][$response->responseID]|isset}{@$likeData[response][$response->responseID]->likes}{else}0{/if}" data-like-dislikes="{if $likeData[response][$response->responseID]|isset}{@$likeData[response][$response->responseID]->dislikes}{else}0{/if}" data-like-users='{if $likeData[response][$response->responseID]|isset}{ {implode from=$likeData[response][$response->responseID]->getUsers() item=likeUser}"{@$likeUser->userID}": { "username": "{$likeUser->username|encodeJSON}" }{/implode} }{else}{ }{/if}' data-can-edit="{if $response->isEditable()}true{else}false{/if}" data-can-delete="{if $response->isDeletable()}true{else}false{/if}" data-user-id="{@$response->userID}">
                <div class="box32">
-                       <a href="{link controller='User' object=$response->getUserProfile()}{/link}" title="{$response->getUserProfile()->username}" class="framed">
-                               {if $response->getUserProfile()->getAvatar()}
+                       {if $response->userID}
+                               <a href="{link controller='User' object=$response->getUserProfile()}{/link}" title="{$response->getUserProfile()->username}" class="framed">
                                        {@$response->getUserProfile()->getAvatar()->getImageTag(32)}
-                               {/if}
-                       </a>
+                               </a>
+                       {else}
+                               <span class="framed">{@$response->getUserProfile()->getAvatar()->getImageTag(32)}</span>
+                       {/if}
                        
                        <div class="commentContent commentResponseContent">
                                <div class="containerHeadline">
-                                       <h3><a href="{link controller='User' object=$response->getUserProfile()}{/link}" class="userLink" data-user-id="{@$response->userID}">{$response->username}</a><small> - {@$response->time|time}</small></h3> 
+                                       <h3>
+                                               {if $response->userID}
+                                                       <a href="{link controller='User' object=$response->getUserProfile()}{/link}" class="userLink" data-user-id="{@$response->userID}">{$response->username}</a>
+                                               {else}
+                                                       {$response->username}
+                                               {/if}
+                                               
+                                               <small> - {@$response->time|time}</small>
+                                       </h3>
                                </div>
                                
                                <p class="userMessage">{@$response->getFormattedMessage()}</p>
index 5a13c6d35b05e7ff8f63e3a98cf9bc289ad6b589..5107660a4eeddd350941f5f4c7797267d44a4f81 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\comment;
 use wcf\data\comment\response\StructuredCommentResponse;
+use wcf\data\user\User;
 use wcf\data\user\UserProfile;
 use wcf\data\DatabaseObjectDecorator;
 
@@ -101,6 +102,10 @@ class StructuredComment extends DatabaseObjectDecorator implements \Countable, \
         * @return      wcf\data\user\UserProfile
         */
        public function getUserProfile() {
+               if ($this->userProfile === null) {
+                       $this->userProfile = new UserProfile(new User(null, $this->data));
+               }
+               
                return $this->userProfile;
        }
        
index 7e56d80c5c9594aeae25791466b60b6354ff4407..d565c984686bef5c09cefb48649ad768132e044a 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\data\comment\response;
+use wcf\data\user\User;
 use wcf\data\user\UserProfile;
 use wcf\data\DatabaseObjectDecorator;
 
@@ -52,6 +53,10 @@ class StructuredCommentResponse extends DatabaseObjectDecorator {
         * @return      wcf\data\user\UserProfile
         */
        public function getUserProfile() {
+               if ($this->userProfile === null) {
+                       $this->userProfile = new UserProfile(new User(null, $this->data));
+               }
+               
                return $this->userProfile;
        }