1
0
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:
Tim Düsterhus 2013-04-26 20:47:40 +02:00
parent 32e979c7c5
commit 140366f387
3 changed files with 61 additions and 55 deletions

View File

@ -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;

View File

@ -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');
}
}
}

View File

@ -1,11 +1,13 @@
<header class="boxHeadline boxSubHeadline">
{hascontent}
<header class="boxHeadline boxSubHeadline">
<hgroup>
<h1>{lang}chat.header.menu.chat{/lang}</h1>
</hgroup>
</header>
</header>
<div class="container marginTop">
<div class="container marginTop">
<ul class="containerList">
{content}
{foreach from=$rooms item='room'}
{assign var='users' value=$room->getUsers()}
@ -17,13 +19,18 @@
<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}
{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>
</div>
{/hascontent}