Use tabs for global settings

This commit is contained in:
Tony Murray
2016-08-20 10:16:56 -05:00
parent 7b7d7b3bfa
commit 9babc10820

View File

@@ -1,6 +1,9 @@
<?php <?php
/**
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org> * settings.inc.php
*
* Web page to display settings
*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
@@ -13,36 +16,18 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2015 Daniel Preussker <f0o@devilcode.org>
* @copyright 2016 Tony Murray <murraytony@gmail.com>
* @author f0o <f0o@devilcode.org>
*/ */
/*
* Global Settings
* @author f0o <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Page
*/
if (empty($vars['sub'])) {
$page_name = 'Global';
} else {
$page_name = ucfirst($vars['sub']);
}
$pagetitle[] = $page_name . ' Settings';
$config['memcached']['enable'] = false; $config['memcached']['enable'] = false;
?> ?>
<div class="container-fluid"> <div class="container-fluid">
<h2>
<?php
echo $pagetitle[0];
?>
</h2>
<hr>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<span id="message"></span> <span id="message"></span>
@@ -50,65 +35,74 @@ echo $pagetitle[0];
</div> </div>
</div> </div>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<?php <?php
if (is_admin() === true) { if (is_admin() === true) {
if (isset($vars['sub'])) { echo '<ul class="nav nav-tabs">';
if (file_exists("pages/settings/".mres($vars['sub']).".inc.php")) { $pages = dbFetchRows("SELECT DISTINCT `config_group` FROM `config` WHERE `config_group` IS NOT NULL AND `config_group` != ''");
require_once "pages/settings/".mres($vars['sub']).".inc.php"; array_unshift($pages, array('config_group' => 'Global')); // Add Global tab
$curr_page = isset($vars['sub']) ? $vars['sub'] : 'Global';
foreach ($pages as $sub_page) {
$sub_page = $sub_page['config_group'];
$page_name = ucfirst($sub_page) . ' Settings';
echo '<li';
if ($sub_page == $curr_page) {
echo ' class="active"';
}
echo '><a href="';
echo generate_url(array(
'page' => 'settings',
'sub' => $sub_page
));
echo '">' . $page_name . '</a></li>';
}
echo '</ul></div></div><br />';
if (isset($vars['sub']) && $vars['sub'] != 'Global') {
if (file_exists("pages/settings/" . mres($vars['sub']) . ".inc.php")) {
require_once "pages/settings/" . mres($vars['sub']) . ".inc.php";
} else { } else {
print_error("This settings page doesn't exist, please go to the main settings page"); print_error("This settings page doesn't exist, please go to the main settings page");
} }
} else { } else {
?>
<div class="container-fluid"> /**
<div class="row"> * Array-To-Table
<?php * @param array $a N-Dimensional, Associative Array
foreach (dbFetchRows("SELECT DISTINCT `config_group` FROM `config` WHERE `config_group` IS NOT NULL AND `config_group` != ''") as $sub_page) { * @return string
$sub_page = $sub_page['config_group']; */
?>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<a class="btn btn-primary" href="<?php echo(generate_url(array('page'=>'settings','sub'=>$sub_page))); ?>"><?php echo ucfirst($sub_page); ?> Settings</a>
</div>
<?php
}
?>
</div>
</div>
<br />
<?php
/** function a2t($a)
* Array-To-Table {
* @param array $a N-Dimensional, Associative Array $r = '<table class="table table-condensed table-hover"><tbody>';
* @return string foreach ($a as $k => $v) {
*/ if (!empty($v)) {
$r .= '<tr><td class="col-md-2"><i><b>' . $k . '</b></i></td><td class="col-md-10">';
$r .= is_array($v) ? a2t($v) : '<code>' . wordwrap($v, 75, '<br/>') . '</code>';
$r .= '</td></tr>';
}
}
$r .= '</tbody></table>';
return $r;
}
function a2t($a) echo '<div class="table-responsive">' . a2t($config) . '</div>';
{
$r = "<table class='table table-condensed table-hover'><tbody>"; if ($debug && $_SESSION['userlevel'] >= '10') {
foreach ($a as $k => $v) {
if (!empty($v)) { echo("<pre>");
$r .= "<tr><td class='col-md-2'><i><b>".$k."</b></i></td><td class='col-md-10'>".(is_array($v)?a2t($v):"<code>".wordwrap($v, 75, "<br/>")."</code>")."</td></tr>"; print_r($config);
echo("</pre>");
} }
} }
$r .= '</tbody></table>';
return $r;
}
echo "<div class='table-responsive'>".a2t($config)."</div>";
if ($_SESSION['userlevel'] >= '10') {
if ($debug) {
echo("<pre>");
print_r($config);
echo("</pre>");
}
} else {
include 'includes/error-no-perm.inc.php';
}
}
} else { } else {
include 'includes/error-no-perm.inc.php'; include 'includes/error-no-perm.inc.php';
} }
?> ?>
</div>