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

Author: LaMi <l...@vertical-visions.de>
Date:   Tue Nov 10 17:47:59 2009 +0100

Implemented reload/redirect to frontendMessage

---

 share/frontend/nagvis-js/js/ajax.js                |    2 +-
 share/frontend/nagvis-js/js/frontend.js            |   21 +------------------
 share/frontend/nagvis-js/js/frontendMessage.js     |   13 ++++++++++++
 share/server/core/classes/CoreModAuth.php          |    9 +++----
 .../userfiles/templates/pages/default.header.html  |    2 +-
 5 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/share/frontend/nagvis-js/js/ajax.js 
b/share/frontend/nagvis-js/js/ajax.js
index 351473c..9b8a0ef 100644
--- a/share/frontend/nagvis-js/js/ajax.js
+++ b/share/frontend/nagvis-js/js/ajax.js
@@ -475,4 +475,4 @@ function getFormParams(formId) {
        oForm = null;
        
        return sReturn;
-}
\ No newline at end of file
+}
diff --git a/share/frontend/nagvis-js/js/frontend.js 
b/share/frontend/nagvis-js/js/frontend.js
index e1cb173..13f49ed 100644
--- a/share/frontend/nagvis-js/js/frontend.js
+++ b/share/frontend/nagvis-js/js/frontend.js
@@ -43,25 +43,8 @@ var oAutomapParams = {};
  */
 function submitFrontendForm(sUrl, sFormId) {
        var oResult = postSyncRequest(sUrl, getFormParams(sFormId));
-       if(oResult && oResult.status === 'OK') {
-               var oMsg = {};
-               oMsg.type = 'NOTE';
-               oMsg.message = oResult.message;
-               frontendMessage(oMsg);
-               oMsg = null;
-               
-               // Maybe there is a request for a reload/redirect
-               if(typeof oResult.redirectTime !== 'undefined') {
-                       var sUrl = window.location.href;
-                       
-                       // Maybe enable redirect
-                       if(typeof oResult.redirectUrl !== 'undefined') {
-                               sUrl = oResult.redirectUrl;
-                       }
-                       
-                       // Register reload/redirect
-                       setTimeout(function() {window.location = sUrl;}, 
oResult.redirectTime*1000);
-               }
+       if(oResult && oResult.type && oResult.type === 'NOTE') {
+               frontendMessage(oResult);
                
                // Additionally close the popup window when the response is 
positive
                if(typeof popupWindowClose == 'function') { 
diff --git a/share/frontend/nagvis-js/js/frontendMessage.js 
b/share/frontend/nagvis-js/js/frontendMessage.js
index 2ea3983..13111bd 100644
--- a/share/frontend/nagvis-js/js/frontendMessage.js
+++ b/share/frontend/nagvis-js/js/frontendMessage.js
@@ -165,4 +165,17 @@ function frontendMessage(oMessage, iTimeout) {
        
        document.body.appendChild(oContainerDiv);
        oContainerDiv = null;
+
+       // Maybe there is a request for a reload/redirect
+       if(typeof oMessage.reloadTime !== 'undefined') {
+               var sUrl = window.location.href;
+               
+               // Maybe enable redirect
+               if(typeof oMessage.realoadUrl !== 'undefined') {
+                       sUrl = oMessage.reloadUrl;
+               }
+               
+               // Register reload/redirect
+               setTimeout(function() {window.location = sUrl;}, 
oMessage.reloadTime*1000);
+       }
 }
diff --git a/share/server/core/classes/CoreModAuth.php 
b/share/server/core/classes/CoreModAuth.php
index 20f8f94..e73c378 100644
--- a/share/server/core/classes/CoreModAuth.php
+++ b/share/server/core/classes/CoreModAuth.php
@@ -33,10 +33,11 @@ class CoreModAuth extends CoreModule {
                                                        // Try to authenticate 
the user
                                                        
if($this->AUTHENTICATION->isAuthenticated()) {
                                                                // Display 
success with link and refresh in 5 seconds to called page
-                                                               $sReturn = 
json_encode(Array('status' => 'OK',
+                                                               /*$sReturn = 
json_encode(Array('status' => 'OK',
                                                                                
             'message' => $this->CORE->getLang()->getText('You have been 
authenticated. You will be redirected.'),
                                                                                
             'redirectTime' => 1,
-                                                                               
             'redirectUrl' => $this->CORE->getMainCfg()->getValue('paths', 
'htmlbase')));
+                                                                               
             'redirectUrl' => $this->CORE->getMainCfg()->getValue('paths', 
'htmlbase')));*/
+                                                               new 
GlobalMessage('NOTE', $this->CORE->getLang()->getText('You have been 
authenticated. You will be redirected.'), null, null, 1, 
$this->CORE->getMainCfg()->getValue('paths', 'htmlbase'));
                                                        } else {
                                                                // Invalid 
credentials
                                                                // FIXME: Count 
tries and maybe block somehow
@@ -54,9 +55,7 @@ class CoreModAuth extends CoreModule {
                                case 'logout':
                                        $this->AUTHENTICATION->logout();
                                        
-                                       // Redirect to main page
-                                       Header('Location: 
'.$this->CORE->getMainCfg()->getValue('paths', 'htmlbase'));
-                                       exit(0);
+                                       new GlobalMessage('NOTE', 
$this->CORE->getLang()->getText('You have been logged out. You will be 
redirected.'), null, null, 1, $this->CORE->getMainCfg()->getValue('paths', 
'htmlbase'));
                                break;
                        }
                }
diff --git a/share/userfiles/templates/pages/default.header.html 
b/share/userfiles/templates/pages/default.header.html
index e621710..30062f7 100644
--- a/share/userfiles/templates/pages/default.header.html
+++ b/share/userfiles/templates/pages/default.header.html
@@ -41,7 +41,7 @@
                    <ul>
                        <li><a href="#">{$lang_logged_in}: 
{$current_user}</a></li>
                        <li><a 
href="javascript:showChangePassword('{$lang_change_password}');">{$lang_change_password}</a></li>
-                       <li><a 
href="{$html_base}/server/core/ajax_handler.php?mod=Auth&amp;act=logout" 
class="underline">{$lang_logout}</a></li>
+                       <li><a href="#" 
onclick="getSyncRequest('{$html_base}/server/core/ajax_handler.php?mod=Auth&amp;act=logout');return
 false;" class="underline">{$lang_logout}</a></li>
                    </ul>
                  </dd>
                </dl>


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Nagvis-checkins mailing list
Nagvis-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to