From 9299b8541b7bf3722ccae5ca3f4cf01f974110fe Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 5 Aug 2009 21:50:52 -0600 Subject: [PATCH] Improve session_timeout handling --- imp/ajax.php | 2 +- imp/lib/base.php | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/imp/ajax.php b/imp/ajax.php index 82a0160d0..c6038f24e 100644 --- a/imp/ajax.php +++ b/imp/ajax.php @@ -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. diff --git a/imp/lib/base.php b/imp/lib/base.php index cc963e5cb..6b598551f 100644 --- a/imp/lib/base.php +++ b/imp/lib/base.php @@ -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. * * * 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')) { -- 2.11.0