From 2e0651ddd8d2ae27e507febef3446d34e6313d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 27 Feb 2014 19:49:01 +0100 Subject: [PATCH] Automatically refresh room list in room selector --- file/lib/data/room/RoomAction.class.php | 9 ++- template/boxRoomList.tpl | 22 ++++++ template/chat.tpl | 46 ++++++------ template/dashboardBoxOnlineList.tpl | 97 ++++++++++--------------- 4 files changed, 89 insertions(+), 85 deletions(-) create mode 100644 template/boxRoomList.tpl diff --git a/file/lib/data/room/RoomAction.class.php b/file/lib/data/room/RoomAction.class.php index 17cb765..edf6bbb 100644 --- a/file/lib/data/room/RoomAction.class.php +++ b/file/lib/data/room/RoomAction.class.php @@ -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') ); } } diff --git a/template/boxRoomList.tpl b/template/boxRoomList.tpl new file mode 100644 index 0000000..31c6e1e --- /dev/null +++ b/template/boxRoomList.tpl @@ -0,0 +1,22 @@ +{foreach from=$rooms item='room'} + {assign var='users' value=$room->getUsers()} + + {if $showEmptyRooms || $users|count > 0} +
  • +
    +
    +
    +

    {$room} {#$users|count}

    +

    {$room->topic|language}

    +
    + +
      + {foreach from=$users item='user'} +
    • {$user}
    • + {/foreach} +
    +
    +
    +
  • + {/if} +{/foreach} diff --git a/template/chat.tpl b/template/chat.tpl index cfec043..1698b2e 100644 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -161,29 +161,33 @@

    {lang}chat.general.title{/lang}

    -
    +
      - {foreach from=$rooms item='room'} - {assign var='users' value=$room->getUsers()} - -
    • -
      -
      -
      -

      {$room} {#$users|count}

      -

      {$room->topic|language}

      -
      - -
        - {foreach from=$users item='user'} -
      • {$user}
      • - {/foreach} -
      -
      -
      -
    • - {/foreach} + {include application='chat' file='boxRoomList' showEmptyRooms=true}
    +
    {/if} diff --git a/template/dashboardBoxOnlineList.tpl b/template/dashboardBoxOnlineList.tpl index f3f1ada..bdd02a6 100644 --- a/template/dashboardBoxOnlineList.tpl +++ b/template/dashboardBoxOnlineList.tpl @@ -1,62 +1,39 @@ -{capture assign='roomList'} - {foreach from=$rooms item='room'} - {assign var='users' value=$room->getUsers()} - - {if $users|count > 0} -
  • -
    -
    -
    -

    {$room} {#$users|count}

    -

    {$room->topic|language}

    -
    - -
      - {foreach from=$users item='user'} -
    • {$user}
    • - {/foreach} -
    -
    -
    -
  • - {/if} - {/foreach} -{/capture} -{if $onlyList|isset} - {@$roomList} -{else} -