$('<li><a href="' + this._addLink + '">' + WCF.Language.get('wcf.conversation.add') + '</a></li>').appendTo(dropdownMenu);
},
+ /**
+ * @see WCF.UserPanel._after()
+ */
+ _after: function(dropdownMenu) {
+ var $items = dropdownMenu.children('.conversationItemUnread');
+ if ($items.length) {
+ var $item = $items.last();
+ if ($item.next('.conversationItem').length) {
+ $('<li class="dropdownDivider" />').insertAfter($item);
+ }
+ }
+ },
+
/**
* @see WCF.UserPanel._getParameters()
*/
_getParameters: function() {
return {
- actionName: 'getUnreadConversations',
+ actionName: 'getMixedConversationList',
className: 'wcf\\data\\conversation\\ConversationAction'
};
}
}
/**
- * Validates the 'getUnreadConversations' action.
+ * Validates parameters to return the mixed conversation list.
*/
- public function validateGetUnreadConversations() {
+ public function validateGetMixedConversationList() {
// does nothing
}
/**
- * Returns the last 5 unread conversations.
+ * Returns a mixed conversation list with up to 5 unread conversations.
*
- * @return array
+ * @return array<mixed>
*/
- public function getUnreadConversations() {
- $conversationList = new UserConversationList(WCF::getUser()->userID);
- $conversationList->getConditionBuilder()->add('conversation_to_user.lastVisitTime < conversation.lastPostTime');
- $conversationList->sqlLimit = 5;
- $conversationList->sqlOrderBy = 'conversation.lastPostTime DESC';
- $conversationList->readObjects();
+ public function getMixedConversationList() {
+ $unreadConversationList = new UserConversationList(WCF::getUser()->userID);
+ $unreadConversationList->getConditionBuilder()->add('conversation_to_user.lastVisitTime < conversation.lastPostTime');
+ $unreadConversationList->sqlLimit = 5;
+ $unreadConversationList->sqlOrderBy = 'conversation.lastPostTime DESC';
+ $unreadConversationList->readObjects();
+
+ $conversations = array();
+ $count = 0;
+ foreach ($unreadConversationList as $conversation) {
+ $conversations[] = $conversation;
+ $count++;
+ }
+
+ if ($count < 5) {
+ $conversationList = new UserConversationList(WCF::getUser()->userID);
+ $conversationList->getConditionBuilder()->add('conversation_to_user.lastVisitTime >= conversation.lastPostTime');
+ $conversationList->sqlLimit = (5 - $count);
+ $conversationList->sqlOrderBy = 'conversation.lastPostTime DESC';
+ $conversationList->readObjects();
+
+ foreach ($conversationList as $conversation) {
+ $conversations[] = $conversation;
+ }
+ }
WCF::getTPL()->assign(array(
- 'conversations' => $conversationList->getObjects()
+ 'conversations' => $conversations
));
$totalCount = ConversationHandler::getInstance()->getUnreadConversationCount();
- if (count($conversationList) < $totalCount) {
+ if ($count < 5 && $count < $totalCount) {
UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'unreadConversationCount');
}
{foreach from=$conversations item=conversation}
- <li>
+ <li class="conversationItem{if $conversation->lastVisitTime < $conversation->lastPostTime} conversationItemUnread{/if}">
<a href="{link controller='Conversation' object=$conversation}action=firstNew{/link}" class="box24">
<div class="framed">
{if $conversation->lastPosterID}
{/if}
</div>
<div>
- <h3>{$conversation->subject}</h3>
+ <h3>{if $conversation->lastVisitTime < $conversation->lastPostTime}<span class="badge label newContentBadge">{lang}wcf.message.new{/lang}</span> {/if}{$conversation->subject}</h3>
<small>{if $conversation->lastPosterID}{$conversation->lastPoster}{else}{$conversation->username}{/if} - {@$conversation->lastPostTime|time}</small>
</div>
</a>