Improve session_timeout handling
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 6 Aug 2009 03:50:52 +0000 (21:50 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 6 Aug 2009 03:51:07 +0000 (21:51 -0600)
imp/ajax.php
imp/lib/base.php

index 82a0160..c6038f2 100644 (file)
@@ -165,7 +165,7 @@ if (in_array($action, array('chunkContent', 'Html2Text', 'Text2Html', 'GetReplyD
 }
 
 $imp_dimp_logout = ($action == 'LogOut');
-$session_timeout = 'json';
+$imp_session_timeout = 'json';
 require_once IMP_BASE . '/lib/base.php';
 
 // Process common request variables.
index cc963e5..6b59855 100644 (file)
@@ -20,6 +20,8 @@
  *   'none' - Do not start a session
  *   'readonly' - Start session readonly
  *   [DEFAULT] - Start read/write session
+ * $imp_session_timeout - Sets special handling for session timeouts:
+ *   'json' - Send session logout request to browser.
  * </pre>
  *
  * Global variables defined:
@@ -88,21 +90,13 @@ try {
             throw $e;
         }
 
-        if ($viewmode == 'dimp') {
-            // Handle session timeouts
-            switch (Horde_Util::nonInputVar('session_timeout')) {
-            case 'json':
-                $GLOBALS['notification']->push(null, 'dimp.timeout');
-                Horde::sendHTTPResponse(Horde::prepareResponse(), 'json');
-                exit;
-
-            case 'none':
-                exit;
-
-            default:
-                // TODO: Redirect to login screen
-                exit;
-            }
+        // Handle session timeouts when they come from an AJAX request.
+        if (($viewmode == 'dimp') &&
+            (Horde_Util::nonInputVar('imp_session_timeout') == 'json')) {
+            $notification = Horde_Notification::singleton();
+            $notification->push(null, 'dimp.timeout');
+            Horde::sendHTTPResponse(Horde::prepareResponse(), 'json');
+            exit;
         }
 
         if (Horde_Util::nonInputVar('imp_compose_page')) {