From: Marcel Werk Date: Tue, 24 May 2016 14:24:33 +0000 (+0200) Subject: Overhauled conversation drop down X-Git-Tag: 3.0.0_Beta_1~95 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=df3404c7173dc5984be7f0c3174bac4e40ef8e2c;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.conversation.git Overhauled conversation drop down --- diff --git a/files/lib/data/conversation/ConversationAction.class.php b/files/lib/data/conversation/ConversationAction.class.php index 648a782..3bb08d4 100644 --- a/files/lib/data/conversation/ConversationAction.class.php +++ b/files/lib/data/conversation/ConversationAction.class.php @@ -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'; diff --git a/files/lib/data/conversation/ViewableConversation.class.php b/files/lib/data/conversation/ViewableConversation.class.php index 8cdc081..a5fc765 100644 --- a/files/lib/data/conversation/ViewableConversation.class.php +++ b/files/lib/data/conversation/ViewableConversation.class.php @@ -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. * diff --git a/files/style/conversation.scss b/files/style/conversation.scss index c3610bf..4cf0e8e 100644 --- a/files/style/conversation.scss +++ b/files/style/conversation.scss @@ -45,3 +45,16 @@ } } +.conversationItem { + .conversationInfo { + display: flex; + } + + .conversationParticipant { + flex: 1 1 auto; + } + .conversationLastPostTime { + flex: 0 0 auto; + margin-left: 10px; + } +} diff --git a/templates/conversationListUserPanel.tpl b/templates/conversationListUserPanel.tpl index d7b0821..0badff9 100644 --- a/templates/conversationListUserPanel.tpl +++ b/templates/conversationListUserPanel.tpl @@ -2,15 +2,35 @@
  • - {if $conversation->lastPosterID} - {@$conversation->getLastPosterProfile()->getAvatar()->getImageTag(48)} + {if $conversation->userID == $__wcf->user->userID} + {if $conversation->participants > 1} + + {else} + {@$conversation->getOtherParticipantProfile()->getAvatar()->getImageTag(48)} + {/if} {else} {@$conversation->getUserProfile()->getAvatar()->getImageTag(48)} {/if}

    {$conversation->subject}

    - {if $conversation->lastPosterID}{$conversation->lastPoster}{else}{$conversation->username}{/if} {@$conversation->lastPostTime|time} + + + {if $conversation->userID == $__wcf->user->userID} + {if $conversation->participants > 1} + {assign var='participantSummaryCount' value=$conversation->getParticipantSummary()|count} + {implode from=$conversation->getParticipantSummary() item=participant}{$participant->username}{/implode} + {if $participantSummaryCount < $conversation->participants}{lang}wcf.conversation.participants.other{/lang}{/if} + {else} + {if $conversation->getOtherParticipantProfile()->userID}{$conversation->getOtherParticipantProfile()->username}{else}{$conversation->getOtherParticipantProfile()->username}{/if} + {/if} + {else} + {if $conversation->userID}{$conversation->username}{else}{$conversation->username}{/if} + {/if} + + + {@$conversation->lastPostTime|time} +