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

Author: Lars Michelsen <[email protected]>
Date:   Wed Dec 29 11:42:02 2010 +0100

Fixed automap aliases on automap and move automap object_id handling to config 
code

---

 share/server/core/classes/GlobalIndexPage.php      |    8 ++-
 share/server/core/classes/GlobalMapCfg.php         |    2 +-
 share/server/core/classes/NagVisAutoMap.php        |   47 +--------------
 share/server/core/classes/NagVisAutomapCfg.php     |   60 ++++++++++++++++++-
 share/server/core/classes/objects/NagVisObject.php |    2 +
 5 files changed, 67 insertions(+), 52 deletions(-)

diff --git a/share/server/core/classes/GlobalIndexPage.php 
b/share/server/core/classes/GlobalIndexPage.php
index 9984b9e..dd14848 100644
--- a/share/server/core/classes/GlobalIndexPage.php
+++ b/share/server/core/classes/GlobalIndexPage.php
@@ -98,7 +98,7 @@ class GlobalIndexPage {
                                $map['configError'] = true;
                                $map['configErrorMsg'] = $e->getMessage();
                        }
-                       
+
                        if($type == 'automap')
                                $MAP = new NagVisAutoMap($this->CORE, $MAPCFG, 
$this->BACKEND, Array('automap' => $mapName, 'preview' => 1), !IS_VIEW);
                        else
@@ -112,8 +112,10 @@ class GlobalIndexPage {
                        $objConf['hover_menu']        = 1;
                        $objConf['hover_childs_show'] = 1;
                        $objConf['hover_template']    = 'default';
-                       unset($objConf['alias']);
-                       
+                       // Enforce std_medium iconset - don't use map default 
iconset
+                       $objConf['iconset']           = 'std_medium';
+                       $objConf['alias']             = $MAPCFG->getAlias();
+
                        $MAP->MAPOBJ->setConfiguration($objConf);
                        
                        if(isset($map['configError'])) {
diff --git a/share/server/core/classes/GlobalMapCfg.php 
b/share/server/core/classes/GlobalMapCfg.php
index 240e597..f900e96 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -1383,7 +1383,7 @@ class GlobalMapCfg {
         * @param   Boolean  Only fetch global type settings
         * @author      Lars Michelsen <[email protected]>
         */
-       public function gatherTypeDefaults($onlyGlobal) {
+       private function gatherTypeDefaults($onlyGlobal) {
                if($onlyGlobal)
                        $types = Array('global');
                else
diff --git a/share/server/core/classes/NagVisAutoMap.php 
b/share/server/core/classes/NagVisAutoMap.php
index 3967971..67f4b9d 100644
--- a/share/server/core/classes/NagVisAutoMap.php
+++ b/share/server/core/classes/NagVisAutoMap.php
@@ -55,8 +55,6 @@ class NagVisAutoMap extends GlobalMap {
 
        private $graphvizPath;
        private $noBinaryFound;
-
-       private $objIdFile;
        
        /**
         * Automap constructor
@@ -75,7 +73,6 @@ class NagVisAutoMap extends GlobalMap {
                $this->arrHostnamesParsed = Array();
                $this->mapCode = '';
                
-               $this->objIdFile = $CORE->getMainCfg()->getValue('paths', 
'var').'automap.hostids';
                $this->graphvizPath = '';
                $this->noBinaryFound = false;
                
@@ -188,7 +185,7 @@ class NagVisAutoMap extends GlobalMap {
                 * the child tree by the given list of host object ids.
                 */
                if($this->filterByIds) {
-                       $names = $this->objIdsToNames($this->filterByIds);
+                       $names = 
$this->MAPCFG->objIdsToNames($this->filterByIds);
                        $this->rootObject->filterChilds($names);
 
                        // Filter the parent object tree too when enabled
@@ -536,44 +533,6 @@ class NagVisAutoMap extends GlobalMap {
        
        # END Public Methods
        # #####################################################
-
-       /**
-        * Transforms a list of automap object_ids to hostnames using the 
object_id
-        * translation file. Unknown object_ids are skipped
-        *
-        * @author      Lars Michelsen <[email protected]>
-        */
-       private function objIdsToNames($ids) {
-               $names = Array();
-               $map = $this->loadObjIds();
-               foreach($ids AS $id) {
-                       $name = array_search($id, $map);
-                       if($name !== FALSE)
-                               $names[] = $name;
-               }
-               return $names;
-       }
-
-       /**
-        * Loads the hostname to object_id mapping table from the central file
-        *
-        * @author      Lars Michelsen <[email protected]>
-        */
-       private function loadObjIds() {
-               if($this->CORE->checkExisting($this->objIdFile, false))
-                       return json_decode(file_get_contents($this->objIdFile), 
true);
-               else
-                       return Array();
-       }
-
-       /**
-        * Saves the given hostname to object_id mapping table in the central 
file
-        *
-        * @author      Lars Michelsen <[email protected]>
-        */
-       private function storeObjIds($a) {
-               return file_put_contents($this->objIdFile, json_encode($a)) !== 
false;
-       }
        
        private function loadObjectConfigurations() {
                // Load the hosts from mapcfg into the aConf array
@@ -584,7 +543,7 @@ class NagVisAutoMap extends GlobalMap {
                }
 
                // And now load the stored object id (or get a new one)
-               $objIds = $this->loadObjIds();
+               $objIds = $this->MAPCFG->loadObjIds();
                $newObjId = false;
 
                // Loop all map objects to load host individual configurations 
and the uniqe
@@ -609,7 +568,7 @@ class NagVisAutoMap extends GlobalMap {
                }
 
                // When some new object ids have been added store them
-               $this->storeObjIds($objIds);
+               $this->MAPCFG->storeObjIds($objIds);
        }
        
        /**
diff --git a/share/server/core/classes/NagVisAutomapCfg.php 
b/share/server/core/classes/NagVisAutomapCfg.php
index 0e0c8b8..2f31a4b 100644
--- a/share/server/core/classes/NagVisAutomapCfg.php
+++ b/share/server/core/classes/NagVisAutomapCfg.php
@@ -29,6 +29,9 @@
 class NagVisAutomapCfg extends GlobalMapCfg {
        private $defaultConf = null;
 
+       private $objIds = Array();
+       private $objIdFile;
+
        /**
         * Class Constructor
         *
@@ -43,6 +46,8 @@ class NagVisAutomapCfg extends GlobalMapCfg {
                } else {
                        $this->name     = $name;
                }
+
+               $this->objIdFile = $CORE->getMainCfg()->getValue('paths', 
'var').'automap.hostids';
                
                // Start of the parent constructor
                parent::__construct($CORE, $this->name);
@@ -71,11 +76,15 @@ class NagVisAutomapCfg extends GlobalMapCfg {
                // Load the settings once and then remove the dummy host from 
host list
                if(!$this->defaultConf) {
                        $this->defaultConf = Array();
+
+                       $ids = $this->loadObjIds();
+                       if(isset($ids['__dummy__']))
+                               $objectId = $ids['__dummy__'];
+                       else
+                               return $this->defaultConf;
                        
                        /*
                         * 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'
@@ -85,11 +94,11 @@ class NagVisAutomapCfg extends GlobalMapCfg {
                                         && $key != 'x'
                                         && $key != 'y'
                                         && $key != 'line_width') {
-                                       $this->defaultConf[$key] = 
$this->getValue(0, $key);
+                                       $this->defaultConf[$key] = 
$this->getValue($objectId, $key);
                                }
                        }
 
-                       $this->deleteElement(0);
+                       $this->deleteElement($objectId);
                }
                
                return $this->defaultConf;
@@ -109,5 +118,48 @@ class NagVisAutomapCfg extends GlobalMapCfg {
                        $this->mapConfig = array_merge(Array($global, $dummy), 
$this->mapConfig);
                }
        }
+
+       /**
+        * Transforms a list of automap object_ids to hostnames using the 
object_id
+        * translation file. Unknown object_ids are skipped
+        *
+        * @author      Lars Michelsen <[email protected]>
+        */
+       public function objIdsToNames($ids) {
+               $names = Array();
+               $map = $this->loadObjIds();
+               foreach($ids AS $id) {
+                       $name = array_search($id, $map);
+                       if($name !== FALSE)
+                               $names[] = $name;
+               }
+               return $names;
+       }
+
+       /**
+        * Loads the hostname to object_id mapping table from the central file
+        *
+        * @author      Lars Michelsen <[email protected]>
+        */
+       public function loadObjIds() {
+               if($this->objIds === null)
+                       if($this->CORE->checkExisting($this->objIdFile, false))
+                               $this->objIds = 
json_decode(file_get_contents($this->objIdFile), true);
+                       else
+                               $this->objIds = Array();
+
+               return $this->objIds;
+       }
+
+       /**
+        * Saves the given hostname to object_id mapping table in the central 
file
+        *
+        * @author      Lars Michelsen <[email protected]>
+        */
+       public function storeObjIds($a) {
+               $this->objIds = $a;
+
+               return file_put_contents($this->objIdFile, json_encode($a)) !== 
false;
+       }
 }
 ?>
diff --git a/share/server/core/classes/objects/NagVisObject.php 
b/share/server/core/classes/objects/NagVisObject.php
index 0461f00..7ea494e 100644
--- a/share/server/core/classes/objects/NagVisObject.php
+++ b/share/server/core/classes/objects/NagVisObject.php
@@ -39,6 +39,8 @@ class NagVisObject {
        protected $y;
        protected $z;
        protected $icon;
+       protected $url;
+       protected $url_target;
        
        protected $view_type;
        protected $hover_menu;


------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to