Author: Lars Michelsen <[email protected]>
Date: Thu Aug 8 08:39:43 2013 +0200
Committer: Lars Michelsen <[email protected]>
Commit-Date: Thu Aug 8 08:39:43 2013 +0200
Fixed source param validation in addmodify dialog
---
share/server/core/classes/CoreModMap.php | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/share/server/core/classes/CoreModMap.php
b/share/server/core/classes/CoreModMap.php
index 3dce522..1f96ab1 100644
--- a/share/server/core/classes/CoreModMap.php
+++ b/share/server/core/classes/CoreModMap.php
@@ -390,7 +390,7 @@ class CoreModMap extends CoreModule {
if(!$MAPCFG->objExists($objId))
throw new NagVisException(l('The object does not exist.'));
- $this->validateAttributes($MAPCFG->getValidObjectType($type),
$attrs);
+ $this->validateAttributes($MAPCFG,
$MAPCFG->getValidObjectType($type), $attrs);
// Update the map configuration
if($mode == 'view_params') {
@@ -410,7 +410,7 @@ class CoreModMap extends CoreModule {
// Create the new object
$type = $attrs['type'];
- $this->validateAttributes($MAPCFG->getValidObjectType($type),
$attrs);
+ $this->validateAttributes($MAPCFG,
$MAPCFG->getValidObjectType($type), $attrs);
// append a new object definition to the map configuration
$MAPCFG->addElement($type, $attrs, true);
@@ -426,12 +426,18 @@ class CoreModMap extends CoreModule {
return $successMsg;
}
- private function validateAttributes($attrDefs, $attrs) {
+ private function validateAttributes($MAPCFG, $attrDefs, $attrs) {
// Are some must values missing?
foreach($attrDefs as $propname => $prop) {
- if(isset($prop['must']) && $prop['must'] == '1'
- && (!isset($attrs[$propname]) || $attrs[$propname] == ''))
- throw new FieldInputError($propname, l('The attribute needs to
be set.'));
+ if(isset($prop['must']) && $prop['must'] == '1') {
+ // In case of "source" options only validate the ones which
belong
+ // to currently enabled sources
+ if(isset($prop['source_param']) &&
!in_array($prop['source_param'], $MAPCFG->getValue(0, 'sources')))
+ continue;
+
+ if (!isset($attrs[$propname]) || $attrs[$propname] == '')
+ throw new FieldInputError($propname, l('The attribute
needs to be set.'));
+ }
}
// FIXME: Are all given attrs valid ones?
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins