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:
parent
8b878f2f3c
commit
dce1f64d94
@ -49,6 +49,7 @@ Instances of `WCF.Template`
|
|||||||
|
|
||||||
titleTemplate: null
|
titleTemplate: null
|
||||||
messageTemplate: null
|
messageTemplate: null
|
||||||
|
userTemplate: null
|
||||||
|
|
||||||
Attributes needed for notificationss
|
Attributes needed for notificationss
|
||||||
|
|
||||||
@ -86,10 +87,10 @@ Every `WCF.PeriodicalExecuter` used by the chat to allow access for 3rd party de
|
|||||||
Methods
|
Methods
|
||||||
-------
|
-------
|
||||||
|
|
||||||
**init(@config, @titleTemplate, @messageTemplate)**
|
**init(@config, @titleTemplate, @messageTemplate, @userTemplate)**
|
||||||
Constructor, binds needed events and initializes `@events` and `PeriodicalExecuter`s.
|
Constructor, binds needed events and initializes `@events` and `PeriodicalExecuter`s.
|
||||||
|
|
||||||
init: (@config, @titleTemplate, @messageTemplate) ->
|
init: (@config, @titleTemplate, @messageTemplate, @userTemplate) ->
|
||||||
console.log 'Initializing'
|
console.log 'Initializing'
|
||||||
|
|
||||||
Bind events and initialize our own event system.
|
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.attr 'title', user.awayStatus
|
||||||
li.data 'username', user.username
|
li.data 'username', user.username
|
||||||
|
|
||||||
a = $ '<a>' + WCF.String.escapeHTML(user.username) + '</a>'
|
li.append @userTemplate.fetch
|
||||||
a.addClass 'userLink'
|
user: user
|
||||||
a.addClass 'dropdownToggle'
|
|
||||||
a.data 'userID', user.userID
|
|
||||||
a.data 'toggle', id
|
|
||||||
|
|
||||||
li.append a
|
|
||||||
|
|
||||||
menu = $ '<ul></ul>'
|
menu = $ '<ul></ul>'
|
||||||
menu.addClass 'dropdownMenu'
|
menu.addClass 'dropdownMenu'
|
||||||
|
@ -137,7 +137,7 @@ public function getTitle() {
|
|||||||
/**
|
/**
|
||||||
* Returns the users that are currently active in this room.
|
* Returns the users that are currently active in this room.
|
||||||
*
|
*
|
||||||
* @return array<\wcf\data\user\User>
|
* @return \wcf\data\user\UserList
|
||||||
*/
|
*/
|
||||||
public function getUsers() {
|
public function getUsers() {
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
@ -152,27 +152,11 @@ public function getUsers() {
|
|||||||
$userIDs = array();
|
$userIDs = array();
|
||||||
while ($userID = $stmt->fetchColumn()) $userIDs[] = $userID;
|
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
|
return $userList;
|
||||||
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');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,12 +140,21 @@ public function show() {
|
|||||||
foreach ($this->messages as $message) {
|
foreach ($this->messages as $message) {
|
||||||
$json['messages'][] = $message->jsonify(true);
|
$json['messages'][] = $message->jsonify(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\wcf\system\user\storage\UserStorageHandler::getInstance()->loadStorage(array_keys($this->users->getObjects()));
|
||||||
|
|
||||||
foreach ($this->users as $user) {
|
foreach ($this->users as $user) {
|
||||||
$json['users'][] = array(
|
$json['users'][] = array(
|
||||||
'userID' => (int) $user->userID,
|
'userID' => (int) $user->userID,
|
||||||
'username' => $user->username,
|
'username' => $user->username,
|
||||||
'awayStatus' => $user->awayStatus,
|
'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)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
{if MODULE_SMILEY}WCF.TabMenu.init();{/if}
|
{if MODULE_SMILEY}WCF.TabMenu.init();{/if}
|
||||||
new WCF.Message.Smilies();
|
new WCF.Message.Smilies();
|
||||||
{capture assign='messageTemplate'}{include application='chat' file='message'}{/capture}
|
{capture assign='messageTemplate'}{include application='chat' file='message'}{/capture}
|
||||||
|
{capture assign='userTemplate'}{include application='chat' file='userListUser'}{/capture}
|
||||||
|
|
||||||
window.chat = new be.bastelstu.Chat(
|
window.chat = new be.bastelstu.Chat(
|
||||||
{
|
{
|
||||||
@ -32,7 +33,8 @@
|
|||||||
socketIOPath: '{@CHAT_SOCKET_IO_PATH|encodeJS}'
|
socketIOPath: '{@CHAT_SOCKET_IO_PATH|encodeJS}'
|
||||||
},
|
},
|
||||||
new WCF.Template('{ldelim}$title} - {'chat.general.title'|language|encodeJS} - {PAGE_TITLE|language|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'}
|
{event name='afterInit'}
|
||||||
|
1
template/userListUser.tpl
Normal file
1
template/userListUser.tpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{literal}<a class="dropdownToggle userLink" data-user-id="{$user.userID.toString()}">{@$user.avatar['24']} {$user.username}</a>{/literal}
|
Loading…
Reference in New Issue
Block a user