Improvements for adminlist
- Added group icons - Added empty group text - Made adminlist sortable through config - Code has been optimised
This commit is contained in:
parent
0f7146bb09
commit
bcffecd525
|
@ -47,5 +47,5 @@ $config["navlinks"] = array(
|
||||||
|
|
||||||
/************* Konfiguracja listy administratorow *************/
|
/************* 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);
|
$config["adminlist"] = array(6, 17, 19);
|
||||||
|
|
|
@ -27,6 +27,7 @@ a {
|
||||||
float: right
|
float: right
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ****** */
|
/* ****** */
|
||||||
/* STATUS */
|
/* STATUS */
|
||||||
/* ****** */
|
/* ****** */
|
||||||
|
@ -43,6 +44,7 @@ a {
|
||||||
float: right
|
float: right
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ********* */
|
/* ********* */
|
||||||
/* ADMINLIST */
|
/* ADMINLIST */
|
||||||
/* ********* */
|
/* ********* */
|
||||||
|
|
|
@ -20,24 +20,51 @@ if (is_null($adminlist)) {
|
||||||
$cache->set('adminlist', $adminlist, 30);
|
$cache->set('adminlist', $adminlist, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
|
|
||||||
function getAdminList() {
|
function getAdminList() {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$admingroups = $config["adminlist"];
|
||||||
|
$localIcons = array(100, 200, 300, 400, 500, 600);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$tsAdmin = TeamSpeak3::factory(getTeamspeakURI(). "#no_query_clients");
|
$tsAdmin = TeamSpeak3::factory(getTeamspeakURI(). "#no_query_clients");
|
||||||
$serverGroupList = $tsAdmin->serverGroupList();
|
|
||||||
|
|
||||||
$output = "";
|
$output = "";
|
||||||
|
|
||||||
foreach ($serverGroupList as $group) {
|
foreach ($admingroups as $group) {
|
||||||
|
|
||||||
if(!isAdminGroup($group->getId()))
|
if(!array_key_exists((string) $group, $tsAdmin->serverGroupList()))
|
||||||
continue;
|
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']);
|
$user = getClientByDbid($tsAdmin, $userInfo['cldbid']);
|
||||||
|
|
||||||
if(!$user) {
|
if(!$user) {
|
||||||
|
@ -45,7 +72,7 @@ function getAdminList() {
|
||||||
continue;
|
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) {
|
function getClientByDbid($tsAdmin, $cldbid) {
|
||||||
try {
|
try {
|
||||||
return $tsAdmin->clientGetByDbid($cldbid);
|
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();
|
// echo getAdminList();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<p class="pull-left">© <?php echo $config["general"]["title"]; ?> 2016</p>
|
<p class="pull-left">© <?php echo $config["general"]["title"]; ?> 2016</p>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<ul class="list-inline">
|
<ul class="list-inline">
|
||||||
<li>Strona © <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 © <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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -84,7 +84,7 @@ function showError($title, $text) { ?>
|
||||||
<?php echo $text; ?>
|
<?php echo $text; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
Strona © <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 © <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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue