Module: nagvis
Branch: master
Commit: cd57763e91b51c575151ae5690a29adc9beaece4
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=cd57763e91b51c575151ae5690a29adc9beaece4

Author: Lars Michelsen <[email protected]>
Date:   Sun Sep 26 17:45:48 2010 +0200

#355 Linking automaps in maps works now as expected

---

 share/server/core/classes/CoreModMap.php           |   15 ++++++-
 share/server/core/classes/GlobalMapCfg.php         |    4 +-
 share/server/core/classes/NagVisAutomapCfg.php     |   41 +++++++++++--------
 share/server/core/classes/WuiMapCfg.php            |    2 +-
 share/server/core/classes/objects/NagVisMapObj.php |   22 ++++++----
 share/server/core/classes/objects/NagVisObject.php |    8 +--
 6 files changed, 55 insertions(+), 37 deletions(-)

diff --git a/share/server/core/classes/CoreModMap.php 
b/share/server/core/classes/CoreModMap.php
index 35d8f62..6800c9c 100644
--- a/share/server/core/classes/CoreModMap.php
+++ b/share/server/core/classes/CoreModMap.php
@@ -1023,10 +1023,19 @@ class CoreModMap extends CoreModule {
                                break;
                                case 'map':
                                        // Initialize map configuration based 
on map type
-                                       $MAPCFG = new NagVisMapCfg($this->CORE, 
$arrName1[$i]);
-                                       $MAPCFG->readMapConfig();
+                                       
if($this->CORE->checkMapIsAutomap($arrName1[$i]))
+                                               $SUBMAPCFG = new 
NagVisAutomapCfg($this->CORE, $arrName1[$i]);
+                                       else
+                                               $SUBMAPCFG = new 
NagVisMapCfg($this->CORE, $arrName1[$i]);
+
+                                       if($SUBMAPCFG->checkMapConfigExists(0))
+                                               $SUBMAPCFG->readMapConfig();
                        
-                                       $OBJ = new NagVisMapObj($this->CORE, 
$BACKEND, $MAPCFG, !IS_VIEW);
+                                       
if($this->CORE->checkMapIsAutomap($objConf['map_name'])) {
+                                               $MAP = new 
NagVisAutoMap($this->CORE, $SUBMAPCFG, $BACKEND, Array(), !IS_VIEW);
+                                               $OBJ = $MAP->MAPOBJ;
+                                       } else 
+                                               $OBJ = new 
NagVisMapObj($this->CORE, $BACKEND, $MAPCFG, !IS_VIEW);
                                        $OBJ->fetchMapObjects();
                                break;
                                case 'automap':
diff --git a/share/server/core/classes/GlobalMapCfg.php 
b/share/server/core/classes/GlobalMapCfg.php
index cfe6c2c..f9e9642 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -1941,8 +1941,8 @@ class GlobalMapCfg {
         * @author      Lars Michelsen <[email protected]>
         */
        public function deleteElement($type,$id) {
-               $this->mapConfig[$type][$id] = '';
-               return TRUE;
+               unset($this->mapConfig[$type][$id]);
+               return true;
        }
        
        /**
diff --git a/share/server/core/classes/NagVisAutomapCfg.php 
b/share/server/core/classes/NagVisAutomapCfg.php
index 5a54f3c..367959f 100644
--- a/share/server/core/classes/NagVisAutomapCfg.php
+++ b/share/server/core/classes/NagVisAutomapCfg.php
@@ -27,6 +27,8 @@
  * @author     Lars Michelsen <[email protected]>
  */
 class NagVisAutomapCfg extends GlobalMapCfg {
+       private $defaultConf = null;
+
        /**
         * Class Constructor
         *
@@ -62,26 +64,31 @@ class NagVisAutomapCfg extends GlobalMapCfg {
         * @author      Lars Michelsen <[email protected]>
         */
        public function &getObjectConfiguration() {
-               $objConf = Array();
-               
-               /*
-                * Get object default configuration from configuration file
-                * The dummy host MUST be the first host defined in the automap 
configuration file.
-                * The settings of the first host will be used for all objects 
on the map
-                */
-               foreach($this->getValidTypeKeys('host') AS $key) {
-                       if($key != 'type'
-                                && $key != 'backend_id'
-                                && $key != 'host_name'
-                                && $key != 'object_id'
-                                && $key != 'x'
-                                && $key != 'y'
-                                && $key != 'line_width') {
-                               $objConf[$key] = $this->getValue('host', 0, 
$key);
+               // Load the settings once and then remove the dummy host from 
host list
+               if(!$this->defaultConf) {
+                       $this->defaultConf = Array();
+                       
+                       /*
+                        * Get object default configuration from configuration 
file
+                        * The dummy host MUST be the first host defined in the 
automap configuration file.
+                        * The settings of the first host will be used for all 
objects on the map
+                        */
+                       foreach($this->getValidTypeKeys('host') AS $key) {
+                               if($key != 'type'
+                                        && $key != 'backend_id'
+                                        && $key != 'host_name'
+                                        && $key != 'object_id'
+                                        && $key != 'x'
+                                        && $key != 'y'
+                                        && $key != 'line_width') {
+                                       $this->defaultConf[$key] = 
$this->getValue('host', 0, $key);
+                               }
                        }
+
+                       $this->deleteElement('host', 0);
                }
                
-               return $objConf;
+               return $this->defaultConf;
        }
 }
 ?>
diff --git a/share/server/core/classes/WuiMapCfg.php 
b/share/server/core/classes/WuiMapCfg.php
index 7a9f340..3d38c99 100644
--- a/share/server/core/classes/WuiMapCfg.php
+++ b/share/server/core/classes/WuiMapCfg.php
@@ -179,7 +179,7 @@ class WuiMapCfg extends GlobalMapCfg {
                                                // check if element exists
                                                if($a == $id) {
                                                        // check if element is 
an array...
-                                                       
if(is_array($this->mapConfig[$type][$a])) {
+                                                       
if(isset($this->mapConfig[$type][$a]) && is_array($this->mapConfig[$type][$a])) 
{
                                                                // ...array: 
update!
                                                                
                                                                // choose first 
parameter line
diff --git a/share/server/core/classes/objects/NagVisMapObj.php 
b/share/server/core/classes/objects/NagVisMapObj.php
index a8a4361..15b7b0a 100644
--- a/share/server/core/classes/objects/NagVisMapObj.php
+++ b/share/server/core/classes/objects/NagVisMapObj.php
@@ -337,11 +337,9 @@ class NagVisMapObj extends NagVisStatefulObject {
                                        $objConf['id'] = $index;
                                        
                                        // merge with "global" settings
-                                       foreach($typeDefs AS $key => $default) {
-                                               if(!isset($objConf[$key])) {
+                                       foreach($typeDefs AS $key => $default)
+                                               if(!isset($objConf[$key]))
                                                        $objConf[$key] = 
$default;
-                                               }
-                                       }
                                        
                                        switch($type) {
                                                case 'host':
@@ -360,14 +358,20 @@ class NagVisMapObj extends NagVisStatefulObject {
                                                        // Initialize map 
configuration based on map type
                                                        
if($this->CORE->checkMapIsAutomap($objConf['map_name'])) {
                                                                $SUBMAPCFG = 
new NagVisAutomapCfg($this->CORE, $objConf['map_name']);
-                                                       } else {
+
+                                                               // Override the 
default map url for the automaps
+                                                               $objConf['url'] 
= str_replace('mod=Map', 'mod=AutoMap', $objConf['url']);
+                                                       } else
                                                                $SUBMAPCFG = 
new NagVisMapCfg($this->CORE, $objConf['map_name']);
-                                                       }
                                                        
-                                                       
if($SUBMAPCFG->checkMapConfigExists(0)) {
+                                                       
if($SUBMAPCFG->checkMapConfigExists(0))
                                                                
$SUBMAPCFG->readMapConfig();
-                                                       }
-                                                       $OBJ = new 
NagVisMapObj($this->CORE, $this->BACKEND, $SUBMAPCFG, !IS_VIEW);
+
+                                                       
if($this->CORE->checkMapIsAutomap($objConf['map_name'])) {
+                                                               $MAP = new 
NagVisAutoMap($this->CORE, $SUBMAPCFG, $this->BACKEND, Array(), !IS_VIEW);
+                                                               $OBJ = 
$MAP->MAPOBJ;
+                                                       } else 
+                                                               $OBJ = new 
NagVisMapObj($this->CORE, $this->BACKEND, $SUBMAPCFG, !IS_VIEW);
                                                        
                                                        
if(!$SUBMAPCFG->checkMapConfigExists(0)) {
                                                                
$OBJ->summary_state = 'ERROR';
diff --git a/share/server/core/classes/objects/NagVisObject.php 
b/share/server/core/classes/objects/NagVisObject.php
index 92547ec..8d10387 100644
--- a/share/server/core/classes/objects/NagVisObject.php
+++ b/share/server/core/classes/objects/NagVisObject.php
@@ -224,13 +224,12 @@ class NagVisObject {
                
                // Need to remove some options which are not relevant
                // FIXME: Would be much better to name the needed vars explicit
-               if(self::$arrDenyKeys == null) {
+               if(self::$arrDenyKeys == null)
                        self::$arrDenyKeys = Array('CORE' => '', 'BACKEND' => 
'', 'MAPCFG' => '',
                                'MAP' => '', 'GRAPHIC' => '', 'conf' => '', 
'services' => '',
                                'fetchedChildObjects' => '', 'childObjects' => 
'', 'parentObjects' => '',
                                'members' => '', 'objects' => '', 'linkedMaps' 
=> '', 'isSummaryObject' => '',
                                'isView' => '', 'dateFormat' => '', 
'arrDenyKeys' => '');
-               }
                
                foreach($this AS $key => $val) {
                        if(!isset(self::$arrDenyKeys[$key])) {
@@ -239,11 +238,10 @@ class NagVisObject {
                }
 
                // Add special static options
-               if($this instanceof NagVisStatefulObject) {
+               if($this instanceof NagVisStatefulObject)
                        $arr['iconHtmlPath'] = 
NagVisStatefulObject::$iconHtmlPath;
-               } elseif($this instanceof NagVisStatelessObject) {
+               elseif($this instanceof NagVisStatelessObject)
                        $arr['iconHtmlPath'] = 
NagVisStatelessObject::$iconHtmlPath;
-               }
                
                // Save the number of members
                switch($this->type) {


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to