Author: Lars Michelsen <[email protected]>
Date: Fri Aug 29 20:42:57 2014 +0200
Committer: Lars Michelsen <[email protected]>
Commit-Date: Fri Aug 29 20:42:57 2014 +0200
Fixed dynamic map global setting default values
---
ChangeLog | 1 +
share/server/core/classes/GlobalMapCfg.php | 33 +++++++++++++++++++++++++--
share/server/core/sources/automap.php | 13 +++++++---
3 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a505c5a..3505fe0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
1.8b7:
Frontend:
* FIX: The zoombar is now rendered below the header menu layer
+ * FIX: The line_arrow is now configured using a dropdown field
Core:
* Multisite Authorisation: It is now possible to specific manage map
view/edit permissions
diff --git a/share/server/core/classes/GlobalMapCfg.php
b/share/server/core/classes/GlobalMapCfg.php
index dd742c5..e9f35a8 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -45,6 +45,7 @@ class GlobalMapCfg {
// Array for config validation
protected static $validConfig = null;
+ protected static $updateValidConfig = array();
// Array for holding the registered map sources
protected static $viewParams = array();
@@ -427,6 +428,13 @@ class GlobalMapCfg {
), $this->getSourceParams(true, true));
}
+ // Update the valid config construct with source specific adaptions
+ // It is a hack to do it here, because these changes might affect maps
+ // which are using other sources. But for the moment this seems to be
+ // okay, because the sources only adapt options which are related to
+ // the visualisation of objects.
+ $this->addSourceDefaults();
+
// Gather the default values for the object types
$this->gatherTypeDefaults($onlyGlobal);
@@ -481,9 +489,10 @@ class GlobalMapCfg {
private function fetchMapSources() {
global $CORE;
foreach($CORE->getAvailableSources() AS $source_name) {
- $viewParams = array();
- $configVars = array();
- $selectable = false;
+ $viewParams = array();
+ $configVars = array();
+ $updateConfigVars = array();
+ $selectable = false;
if(file_exists(path('sys', 'local', 'sources'))) {
include_once(path('sys', 'local', 'sources') . '/'.
$source_name . '.php');
@@ -506,6 +515,11 @@ class GlobalMapCfg {
self::$validConfig['global'][$key]['source_param'] =
$source_name;
}
+ // Apply adaptions to the generic options
+ if (count($updateConfigVars) > 0) {
+ self::$updateValidConfig[$source_name] = $updateConfigVars;
+ }
+
// Register the slectable source
if ($selectable) {
$CORE->addSelectableSource($source_name);
@@ -653,6 +667,19 @@ class GlobalMapCfg {
return $params;
}
+ private function addSourceDefaults() {
+ $sources = $this->getValue(0, 'sources') !== false ?
$this->getValue(0, 'sources') : array();
+ foreach ($sources AS $source_name) {
+ if (isset(self::$updateValidConfig[$source_name])) {
+ foreach(self::$updateValidConfig[$source_name] AS $param =>
$spec) {
+ foreach ($spec AS $key => $val) {
+ self::$validConfig['global'][$param][$key] = $val;
+ }
+ }
+ }
+ }
+ }
+
/**
* Stores the user given options as parameters in the map configuration
when
* the user requested this.
diff --git a/share/server/core/sources/automap.php
b/share/server/core/sources/automap.php
index e8a694f..e8c7328 100644
--- a/share/server/core/sources/automap.php
+++ b/share/server/core/sources/automap.php
@@ -169,10 +169,15 @@ if (cfg('global', 'shinken_features')) {
);
}
-// Hack to reflect the automap line default settings
-GlobalMapCfg::$validConfig['global']['line_color']['default'] = '#000000';
-GlobalMapCfg::$validConfig['global']['line_width']['default'] = '1';
-GlobalMapCfg::$validConfig['global']['line_arrow']['default'] = 'forward';
+// Alter some global vars with automap specific things
+$updateConfigVars = array(
+ 'line_width' => array(
+ 'default' => '1',
+ ),
+ 'line_color' => array(
+ 'default' => '#000000',
+ ),
+);
/**
* Get root host object by NagVis configuration or by backend.
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins