1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Make avatar available in user list

This commit is contained in:
Tim Düsterhus 2013-04-21 20:21:51 +02:00
parent 8b878f2f3c
commit dce1f64d94
5 changed files with 25 additions and 33 deletions

View File

@ -49,6 +49,7 @@ Instances of `WCF.Template`
titleTemplate: null
messageTemplate: null
userTemplate: null
Attributes needed for notificationss
@ -86,10 +87,10 @@ Every `WCF.PeriodicalExecuter` used by the chat to allow access for 3rd party de
Methods
-------
**init(@config, @titleTemplate, @messageTemplate)**
**init(@config, @titleTemplate, @messageTemplate, @userTemplate)**
Constructor, binds needed events and initializes `@events` and `PeriodicalExecuter`s.
init: (@config, @titleTemplate, @messageTemplate) ->
init: (@config, @titleTemplate, @messageTemplate, @userTemplate) ->
console.log 'Initializing'
Bind events and initialize our own event system.
@ -504,13 +505,8 @@ Build HTML of new user and append it.
li.attr 'title', user.awayStatus
li.data 'username', user.username
a = $ '<a>' + WCF.String.escapeHTML(user.username) + '</a>'
a.addClass 'userLink'
a.addClass 'dropdownToggle'
a.data 'userID', user.userID
a.data 'toggle', id
li.append a
li.append @userTemplate.fetch
user: user
menu = $ '<ul></ul>'
menu.addClass 'dropdownMenu'

View File

@ -137,7 +137,7 @@ public function getTitle() {
/**
* Returns the users that are currently active in this room.
*
* @return array<\wcf\data\user\User>
* @return \wcf\data\user\UserList
*/
public function getUsers() {
$sql = "SELECT
@ -152,27 +152,11 @@ public function getUsers() {
$userIDs = array();
while ($userID = $stmt->fetchColumn()) $userIDs[] = $userID;
if (empty($userIDs)) return array();
$userList = new \wcf\data\user\UserProfileList();
if (!empty($userIDs)) $userList->getConditionBuilder()->add('user_table.userID IN (?)', array($userIDs));
else $userList->getConditionBuilder()->add('1 = 0', array());
$userList->readObjects();
$sql = "SELECT
u.*,
st.fieldValue AS awayStatus
FROM
wcf".WCF_N."_user u
LEFT JOIN
wcf".WCF_N."_user_storage st
ON (
u.userID = st.userID
AND st.field = ?
)
WHERE
u.userID IN (".rtrim(str_repeat('?,', count($userIDs)), ',').")
ORDER BY
u.username ASC";
$stmt = WCF::getDB()->prepareStatement($sql);
array_unshift($userIDs, 'away');
$stmt->execute($userIDs);
return $stmt->fetchObjects('\wcf\data\user\User');
return $userList;
}
}

View File

@ -140,12 +140,21 @@ public function show() {
foreach ($this->messages as $message) {
$json['messages'][] = $message->jsonify(true);
}
\wcf\system\user\storage\UserStorageHandler::getInstance()->loadStorage(array_keys($this->users->getObjects()));
foreach ($this->users as $user) {
$json['users'][] = array(
'userID' => (int) $user->userID,
'username' => $user->username,
'awayStatus' => $user->awayStatus,
'suspended' => (boolean) !$this->room->canWrite($user)
'suspended' => (boolean) !$this->room->canWrite($user->getDecoratedObject()),
'avatar' => array(
16 => $user->getAvatar()->getImageTag(16),
24 => $user->getAvatar()->getImageTag(24),
32 => $user->getAvatar()->getImageTag(32),
48 => $user->getAvatar()->getImageTag(48)
)
);
}

View File

@ -23,6 +23,7 @@
{if MODULE_SMILEY}WCF.TabMenu.init();{/if}
new WCF.Message.Smilies();
{capture assign='messageTemplate'}{include application='chat' file='message'}{/capture}
{capture assign='userTemplate'}{include application='chat' file='userListUser'}{/capture}
window.chat = new be.bastelstu.Chat(
{
@ -32,7 +33,8 @@
socketIOPath: '{@CHAT_SOCKET_IO_PATH|encodeJS}'
},
new WCF.Template('{ldelim}$title} - {'chat.general.title'|language|encodeJS} - {PAGE_TITLE|language|encodeJS}'),
new WCF.Template('{@$messageTemplate|encodeJS}')
new WCF.Template('{@$messageTemplate|encodeJS}'),
new WCF.Template('{@$userTemplate|encodeJS}')
);
{event name='afterInit'}

View File

@ -0,0 +1 @@
{literal}<a class="dropdownToggle userLink" data-user-id="{$user.userID.toString()}">{@$user.avatar['24']} {$user.username}</a>{/literal}