Improvements for adminlist

- Added group icons
- Added empty group text
- Made adminlist sortable through config
- Code has been optimised
pull/13/head
Wruczek 9 years ago
parent 0f7146bb09
commit bcffecd525

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

@ -27,6 +27,7 @@ a {
float: right
}
/* ****** */
/* STATUS */
/* ****** */
@ -43,6 +44,7 @@ a {
float: right
}
/* ********* */
/* ADMINLIST */
/* ********* */

@ -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 .= "<p class=\"groupname\">$group</p>";
$group = $tsAdmin->serverGroupGetById($group);
foreach ($group->clientList() as $userInfo) {
$icon = '';
if($group["iconid"]) {
if(!$group->iconIsLocal("iconid")) {
$groupicon = getGroupIcon($tsAdmin, $group);
if($groupicon) {
$icon = '<img src="data:' . TeamSpeak3_Helper_Convert::imageMimeType($groupicon) . ';base64,' . base64_encode($groupicon) . '" /> ';
}
} elseif(in_array($group["iconid"], $localIcons)) {
$icon = '<img src="lib/ts3phpframework/images/viewer/group_icon_' . $group["iconid"] . '.png" /> ';
}
}
$output .= "<p class=\"groupname\">$icon$group</p>";
$clients = $group->clientList();
if(empty($clients)) {
$output .= '<p class="text-center"><i>Ta grupa jest pusta</i></p>';
continue;
}
foreach ($clients as $userInfo) {
$user = getClientByDbid($tsAdmin, $userInfo['cldbid']);
if(!$user) {
@ -45,7 +72,7 @@ function getAdminList() {
continue;
}
$output .= '<p>' . '<img src="lib/ts3phpframework/images/viewer/' . $user->getIcon() . '.png">' . '<span class="label label-primary">' . $user . '</span>' . ($user['client_away'] ? '<span class="label label-warning pullright">Away</span>' : '<span class="label label-success pullright">Online</span>') . '</p>';
$output .= '<p><img src="lib/ts3phpframework/images/viewer/' . $user->getIcon() . '.png">' . '<span class="label label-primary">' . $user . '</span>' . ($user['client_away'] ? '<span class="label label-warning pullright">Away</span>' : '<span class="label label-success pullright">Online</span>') . '</p>';
}
}
@ -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();

@ -7,7 +7,7 @@
<p class="pull-left">&copy; <?php echo $config["general"]["title"]; ?> 2016</p>
<div class="pull-right">
<ul class="list-inline">
<li>Strona &copy; <a href="http://wruczek.top">Wruczek</a> 2016 | <a href="https://github.com/Wruczek/ts-website">ts-website</a> v 1.2.1 | MIT License</li>
<li>Strona &copy; <a href="http://wruczek.top">Wruczek</a> 2016 | <a href="https://github.com/Wruczek/ts-website">ts-website</a> v 1.2.2 | MIT License</li>
</ul>
</div>
</footer>

@ -84,7 +84,7 @@ function showError($title, $text) { ?>
<?php echo $text; ?>
</div>
<div class="panel-footer">
Strona &copy; <a href="http://wruczek.top">Wruczek</a> 2016 | <a href="https://github.com/Wruczek/ts-website">ts-website</a> v 1.2.1 | MIT License
Strona &copy; <a href="http://wruczek.top">Wruczek</a> 2016 | <a href="https://github.com/Wruczek/ts-website">ts-website</a> v 1.2.2 | MIT License
</div>
</div>

Loading…
Cancel
Save