Author:   Lars Michelsen <[email protected]>
Date:     Wed Jun 27 10:08:26 2012 +0200
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Wed Jun 27 10:08:26 2012 +0200

Bugfix: Fixed re-rendering of geomaps after map source changes

---

 ChangeLog                                  |    1 +
 share/server/core/classes/CoreModMap.php   |    4 ++--
 share/server/core/classes/CoreModule.php   |    9 ++++++---
 share/server/core/classes/GlobalMapCfg.php |   13 +++++++++++--
 4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e7838e4..1359fd5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@ Core
   * Bugfix: Suppressing debug messages in non debug mode
   * Bugfix: Better catching of exceptions on nested maps
   * Bugfix: Map configs can be edited using the GUI even in case of source 
errors
+  * Bugfix: Fixed re-rendering of geomaps after map source changes
 
 Frontend
   * Added new map config option (global section) event_on_load to raise 
frontend events
diff --git a/share/server/core/classes/CoreModMap.php 
b/share/server/core/classes/CoreModMap.php
index 689af9a..16c7780 100644
--- a/share/server/core/classes/CoreModMap.php
+++ b/share/server/core/classes/CoreModMap.php
@@ -1023,9 +1023,9 @@ class CoreModMap extends CoreModule {
             'f'  => MATCH_STRING_NO_SPACE_EMPTY
         );
         $aVals = $this->getCustomOptions($aOpts);
-    
+
         // Is this request asked to check file ages?
-        if(isset($aVals['f']) && isset($aVals['f'][0])) {
+        if(isset($aVals['f']) && isset($aVals['f'][0]) && $aVals['f'] != '') {
             $result = $this->checkFilesChanged($aVals['f']);
             if($result !== null)
                 return $result;
diff --git a/share/server/core/classes/CoreModule.php 
b/share/server/core/classes/CoreModule.php
index 0ab4c72..ccce531 100644
--- a/share/server/core/classes/CoreModule.php
+++ b/share/server/core/classes/CoreModule.php
@@ -280,6 +280,7 @@ abstract class CoreModule {
             if(count($parts) != 3)
                 continue;
             list($ty, $name, $age) = $parts;
+            $age = (int) $age;
 
             // Try to fetch the current age of the requested file
             $cur_age = null;
@@ -289,7 +290,8 @@ abstract class CoreModule {
             } elseif($ty == 'map') {
                 if($AUTHORISATION->isPermitted('Map', 'view', $name)) {
                     $MAPCFG  = new NagVisMapCfg($this->CORE, $name);
-                    $cur_age = $MAPCFG->getFileModificationTime();
+                    $MAPCFG->readMapConfig();
+                    $cur_age = $MAPCFG->getFileModificationTime($age);
                 }
             }
 
@@ -299,13 +301,14 @@ abstract class CoreModule {
             }
         }
 
-        if($changed)
+        if(count($changed) > 0) {
             return json_encode(array(
                 'status' => 'CHANGED',
                 'data'   => $changed,
             ));
-        else
+        } else {
             return null;
+        }
     }
 }
 ?>
diff --git a/share/server/core/classes/GlobalMapCfg.php 
b/share/server/core/classes/GlobalMapCfg.php
index 9adea19..f0411f2 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -620,8 +620,9 @@ class GlobalMapCfg {
 
         foreach($sources AS $source) {
             $func = 'changed_'.$source;
-            if($func($this, $compareTime))
+            if($func($this, $compareTime)) {
                 return true;
+            }
         }
         return false;
     }
@@ -1001,8 +1002,16 @@ class GlobalMapCfg {
      * @return Integer Unix timestamp with last modification time
      * @author Lars Michelsen <[email protected]>
      */
-    public function getFileModificationTime() {
+    public function getFileModificationTime($compareTime = null) {
         if($this->checkMapConfigReadable(1)) {
+            // When the sources changed compared to the given time,
+            // return always the current time
+            if($compareTime !== null) {
+                if($this->sourcesChanged($compareTime)) {
+                    return time();
+                }
+            }
+
             $time = filemtime($this->configFile);
             return $time;
         } else {


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to