Author:   Lars Michelsen <[email protected]>
Date:     Tue Mar 27 18:01:49 2012 +0200
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Tue Mar 27 18:01:49 2012 +0200

View options can be persisted per map per user now

---

 TODO                                               |    2 +
 share/server/core/classes/CoreModMap.php           |   37 +++++++++++++++-----
 share/server/core/classes/GlobalMapCfg.php         |   20 ++++++++---
 share/server/core/classes/WuiViewMapAddModify.php  |    2 +
 .../templates/default.wuiMapAddModify.html         |    5 ++-
 5 files changed, 51 insertions(+), 15 deletions(-)

diff --git a/TODO b/TODO
index 2f28b1e..47787f7 100644
--- a/TODO
+++ b/TODO
@@ -153,6 +153,8 @@ Offene Fragen:
     bekannt ist wie groß das Objekt selbst ist
   - Nach dem Einrechnen des Zoomfaktors ist auch die ursprüngliche Größe
     nicht mehr bekannt
+  - Width/Height hängt oft an einem anderen Objekt, als die Position selbst
+    Die Position hängt eher am Container
   -> Nachdenken
 
 - Wenn der Zoom Faktor pro Nutzer gespeichert wird, wird dieser dann pro Map 
diff --git a/share/server/core/classes/CoreModMap.php 
b/share/server/core/classes/CoreModMap.php
index be6b277..e7a0e08 100644
--- a/share/server/core/classes/CoreModMap.php
+++ b/share/server/core/classes/CoreModMap.php
@@ -177,12 +177,13 @@ class CoreModMap extends CoreModule {
                 break;
                 case 'addModify':
                     $aOpts = Array(
-                        'show'     => MATCH_MAP_NAME,
-                        'clone_id' => MATCH_OBJECTID_EMPTY,
-                        'submit'   => MATCH_STRING_EMPTY,
-                        'update'   => MATCH_INTEGER_EMPTY,
-                        'mode'     => MATCH_STRING_EMPTY,
-                        'perm'     => MATCH_BOOLEAN_EMPTY,
+                        'show'      => MATCH_MAP_NAME,
+                        'clone_id'  => MATCH_OBJECTID_EMPTY,
+                        'submit'    => MATCH_STRING_EMPTY,
+                        'update'    => MATCH_INTEGER_EMPTY,
+                        'mode'      => MATCH_STRING_EMPTY,
+                        'perm'      => MATCH_BOOLEAN_EMPTY,
+                        'perm_user' => MATCH_BOOLEAN_EMPTY,
                     );
                     $aVals = $this->getCustomOptions($aOpts, Array(), true);
                     $attrs = 
$this->filterMapAttrs($this->getAllOptions($aOpts));
@@ -192,7 +193,13 @@ class CoreModMap extends CoreModule {
                     // map configuration
                     $mode = isset($aVals['mode']) ? $aVals['mode'] : null;
                     // Tells the handleAddModify handler to store the options 
permanent
-                    $perm = isset($aVals['perm']) ? $aVals['perm'] : null;
+                    if(isset($aVals['perm']) && $aVals['perm'] == '1') {
+                        $perm = 1;
+                    } elseif(isset($aVals['perm_user']) && $aVals['perm_user'] 
== '1') {
+                        $perm = 2;
+                    } else {
+                        $perm = null;
+                    }
 
                     $VIEW = new WuiViewMapAddModify($aVals['show'], $mode);
                     $VIEW->setAttrs($attrs);
@@ -355,15 +362,27 @@ class CoreModMap extends CoreModule {
             // The handler has been called in "view_params" mode. In this case 
the user has
             // less options and the options to
             // 1. modify these parameters only for the current open view
-            // 2. Save the changes for himselfs (FIXME)
+            // 2. Save the changes for himselfs
             // 3. Save the changes to the map config (-> Use default code 
below)
-            if($mode == 'view_params' && $perm != '1') {
+            if($mode == 'view_params' && $perm != 1 && $perm != 2) {
+                echo 1;
                 // This is the 1. case -> redirect the user to a well formated 
url
                 $params = $attrs;
                 unset($params['object_id']);
                 return array(0, $params, '');
             }
 
+            if($mode == 'view_params' && $perm == 2) {
+                // This is the 2. case -> saving the options only for the user
+                $USERCFG = new CoreUserCfg();
+                $params = $attrs;
+                unset($params['object_id']);
+                $USERCFG->doSet(array(
+                    'params-' . $map => $params,
+                ));
+                return array(0, '', '');
+            }
+
             if(!$MAPCFG->objExists($objId))
                 throw new NagVisException(l('The object does not exist.'));
 
diff --git a/share/server/core/classes/GlobalMapCfg.php 
b/share/server/core/classes/GlobalMapCfg.php
index 7b9b0a5..878a36b 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -535,16 +535,26 @@ class GlobalMapCfg {
     public function getSourceParam($key, $only_user_supplied = false, 
$only_customized = false) {
         // Allow _GET or _POST (_POST is needed for add/modify dialog 
submission)
         if(isset($_REQUEST[$key])) {
-            if($only_customized && $_REQUEST[$key] != $this->getValue(0, 
$key)) {
+            if(!$only_customized || $_REQUEST[$key] != $this->getValue(0, 
$key)) {
                 // Only get options which differ from the defaults
                 return $_REQUEST[$key];
             } else {
-                return $_REQUEST[$key];
+                return null;
             }
-        } elseif(!$only_user_supplied) {
-            return $this->getValue(0, $key);
         } else {
-            return null;
+            // Try to use the user profile
+            $USERCFG = new CoreUserCfg();
+            $val = $USERCFG->getValue($key);
+            if($val !== null) {
+                return $val;
+                
+            } elseif(!$only_user_supplied) {
+                // Otherwise use the map global value (if allowed)
+                return $this->getValue(0, $key);
+
+            } else {
+                return null;
+            }
         }
     }
 
diff --git a/share/server/core/classes/WuiViewMapAddModify.php 
b/share/server/core/classes/WuiViewMapAddModify.php
index 3786d9a..a5fd129 100644
--- a/share/server/core/classes/WuiViewMapAddModify.php
+++ b/share/server/core/classes/WuiViewMapAddModify.php
@@ -102,6 +102,8 @@ class WuiViewMapAddModify {
             'mode'          => $this->mode,
             'langSave'      => l('save'),
             'langPermanent' => l('Make Permanent'),
+            'langForAll'    => l('for all users'),
+            'langForYou'    => l('for you'),
         );
 
         // Build page based on the template file and the data array
diff --git a/share/userfiles/templates/default.wuiMapAddModify.html 
b/share/userfiles/templates/default.wuiMapAddModify.html
index 435337b..503acf2 100644
--- a/share/userfiles/templates/default.wuiMapAddModify.html
+++ b/share/userfiles/templates/default.wuiMapAddModify.html
@@ -15,7 +15,10 @@ window.setTimeout(function() \{ window.location.href = 
makeuri({$addParams}); },
     <tr>
         <td class=tdlabel>{$langPermanent}</td>
         <td class=tdbox></td>
-        <td class=tdfield><input type="checkbox" name="perm" value="1" /></td>
+        <td class=tdfield>
+            <input type="checkbox" name="perm" value="1" />{$langForAll}<br />
+            <input type="checkbox" name="perm_user" value="1" />{$langForYou}
+        </td>
     </tr>{/if}
     <tr>
         <td class="tdlabel" colspan="3" align="center">


------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to