Stupid framesets needlessly complicate everything.
}
/**
- * Either sets or checks the value of the logintasks flag.
- *
- * @param integer $set The value of the flag.
- *
- * @return integer The value of the flag.
- * 0 = No login tasks pending
- * 1 = Login tasks pending
- * 2 = Login tasks pending, previous tasks interrupted
- */
- static public function loginTasksFlag($set = null)
- {
- if (!is_null($set)) {
- $_SESSION['imp']['logintasks'] = $set;
- }
-
- return isset($_SESSION['imp']['logintasks'])
- ? $_SESSION['imp']['logintasks']
- : 0;
- }
-
- /**
* Convert a preference value to/from the value stored in the preferences.
*
* Preferences that need to call this function before storing/retrieving:
$_SESSION['imp'] = array(
'cache' => array(),
'imap' => array(),
+ 'logintasks' => false,
'server_key' => $server,
'showunsub' => false
);
$sess = &$_SESSION['imp'];
- /* Set the logintasks flag. */
- IMP::loginTasksFlag(1);
-
/* Run the username through virtualhost expansion functions if
* necessary. */
if (!empty($conf['hooks']['vinfo'])) {
/**
* Perform IMP login tasks.
+ *
+ * @param string $url The URL to use for the Horde_LoginTasks redirect.
*/
- static public function loginTasks()
+ static public function loginTasks($url = null)
{
- if (!IMP::loginTasksFlag()) {
+ if (!empty($_SESSION['imp']['logintasks'])) {
return;
}
- IMP::loginTasksFlag(2);
- IMP::checkAuthentication(true);
-
/* Do login tasks. */
- $tasks = &Horde_LoginTasks::singleton('imp', Horde_Util::addParameter(Horde::selfUrl(true, true, true), array('logintasks_done' => true)));
+ $tasks = &Horde_LoginTasks::singleton('imp', is_null($url) ? Horde::selfUrl(true, true, true) : $url);
$tasks->runTasks();
/* If the user wants to run filters on login, make sure they get
$imp_compose = &IMP_Compose::singleton();
$imp_compose->recoverSessionExpireDraft();
- IMP::loginTasksFlag(0);
+ $_SESSION['imp']['logintasks'] = true;
}
/**
/**
* Tries to authenticate with the mail server and create a mail session.
*
- * @param string $userID The username of the user.
- * @param array $credentials Credentials of the user. Only allowed key:
- * 'password'.
- * @param array $params Additional parameters. Only allowed key:
- * 'server'.
+ * @param string $userID The username of the user.
+ * @param array $credentials Credentials of the user. Only allowed key:
+ * 'password'.
+ * @param array $params Additional parameters. Only allowed key:
+ * 'server'.
*
* @return boolean True on success, false on failure.
*/
require_once IMP_BASE . '/lib/Session.php';
$server_key = empty($params['server'])
- ? IMP_Session::getAutoLoginServer()
- : $params['server'];
+ ? IMP_Session::getAutoLoginServer()
+ : $params['server'];
return IMP_Session::createSession($userID, $credentials['password'], $server_key);
}
$debug = Horde_Util::nonInputVar('mimp_debug');
$GLOBALS['mimp_render'] = new Horde_Mobile(null, $debug);
$GLOBALS['mimp_render']->set('debug', !empty($debug));
+} elseif (empty($_SESSION['imp']['logintasks']) &&
+ ($authentication !== 'none') &&
+ !defined('AUTH_HANDLER')) {
+ /* This captures all login tasks requests other than the IMP
+ * authentication + frameset case which needs to be handled in
+ * redirect.php. */
+ IMP_Session::loginTasks();
}
function _framesetUrl($url)
{
if (!$GLOBALS['noframeset'] && Horde_Util::getFormData('load_frameset')) {
- $full_url = Horde::applicationUrl($GLOBALS['registry']->get('webroot', 'horde') . '/index.php', true);
- $url = Horde_Util::addParameter($full_url, 'url', _addAnchor($url, 'param'), false);
+ $url = Horde_Util::addParameter(Horde::applicationUrl($GLOBALS['registry']->get('webroot', 'horde') . '/index.php', true), array('url' => _addAnchor($url, 'param')), null, false);
+
+ /* Need to do a loginTasks check here because we must display login
+ * tasks before frameset is loaded. */
+ IMP_Session::loginTasks($url);
}
return $url;
}
$imapuser = IMP_Session::canAutoLogin();
$pass = Auth::getCredential('password');
}
-$isLogin = IMP::loginTasksFlag();
+$isLogin = empty($_SESSION['imp']['logintasks']);
$noframeset = false;
/* Get URL/Anchor strings now. */
$url_in = substr($url_in, 0, $pos);
}
-/* If we are returning from LoginTasks processing. */
-if (Horde_Util::getFormData('logintasks_done')) {
- /* Finish up any login tasks we haven't completed yet. */
- IMP_Session::loginTasks();
-
- _redirect(_framesetUrl(_newSessionUrl($actionID, $isLogin)));
-}
-
/* If we already have a session: */
if (isset($_SESSION['imp']) && is_array($_SESSION['imp'])) {
/* Make sure that if a username was specified, it is the current
_redirect(IMP::getLogoutUrl(AUTH_REASON_FAILED, true));
}
- /* Finish up any login tasks we haven't completed yet. */
- IMP_Session::loginTasks();
-
$url = $url_in;
if (empty($url_in)) {
$url = IMP_Session::getInitialUrl($actionID, false);
Horde::callHook('_imp_hook_postlogin', array($actionID, $isLogin), 'imp');
}
- IMP_Session::loginTasks();
-
_redirect(_framesetUrl(_newSessionUrl($actionID, $isLogin)));
}