Showing deleted participants
authorAlexander Ebert <ebert@woltlab.com>
Mon, 8 Jul 2013 14:34:24 +0000 (16:34 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 8 Jul 2013 14:34:24 +0000 (16:34 +0200)
files/lib/data/conversation/ConversationParticipantList.class.php
templates/conversation.tpl

index 71adef734a558861011ec7dafcc1a74a89b70b66..6d22854132e430a2517fd658214d1e6d6733b907 100644 (file)
@@ -1,5 +1,7 @@
 <?php 
 namespace wcf\data\conversation;
+use wcf\data\user\User;
+use wcf\data\user\UserProfile;
 use wcf\data\user\UserProfileList;
 use wcf\system\WCF;
 
@@ -7,13 +9,19 @@ use wcf\system\WCF;
  * Represents a list of conversation participants.
  * 
  * @author     Marcel Werk
- * @copyright  2001-2012 WoltLab GmbH
+ * @copyright  2001-2013 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf.conversation
  * @subpackage data.conversation
  * @category   Community Framework
  */
 class ConversationParticipantList extends UserProfileList {
+       /**
+        * conversation id
+        * @var integer
+        */
+       public $conversationID = 0;
+       
        /**
         * @see wcf\data\DatabaseObjectList::$sqlLimit
         */
@@ -28,6 +36,7 @@ class ConversationParticipantList extends UserProfileList {
        public function __construct($conversationID, $userID = 0, $isAuthor = false) {
                parent::__construct();
                
+               $this->conversationID = $conversationID;
                $this->getConditionBuilder()->add('conversation_to_user.conversationID = ?', array($conversationID));
                if (!$isAuthor) {
                        if ($userID) {
@@ -74,4 +83,26 @@ class ConversationParticipantList extends UserProfileList {
                        $this->objectIDs[] = $row['objectID'];
                }
        }
+       
+       /**
+        * @see wcf\data\user\UserProfileList::readObjects()
+        */
+       public function readObjects() {
+               parent::readObjects();
+               
+               // check for deleted users
+               $sql = "SELECT  username
+                       FROM    wcf".WCF_N."_conversation_to_user
+                       WHERE   conversationID = ?
+                               AND participantID IS NULL";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->conversationID));
+               $i = 0;
+               while ($row = $statement->fetchArray()) {
+                       // create fake user profiles
+                       $user = new User(null, array('userID' => 0, 'username' => $row['username']));
+                       $this->objects['x'.++$i] = new UserProfile($user);
+                       $this->indexToObject[] = 'x'.$i;
+               }
+       }
 }
index 5dc52af944d527671316d60a93de7033a69ba798..4a22864d48ea92743acf3d63c8254e240a48245e 100644 (file)
                                {foreach from=$participants item=participant}
                                        <li class="jsParticipant{if $participant->hideConversation == 2} conversationLeft{/if}">
                                                <div class="box24">
-                                                       <a href="{link controller='User' object=$participant}{/link}" class="framed">{@$participant->getAvatar()->getImageTag(24)}</a>
+                                                       {if $participant->userID}<a href="{link controller='User' object=$participant}{/link}" class="framed">{@$participant->getAvatar()->getImageTag(24)}</a>{else}<span class="framed">{@$participant->getAvatar()->getImageTag(24)}</span>{/if}
                                                        <div>
                                                                <p>
-                                                                       <a href="{link controller='User' object=$participant}{/link}" class="userLink" data-user-id="{@$participant->userID}">{$participant->username}</a>
+                                                                       {if $participant->userID}<a href="{link controller='User' object=$participant}{/link}" class="userLink" data-user-id="{@$participant->userID}">{$participant->username}</a>{else}{$participant->username}{/if}
                                                                        {if $participant->isInvisible}<small>({lang}wcf.conversation.invisible{/lang})</small>{/if}
-                                                                       {if ($conversation->userID == $__wcf->getUser()->userID) && ($participant->userID != $__wcf->getUser()->userID) && $participant->hideConversation != 2}
+                                                                       {if $participant->userID && ($conversation->userID == $__wcf->getUser()->userID) && ($participant->userID != $__wcf->getUser()->userID) && $participant->hideConversation != 2}
                                                                                <a class="jsDeleteButton jsTooltip jsOnly" title="{lang}wcf.conversation.participants.removeParticipant{/lang}" data-confirm-message="{lang}wcf.conversation.participants.removeParticipant.confirmMessage{/lang}" data-object-id="{@$participant->userID}"><span class="icon icon16 icon-remove"></span></a>
                                                                        {/if}
                                                                </p>