mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Automatically refresh room list in room selector
This commit is contained in:
parent
1f533e255f
commit
2e0651ddd8
@ -323,27 +323,28 @@ public function removeDeadUsers() {
|
||||
/**
|
||||
* Validates permissions.
|
||||
*/
|
||||
public function validateGetDashboardRoomList() {
|
||||
public function validateGetBoxRoomList() {
|
||||
if (!MODULE_CHAT) throw new \wcf\system\exception\IllegalLinkException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns dashboard roomlist.
|
||||
*/
|
||||
public function getDashboardRoomList() {
|
||||
public function getBoxRoomList() {
|
||||
$rooms = RoomCache::getInstance()->getRooms();
|
||||
|
||||
foreach ($rooms as $key => $room) {
|
||||
if (!$room->canEnter()) unset($rooms[$key]);
|
||||
}
|
||||
|
||||
$this->readBoolean('showEmptyRooms', true);
|
||||
\wcf\system\WCF::getTPL()->assign(array(
|
||||
'rooms' => $rooms,
|
||||
'onlyList' => true
|
||||
'showEmptyRooms' => $this->parameters['showEmptyRooms']
|
||||
));
|
||||
|
||||
return array(
|
||||
'template' => \wcf\system\WCF::getTPL()->fetch('dashboardBoxOnlineList', 'chat')
|
||||
'template' => \wcf\system\WCF::getTPL()->fetch('boxRoomList', 'chat')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
22
template/boxRoomList.tpl
Normal file
22
template/boxRoomList.tpl
Normal file
@ -0,0 +1,22 @@
|
||||
{foreach from=$rooms item='room'}
|
||||
{assign var='users' value=$room->getUsers()}
|
||||
|
||||
{if $showEmptyRooms || $users|count > 0}
|
||||
<li>
|
||||
<div>
|
||||
<div>
|
||||
<div class="containerHeadline">
|
||||
<h3><a href="{link application='chat' controller='Chat' object=$room}{/link}">{$room}</a> <span class="badge">{#$users|count}</span></h3>
|
||||
<p>{$room->topic|language}</p>
|
||||
</div>
|
||||
|
||||
<ul class="dataList">
|
||||
{foreach from=$users item='user'}
|
||||
<li><a href="{link controller='User' object=$user}{/link}" class="userLink" data-user-id="{$user->userID}">{$user}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{/if}
|
||||
{/foreach}
|
@ -161,29 +161,33 @@
|
||||
<h1>{lang}chat.general.title{/lang}</h1>
|
||||
</header>
|
||||
|
||||
<div class="container marginTop">
|
||||
<div id="chatRoomListContainer" class="container marginTop">
|
||||
<ul class="containerList">
|
||||
{foreach from=$rooms item='room'}
|
||||
{assign var='users' value=$room->getUsers()}
|
||||
|
||||
<li>
|
||||
<div>
|
||||
<div>
|
||||
<div class="containerHeadline">
|
||||
<h3><a href="{link application='chat' controller='Chat' object=$room}{/link}">{$room}</a> <span class="badge">{#$users|count}</span></h3>
|
||||
<p>{$room->topic|language}</p>
|
||||
</div>
|
||||
|
||||
<ul class="dataList">
|
||||
{foreach from=$users item='user'}
|
||||
<li><a href="{link controller='User' object=$user}{/link}" class="userLink" data-user-id="{$user->userID}">{$user}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{/foreach}
|
||||
{include application='chat' file='boxRoomList' showEmptyRooms=true}
|
||||
</ul>
|
||||
<script data-relocate="true">
|
||||
//<![CDATA[
|
||||
(function($, window, undefined) {
|
||||
proxy = new WCF.Action.Proxy({
|
||||
data: {
|
||||
actionName: 'getBoxRoomList',
|
||||
className: 'chat\\data\\room\\RoomAction',
|
||||
parameters: {
|
||||
showEmptyRooms: 1
|
||||
}
|
||||
},
|
||||
showLoadingOverlay: false,
|
||||
suppressErrors: true,
|
||||
success: function(data) {
|
||||
$('#chatRoomListContainer ul').html(data.returnValues.template);
|
||||
}
|
||||
});
|
||||
|
||||
be.bastelstu.wcf.nodePush.onMessage('be.bastelstu.chat.join', $.proxy(proxy.sendRequest, proxy));
|
||||
be.bastelstu.wcf.nodePush.onMessage('be.bastelstu.chat.leave', $.proxy(proxy.sendRequest, proxy));
|
||||
})(jQuery, this);
|
||||
//]]>
|
||||
</script>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
@ -1,31 +1,6 @@
|
||||
{capture assign='roomList'}
|
||||
{foreach from=$rooms item='room'}
|
||||
{assign var='users' value=$room->getUsers()}
|
||||
{capture assign='roomList'}{include application='chat' file='boxRoomList' showEmptyRooms=false}{/capture}
|
||||
|
||||
{if $users|count > 0}
|
||||
<li>
|
||||
<div>
|
||||
<div>
|
||||
<div class="containerHeadline">
|
||||
<h3><a href="{link application='chat' controller='Chat' object=$room}{/link}">{$room}</a> <span class="badge">{#$users|count}</span></h3>
|
||||
<p>{$room->topic|language}</p>
|
||||
</div>
|
||||
|
||||
<ul class="dataList">
|
||||
{foreach from=$users item='user'}
|
||||
<li><a href="{link controller='User' object=$user}{/link}" class="userLink" data-user-id="{$user->userID}">{$user}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/capture}
|
||||
{if $onlyList|isset}
|
||||
{@$roomList}
|
||||
{else}
|
||||
<div id="chatDashboardBoxOnlineListContainer" {if !$roomList|trim} style="display: none;"{/if}>
|
||||
<div id="chatDashboardBoxOnlineListContainer"{if !$roomList|trim} style="display: none;"{/if}>
|
||||
<header class="boxHeadline boxSubHeadline">
|
||||
<h2>{lang}chat.header.menu.chat{/lang}</h2>
|
||||
</header>
|
||||
@ -40,8 +15,11 @@
|
||||
(function($, window, undefined) {
|
||||
proxy = new WCF.Action.Proxy({
|
||||
data: {
|
||||
actionName: 'getDashboardRoomList',
|
||||
className: 'chat\\data\\room\\RoomAction'
|
||||
actionName: 'getBoxRoomList',
|
||||
className: 'chat\\data\\room\\RoomAction',
|
||||
parameters: {
|
||||
showEmptyRooms: 0
|
||||
}
|
||||
},
|
||||
showLoadingOverlay: false,
|
||||
suppressErrors: true,
|
||||
@ -58,5 +36,4 @@
|
||||
})(jQuery, this);
|
||||
//]]>
|
||||
</script>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user