From 140366f387e485abec768d3504f0da6b43e29ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 26 Apr 2013 20:47:40 +0200 Subject: [PATCH] Don't show dashboard box if all rooms are empty. --- file/lib/data/room/Room.class.php | 39 +++++------ .../box/OnlineListDashboardBox.class.php | 12 ++-- template/dashboardBoxOnlineList.tpl | 65 ++++++++++--------- 3 files changed, 61 insertions(+), 55 deletions(-) diff --git a/file/lib/data/room/Room.class.php b/file/lib/data/room/Room.class.php index 9464afa..90c926f 100644 --- a/file/lib/data/room/Room.class.php +++ b/file/lib/data/room/Room.class.php @@ -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; diff --git a/file/lib/system/dashboard/box/OnlineListDashboardBox.class.php b/file/lib/system/dashboard/box/OnlineListDashboardBox.class.php index a6c93cd..b0b9aae 100644 --- a/file/lib/system/dashboard/box/OnlineListDashboardBox.class.php +++ b/file/lib/system/dashboard/box/OnlineListDashboardBox.class.php @@ -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'); } } diff --git a/template/dashboardBoxOnlineList.tpl b/template/dashboardBoxOnlineList.tpl index d65c714..643205c 100644 --- a/template/dashboardBoxOnlineList.tpl +++ b/template/dashboardBoxOnlineList.tpl @@ -1,29 +1,36 @@ -
-
-

{lang}chat.header.menu.chat{/lang}

-
-
- -
- -
\ No newline at end of file +{hascontent} +
+
+

{lang}chat.header.menu.chat{/lang}

+
+
+ +
+ +
+{/hascontent} \ No newline at end of file