mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Don't show dashboard box if all rooms are empty.
This commit is contained in:
parent
32e979c7c5
commit
140366f387
@ -90,25 +90,6 @@ public function canWrite(\wcf\data\user\User $user = null) {
|
||||
return $canWrite || $ph->getPermission($this, 'mod.canAlwaysWrite');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of users currently active in this room.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function countUsers() {
|
||||
$sql = "SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
wcf".WCF_N."_user_storage
|
||||
WHERE
|
||||
field = ?
|
||||
AND fieldValue = ?";
|
||||
$stmt = WCF::getDB()->prepareStatement($sql);
|
||||
$stmt->execute(array('roomID', $this->roomID));
|
||||
|
||||
return $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the room cache.
|
||||
*/
|
||||
@ -134,6 +115,25 @@ public function getTitle() {
|
||||
return \wcf\system\WCF::getLanguage()->get($this->title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of users currently active in this room.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function countUsers() {
|
||||
$sql = "SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
wcf".WCF_N."_user_storage
|
||||
WHERE
|
||||
field = ?
|
||||
AND fieldValue = ?";
|
||||
$stmt = WCF::getDB()->prepareStatement($sql);
|
||||
$stmt->execute(array('roomID', $this->roomID));
|
||||
|
||||
return $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the users that are currently active in this room.
|
||||
*
|
||||
@ -155,6 +155,7 @@ public function getUsers() {
|
||||
$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();
|
||||
|
||||
return $userList;
|
||||
|
@ -37,12 +37,10 @@ public function init(\wcf\data\dashboard\box\DashboardBox $box, \wcf\page\IPage
|
||||
* @see wcf\system\dashboard\box\AbstractContentDashboardBox::render()
|
||||
*/
|
||||
protected function render() {
|
||||
if (count($this->rooms)) {
|
||||
\wcf\system\WCF::getTPL()->assign(array(
|
||||
'rooms' => $this->rooms
|
||||
));
|
||||
|
||||
return \wcf\system\WCF::getTPL()->fetch('dashboardBoxOnlineList', 'chat');
|
||||
}
|
||||
\wcf\system\WCF::getTPL()->assign(array(
|
||||
'rooms' => $this->rooms
|
||||
));
|
||||
|
||||
return \wcf\system\WCF::getTPL()->fetch('dashboardBoxOnlineList', 'chat');
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,36 @@
|
||||
<header class="boxHeadline boxSubHeadline">
|
||||
<hgroup>
|
||||
<h1>{lang}chat.header.menu.chat{/lang}</h1>
|
||||
</hgroup>
|
||||
</header>
|
||||
|
||||
<div class="container marginTop">
|
||||
<ul class="containerList">
|
||||
{foreach from=$rooms item='room'}
|
||||
{assign var='users' value=$room->getUsers()}
|
||||
|
||||
{if $users|count > 0}
|
||||
<li>
|
||||
<div>
|
||||
<div>
|
||||
<hgroup class="containerHeadline">
|
||||
<h1><a href="{link controller='Chat' object=$room}{/link}">{$room}</a><small> - {$room->topic|language}</small></h1>
|
||||
<h2><strong>{#$users|count} Users</strong></h2>
|
||||
</hgroup>
|
||||
<ul class="dataList">
|
||||
{foreach from=$room->getUsers() 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}
|
||||
</ul>
|
||||
</div>
|
||||
{hascontent}
|
||||
<header class="boxHeadline boxSubHeadline">
|
||||
<hgroup>
|
||||
<h1>{lang}chat.header.menu.chat{/lang}</h1>
|
||||
</hgroup>
|
||||
</header>
|
||||
|
||||
<div class="container marginTop">
|
||||
<ul class="containerList">
|
||||
{content}
|
||||
{foreach from=$rooms item='room'}
|
||||
{assign var='users' value=$room->getUsers()}
|
||||
|
||||
{if $users|count > 0}
|
||||
<li>
|
||||
<div>
|
||||
<div>
|
||||
<hgroup class="containerHeadline">
|
||||
<h1><a href="{link controller='Chat' object=$room}{/link}">{$room}</a><small> - {$room->topic|language}</small></h1>
|
||||
<h2><strong>{#$users|count} Users</strong></h2>
|
||||
</hgroup>
|
||||
|
||||
<ul class="dataList">
|
||||
{foreach from=$room->getUsers() 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}
|
||||
{/content}
|
||||
</ul>
|
||||
</div>
|
||||
{/hascontent}
|
Loading…
Reference in New Issue
Block a user