Overhauled conversation drop down
authorMarcel Werk <burntime@woltlab.com>
Tue, 24 May 2016 14:24:33 +0000 (16:24 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 24 May 2016 14:24:33 +0000 (16:24 +0200)
files/lib/data/conversation/ConversationAction.class.php
files/lib/data/conversation/ViewableConversation.class.php
files/style/conversation.scss
templates/conversationListUserPanel.tpl

index 648a7821633820e25a7113858556c5b32726c9c7..3bb08d4e63aad801c3b3da197ca51fc52bf8725c 100644 (file)
@@ -633,7 +633,11 @@ class ConversationAction extends AbstractDatabaseObjectAction implements IClipbo
         * @return      mixed[][]
         */
        public function getMixedConversationList() {
+               $sqlSelect = '  , (SELECT participantID FROM wcf'.WCF_N.'_conversation_to_user WHERE conversationID = conversation.conversationID AND participantID <> conversation.userID AND isInvisible = 0 ORDER BY username, participantID LIMIT 1) AS otherParticipantID
+                               , (SELECT username FROM wcf'.WCF_N.'_conversation_to_user WHERE conversationID = conversation.conversationID AND participantID <> conversation.userID AND isInvisible = 0 ORDER BY username, participantID LIMIT 1) AS otherParticipant';
+               
                $unreadConversationList = new UserConversationList(WCF::getUser()->userID);
+               $unreadConversationList->sqlSelects .= $sqlSelect;
                $unreadConversationList->getConditionBuilder()->add('conversation_to_user.lastVisitTime < conversation.lastPostTime');
                $unreadConversationList->sqlLimit = 10;
                $unreadConversationList->sqlOrderBy = 'conversation.lastPostTime DESC';
@@ -648,6 +652,7 @@ class ConversationAction extends AbstractDatabaseObjectAction implements IClipbo
                
                if ($count < 10) {
                        $conversationList = new UserConversationList(WCF::getUser()->userID);
+                       $conversationList->sqlSelects .= $sqlSelect;
                        $conversationList->getConditionBuilder()->add('conversation_to_user.lastVisitTime >= conversation.lastPostTime');
                        $conversationList->sqlLimit = (10 - $count);
                        $conversationList->sqlOrderBy = 'conversation.lastPostTime DESC';
index 8cdc081a4c1c2c54ef16a2f70d80892134b71b61..a5fc7659988955b92ddd6f9e88f2bfd9aa20cfeb 100644 (file)
@@ -30,19 +30,25 @@ class ViewableConversation extends DatabaseObjectDecorator {
         * participant summary
         * @var string
         */
-       protected $__participantSummary = null;
+       protected $__participantSummary;
        
        /**
         * user profile object
         * @var UserProfile
         */
-       protected $userProfile = null;
+       protected $userProfile;
        
        /**
         * last poster's profile
         * @var UserProfile
         */
-       protected $lastPosterProfile = null;
+       protected $lastPosterProfile;
+       
+       /**
+        * other participant's profile
+        * @var UserProfile
+        */
+       protected $otherParticipantProfile;
        
        /**
         * list of assigned labels
@@ -178,6 +184,24 @@ class ViewableConversation extends DatabaseObjectDecorator {
                return $this->__participantSummary;
        }
        
+       /**
+        * Returns the other participant's profile object.
+        *
+        * @return      UserProfile
+        */
+       public function getOtherParticipantProfile() {
+               if ($this->otherParticipantProfile === null) {
+                       if ($this->otherParticipantID) {
+                               $this->otherParticipantProfile = UserProfileRuntimeCache::getInstance()->getObject($this->otherParticipantID);
+                       }
+                       else {
+                               $this->otherParticipantProfile = UserProfile::getGuestUserProfile($this->otherParticipant);
+                       }
+               }
+               
+               return $this->otherParticipantProfile;
+       }
+       
        /**
         * Assigns a label.
         * 
index c3610bf2030e24f7abe7bf5ab607bb4cb1a96816..4cf0e8e01aa6e14e64c3e2a7552e3885813e3828 100644 (file)
        }
 }
 
+.conversationItem {
+       .conversationInfo {
+               display: flex;
+       }
+       
+       .conversationParticipant {
+               flex: 1 1 auto;
+       }
+       .conversationLastPostTime {
+               flex: 0 0 auto;
+               margin-left: 10px;
+       }
+}
index d7b0821738d8307ba3ae11754b6488f711502af9..0badff9226944a43589c68640c7b5b64da5f3123 100644 (file)
@@ -2,15 +2,35 @@
        <li class="conversationItem{if $conversation->lastVisitTime < $conversation->lastPostTime} conversationItemUnread interactiveDropdownItemOutstanding{/if}" data-link="{link controller='Conversation' object=$conversation}action=firstNew{/link}" data-object-id="{@$conversation->conversationID}" data-is-read="{if $conversation->lastVisitTime < $conversation->lastPostTime}false{else}true{/if}">
                <div class="box48">
                        <div>
-                               {if $conversation->lastPosterID}
-                                       {@$conversation->getLastPosterProfile()->getAvatar()->getImageTag(48)}
+                               {if $conversation->userID == $__wcf->user->userID}
+                                       {if $conversation->participants > 1}
+                                               <span class="icon icon48 fa-users"></span>
+                                       {else}
+                                               {@$conversation->getOtherParticipantProfile()->getAvatar()->getImageTag(48)}
+                                       {/if}   
                                {else}
                                        {@$conversation->getUserProfile()->getAvatar()->getImageTag(48)}
                                {/if}
                        </div>
                        <div>
                                <h3><a href="{link controller='Conversation' object=$conversation}action=firstNew{/link}">{$conversation->subject}</a></h3>
-                               <small>{if $conversation->lastPosterID}<a href="{link controller='User' id=$conversation->lastPosterID title=$conversation->lastPoster}{/link}">{$conversation->lastPoster}</a>{else}{$conversation->username}{/if} <span class="separatorLeft">{@$conversation->lastPostTime|time}</span></small>
+                               <small class="conversationInfo">
+                                       <span class="conversationParticipant">
+                                               {if $conversation->userID == $__wcf->user->userID}
+                                                       {if $conversation->participants > 1}
+                                                               {assign var='participantSummaryCount' value=$conversation->getParticipantSummary()|count}
+                                                               {implode from=$conversation->getParticipantSummary() item=participant}<a href="{link controller='User' object=$participant}{/link}" class="userLink{if $participant->hideConversation == 2} conversationLeft{/if}" data-user-id="{@$participant->userID}">{$participant->username}</a>{/implode}
+                                                               {if $participantSummaryCount < $conversation->participants}{lang}wcf.conversation.participants.other{/lang}{/if}
+                                                       {else}
+                                                               {if $conversation->getOtherParticipantProfile()->userID}<a href="{link controller='User' id=$conversation->getOtherParticipantProfile()->userID title=$conversation->getOtherParticipantProfile()->username}{/link}">{$conversation->getOtherParticipantProfile()->username}</a>{else}{$conversation->getOtherParticipantProfile()->username}{/if}
+                                                       {/if}
+                                               {else}
+                                                       {if $conversation->userID}<a href="{link controller='User' id=$conversation->userID title=$conversation->username}{/link}">{$conversation->username}</a>{else}{$conversation->username}{/if}
+                                               {/if}
+                                       </span>
+                                       
+                                       <span class="conversationLastPostTime">{@$conversation->lastPostTime|time}</span>
+                               </small>
                        </div>
                </div>
        </li>