summaryrefslogtreecommitdiffstats
path: root/modules-available/locations/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2016-06-22 17:56:04 +0200
committerSimon Rettberg2016-06-22 17:56:04 +0200
commita6a484ea37aeb91f848c11cb818e2d7d4351d391 (patch)
tree03cc7b9df8dabf61bdb1bc84137601ce187339ef /modules-available/locations/page.inc.php
parent[location] Support passing array of selected locs to getLocations() (diff)
downloadslx-admin-a6a484ea37aeb91f848c11cb818e2d7d4351d391.tar.gz
slx-admin-a6a484ea37aeb91f848c11cb818e2d7d4351d391.tar.xz
slx-admin-a6a484ea37aeb91f848c11cb818e2d7d4351d391.zip
[locations/sysconfig] Implement location specific sysconfig
Diffstat (limited to 'modules-available/locations/page.inc.php')
-rw-r--r--modules-available/locations/page.inc.php54
1 files changed, 50 insertions, 4 deletions
diff --git a/modules-available/locations/page.inc.php b/modules-available/locations/page.inc.php
index 84bc11a9..de724350 100644
--- a/modules-available/locations/page.inc.php
+++ b/modules-available/locations/page.inc.php
@@ -166,7 +166,6 @@ class Page_Locations extends Page
}
}
// Now actual updates
- // TODO: Warn on mismatch/overlap (should lie entirely in parent's subnet, not overlap with others)
$starts = Request::post('startaddr', false);
$ends = Request::post('endaddr', false);
if (!is_array($starts) || !is_array($ends)) {
@@ -263,7 +262,8 @@ class Page_Locations extends Page
{
$overlapSelf = $overlapOther = true;
$subnets = Location::getSubnetsByLocation($overlapSelf, $overlapOther);
- $locs = Location::getLocations();
+ $locs = Location::getLocations(0, 0, false, true);
+ // Statistics: Count machines for each subnet
$unassigned = false;
if (Module::get('statistics') !== false) {
foreach ($locs as &$location) {
@@ -289,15 +289,61 @@ class Page_Locations extends Page
$unassigned = $res['cnt'];
}
unset($loc, $location);
+ // Show currently active sysconfig for each location
+ $defaultConfig = false;
+ if (Module::isAvailable('sysconfig')) {
+ $confs = SysConfig::getAll();
+ foreach ($confs as $conf) {
+ $confLocs = explode(',', $conf['locs']);
+ foreach ($confLocs as $loc) {
+ settype($loc, 'int');
+ if ($loc === 0) {
+ $defaultConfig = $conf['title'];
+ }
+ if (!isset($locs[$loc]))
+ continue;
+ $locs[$loc] += array('configName' => $conf['title'], 'configClass' => 'slx-bold');
+ }
+ }
+ $depth = array();
+ foreach ($locs as &$loc) {
+ $d = $loc['depth'];
+ if (!isset($loc['configName'])) {
+ // Has no explicit config assignment
+ if ($d === 0) {
+ $loc['configName'] = $defaultConfig;
+ } else {
+ $loc['configName'] = $depth[$d - 1];
+ }
+ $loc['configClass'] = 'gray';
+ }
+ $depth[$d] = $loc['configName'];
+ unset($depth[$d + 1]);
+ }
+ unset($loc);
+ }
+ // Count overridden config vars
+ if (Module::get('baseconfig') !== false) {
+ $res = Database::simpleQuery("SELECT locationid, Count(*) AS cnt FROM `setting_location` GROUP BY locationid");
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $lid = (int)$row['locationid'];
+ if (isset($locs[$lid])) {
+ $locs[$lid]['overriddenVars'] = $row['cnt'];
+ }
+ }
+ }
+ // Output
Render::addTemplate('locations', array(
- 'list' => $locs,
+ 'list' => array_values($locs),
'havestatistics' => Module::get('statistics') !== false,
'havebaseconfig' => Module::get('baseconfig') !== false,
+ 'havesysconfig' => Module::get('sysconfig') !== false,
'overlapSelf' => $overlapSelf,
'overlapOther' => $overlapOther,
'haveOverlapSelf' => !empty($overlapSelf),
'haveOverlapOther' => !empty($overlapOther),
- 'unassignedCount' => $unassigned
+ 'unassignedCount' => $unassigned,
+ 'defaultConfig' => $defaultConfig,
));
}