From bcffecd5259941f5f03731eb6de89ed83e8b30fa Mon Sep 17 00:00:00 2001 From: Wruczek Date: Thu, 30 Jun 2016 04:20:51 +0200 Subject: [PATCH] Improvements for adminlist - Added group icons - Added empty group text - Made adminlist sortable through config - Code has been optimised --- config/config.template.php | 2 +- css/style.css | 2 ++ include/adminlist.php | 54 +++++++++++++++++++++++++++++--------- include/footer.php | 2 +- include/modulecheck.php | 2 +- 5 files changed, 46 insertions(+), 16 deletions(-) diff --git a/config/config.template.php b/config/config.template.php index 50a41ce..c640a20 100644 --- a/config/config.template.php +++ b/config/config.template.php @@ -47,5 +47,5 @@ $config["navlinks"] = array( /************* Konfiguracja listy administratorow *************/ -// ID grup wyświetlanych na liście administracji +// ID grup wyświetlanych na liście administracji. Kolejność grup decyduje o kolejności wyświetlania na stronie $config["adminlist"] = array(6, 17, 19); diff --git a/css/style.css b/css/style.css index ad31e97..0115749 100644 --- a/css/style.css +++ b/css/style.css @@ -27,6 +27,7 @@ a { float: right } + /* ****** */ /* STATUS */ /* ****** */ @@ -43,6 +44,7 @@ a { float: right } + /* ********* */ /* ADMINLIST */ /* ********* */ diff --git a/include/adminlist.php b/include/adminlist.php index 8ee636d..047fb87 100644 --- a/include/adminlist.php +++ b/include/adminlist.php @@ -20,24 +20,51 @@ if (is_null($adminlist)) { $cache->set('adminlist', $adminlist, 30); } + // FUNCTIONS function getAdminList() { + global $config; + + $admingroups = $config["adminlist"]; + $localIcons = array(100, 200, 300, 400, 500, 600); try { $tsAdmin = TeamSpeak3::factory(getTeamspeakURI(). "#no_query_clients"); - $serverGroupList = $tsAdmin->serverGroupList(); $output = ""; - foreach ($serverGroupList as $group) { + foreach ($admingroups as $group) { - if(!isAdminGroup($group->getId())) + if(!array_key_exists((string) $group, $tsAdmin->serverGroupList())) continue; - $output .= "

$group

"; + $group = $tsAdmin->serverGroupGetById($group); - foreach ($group->clientList() as $userInfo) { + $icon = ''; + + if($group["iconid"]) { + if(!$group->iconIsLocal("iconid")) { + $groupicon = getGroupIcon($tsAdmin, $group); + + if($groupicon) { + $icon = ' '; + } + } elseif(in_array($group["iconid"], $localIcons)) { + $icon = ' '; + } + } + + $output .= "

$icon$group

"; + + $clients = $group->clientList(); + + if(empty($clients)) { + $output .= '

Ta grupa jest pusta

'; + continue; + } + + foreach ($clients as $userInfo) { $user = getClientByDbid($tsAdmin, $userInfo['cldbid']); if(!$user) { @@ -45,7 +72,7 @@ function getAdminList() { continue; } - $output .= '

' . '' . '' . $user . '' . ($user['client_away'] ? 'Away' : 'Online') . '

'; + $output .= '

' . '' . $user . '' . ($user['client_away'] ? 'Away' : 'Online') . '

'; } } @@ -56,13 +83,6 @@ function getAdminList() { } -function isAdminGroup($groupid) { - global $config; - $admingroups = $config["adminlist"]; - - return in_array($groupid, $admingroups); -} - function getClientByDbid($tsAdmin, $cldbid) { try { return $tsAdmin->clientGetByDbid($cldbid); @@ -71,4 +91,12 @@ function getClientByDbid($tsAdmin, $cldbid) { } } +function getGroupIcon($tsAdmin, $group) { + try { + return $group->iconDownload(); + } catch(TeamSpeak3_Exception $e) { + return false; + } +} + // echo getAdminList(); diff --git a/include/footer.php b/include/footer.php index 14d383f..7d256ae 100644 --- a/include/footer.php +++ b/include/footer.php @@ -7,7 +7,7 @@

© 2016

diff --git a/include/modulecheck.php b/include/modulecheck.php index 1f94640..1cbeda6 100644 --- a/include/modulecheck.php +++ b/include/modulecheck.php @@ -84,7 +84,7 @@ function showError($title, $text) { ?>