$imp_session_control = 'readonly';
}
-$imp_dimp_logout = ($action == 'LogOut');
-$imp_session_timeout = 'json';
-require_once IMP_BASE . '/lib/base.php';
+$imp_authentication = 'throw';
+try {
+ require_once IMP_BASE . '/lib/base.php';
+} catch (Horde_Exception $e) {
+ /* Handle session timeouts when they come from an AJAX request. */
+ if ($e->getCode() == Horde_Registry::AUTH_FAILURE) {
+ $notification = Horde_Notification::singleton();
+ $imp_notify = $notification->attach('status', array('viewmode' => 'dimp'), 'IMP_Notification_Listener_Status');
+ $notification->push(str_replace('&', '&', Horde_Auth::getLogoutUrl(array('reason' => Horde_Auth::REASON_SESSION))), 'dimp.timeout', array('content.raw'));
+ Horde::sendHTTPResponse(Horde::prepareResponse(null, $imp_notify), 'json');
+ exit;
+ }
+
+ Horde_Auth::authenticateFailure('imp', $e);
+}
// Process common request variables.
$mbox = Horde_Util::getPost('view');
$result = false;
switch ($action) {
+case 'LogOut':
+ /* Handle logout requests. This needs to be done here because the logout
+ * tokens might expire otherwise. */
+ Horde::redirect(str_replace('&', '&', Horde::getServiceLink('logout', 'imp')));
+ break;
+
case 'CreateFolder':
if (empty($mbox)) {
break;
* [DEFAULT] - Authenticate to IMAP/POP server; on no auth redirect to login
* screen
* $imp_compose_page - If true, we are on IMP's compose page
- * $imp_dimp_logout - Logout and redirect to the login page.
* $imp_no_compress - Controls whether the page should be compressed
* $imp_session_control - Sets special session control limitations:
* 'netscape' - TODO; start read/write session
* '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:
}
$registry = Horde_Registry::singleton($s_ctrl);
-// Determine view mode.
-$viewmode = isset($_SESSION['imp']['view'])
- ? $_SESSION['imp']['view']
- : 'imp';
-
-// Handle dimp logout requests.
-if (($viewmode == 'dimp') && Horde_Util::nonInputVar('imp_dimp_logout')) {
- Horde::redirect(str_replace('&', '&', Horde::getServiceLink('logout', 'imp')));
-}
-
// Determine imp authentication type.
$authentication = Horde_Util::nonInputVar('imp_authentication');
if ($authentication == 'horde') {
$registry->pushApp('imp', array('check_perms' => ($authentication != 'none'), 'logintasks' => true));
} catch (Horde_Exception $e) {
if ($e->getCode() == Horde_Registry::AUTH_FAILURE) {
- if ($authentication == 'throw') {
- throw $e;
- }
-
- // 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')) {
$imp_compose = IMP_Compose::singleton();
$imp_compose->sessionExpireDraft();
}
+
+ if ($authentication == 'throw') {
+ throw $e;
+ }
}
Horde_Auth::authenticateFailure('imp', $e);
'URI_MESSAGE' => Horde::applicationUrl('message-dimp.php'),
'URI_PREFS' => Horde::getServiceLink('prefsapi', 'imp'),
'URI_PREFS_IMP' => str_replace('&', '&', Horde::getServiceLink('options', 'imp')),
- 'URI_TIMEOUT' => Horde_Auth::getLogoutUrl(array('reason' => Horde_Auth::REASON_SESSION)),
'URI_VIEW' => Horde::applicationUrl('view.php'),
'SESSION_ID' => defined('SID') ? SID : '',