From ef4d1ee357529cbbe6b1182c65fff370c984ea8e Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 21 Jul 2009 18:23:46 -0600 Subject: [PATCH] Clean up logintasks handling We may have to tweak this again going forward, but it will be much elegant and we will most certainly not need all of this hackish code. --- imp/lib/Auth.php | 20 +------------------- kronolith/lib/Kronolith.php | 21 --------------------- kronolith/lib/base.php | 24 ------------------------ turba/lib/base.php | 12 ------------ turba/lib/tests/KolabTestBase.php | 3 +-- 5 files changed, 2 insertions(+), 78 deletions(-) diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php index 2c35253ae..4d03cf018 100644 --- a/imp/lib/Auth.php +++ b/imp/lib/Auth.php @@ -90,10 +90,6 @@ class IMP_Auth throw new Horde_Auth_Exception($e->getMessage()); } - if (!empty($_SESSION['imp']['logintasks'])) { - self::_loginTasks(); - } - return $retval; } @@ -171,7 +167,6 @@ class IMP_Auth * 'imap' -- Config for various IMAP resources (acl, admin, * namespace, quota) * 'imap_ob' -- The serialized Horde_Imap_Client object. - * 'logintasks' -- Have the login tasks been completed? * 'maildomain' -- See config/servers.php. * 'notepadavail' -- Is listing of notepads available? * 'protocol' -- Either 'imap' or 'pop'. @@ -202,7 +197,6 @@ class IMP_Auth $_SESSION['imp'] = array( 'cache' => array(), 'imap' => array(), - 'logintasks' => false, 'server_key' => $credentials['server'], 'showunsub' => false ); @@ -312,18 +306,6 @@ class IMP_Auth /* Set up search information for the session. */ $GLOBALS['imp_search']->sessionSetup(); - IMP_Auth::logMessage('login', __FILE__, __LINE__, PEAR_LOG_NOTICE); - } - - /** - * Perform IMP login tasks. - */ - static protected function _loginTasks() - { - /* Do login tasks. */ - $tasks = Horde_LoginTasks::singleton('imp', Horde::selfUrl(true, true, true)); - $tasks->runTasks(); - /* If the user wants to run filters on login, make sure they get run. */ if ($GLOBALS['prefs']->getValue('filter_on_login')) { @@ -336,7 +318,7 @@ class IMP_Auth $imp_compose = IMP_Compose::singleton(); $imp_compose->recoverSessionExpireDraft(); - $_SESSION['imp']['logintasks'] = true; + IMP_Auth::logMessage('login', __FILE__, __LINE__, PEAR_LOG_NOTICE); } /** diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 1a5846b01..768656ede 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -883,7 +883,6 @@ class Kronolith /* Initialize Kronolith session if we don't have one */ if (!isset($_SESSION['kronolith_session'])) { $_SESSION['kronolith_session'] = array(); - self::loginTasksFlag(1); } /* Fetch display preferences. */ @@ -1089,26 +1088,6 @@ class Kronolith } /** - * 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 - */ - public static function loginTasksFlag($set = null) - { - if (($set !== null)) { - $_SESSION['kronolith_session']['_logintasks'] = $set; - } - - return isset($_SESSION['kronolith_session']['_logintasks']) ? - $_SESSION['kronolith_session']['_logintasks'] : 0; - } - - /** * Returns the real name, if available, of a user. */ public static function getUserName($uid) diff --git a/kronolith/lib/base.php b/kronolith/lib/base.php index 80bb034da..65e5750ca 100644 --- a/kronolith/lib/base.php +++ b/kronolith/lib/base.php @@ -50,27 +50,3 @@ Horde_Nls::setTimeZone(); $GLOBALS['kronolith_shares'] = Horde_Share::singleton($registry->getApp()); Kronolith::initialize(); - -// TODO - Maintenance operations need to be refactored to a more global -// operation and then we can get rid of these hackish checks -/* Do login tasks - need to check for a number of conditions to be - * sure that we aren't here due to alarm notifications (which would occur after - * headers are sent), we aren't on any of the portal pages, and that we haven't - * already performed login tasks. - */ -if (empty($no_maint) && Kronolith::loginTasksFlag() && - !strstr($_SERVER['PHP_SELF'], 'maintenance.php') && - !headers_sent() && !defined('AUTH_HANDLER')) { - Kronolith::loginTasksFlag(2); - - $tasks = Horde_LoginTasks::singleton('kronolith', Horde_Util::addParameter(Horde::selfUrl(true, true, true), array('logintasks_done' => true))); - $tasks->runTasks(); - - Kronolith::loginTasksFlag(0); -} elseif (Horde_Util::getFormData('logintasks_done') && - Kronolith::loginTasksFlag()) { - $tasks = Horde_LoginTasks::singleton('kronolith', Horde_Util::addParameter(Horde::selfUrl(true, true, true), array('logintasks_done' => true))); - $tasks->runTasks(); - - Kronolith::loginTasksFlag(0); -} diff --git a/turba/lib/base.php b/turba/lib/base.php index 9135f8b47..1d991e0a1 100644 --- a/turba/lib/base.php +++ b/turba/lib/base.php @@ -2,9 +2,6 @@ /** * Turba base inclusion file. * - * The following global variables are used: - * $turba_no_maintenance - Don't perform maintenance tasks. - * * This file brings in all of the dependencies that every Turba script will * need, and sets up objects that all scripts use. */ @@ -52,15 +49,6 @@ if (!empty($_SESSION['turba']['has_share'])) { $GLOBALS['cfgSources'] = Turba::permissionsFilter($GLOBALS['cfgSources']); $GLOBALS['attributes'] = $attributes; -// Check for any login tasks needed. Don't need a URL argument since we will -// never redirect to the confirmation screen. -if (empty($_SESSION['turba']['maintenance']) && - !Horde_Util::nonInputVar('turba_no_maintenance')) { - $tasks = Horde_LoginTasks::singleton('turba', null); - $tasks->runTasks(); - $_SESSION['turba']['maintenance'] = true; -} - // Build the directory sources select widget. $default_source = Horde_Util::nonInputVar('source'); if (empty($default_source)) { diff --git a/turba/lib/tests/KolabTestBase.php b/turba/lib/tests/KolabTestBase.php index b528018f8..44d17aa41 100644 --- a/turba/lib/tests/KolabTestBase.php +++ b/turba/lib/tests/KolabTestBase.php @@ -140,8 +140,7 @@ class Turba_KolabTestBase extends Horde_Kolab_Test_Storage $this->assertTrue($world['auth']->authenticate('wrobel@example.org', array('password' => 'none'))); - // Disable maintenance - $GLOBALS['turba_no_maintenance'] = true; + // TODO: Disable maintenance $GLOBALS['registry']->pushApp('turba'); // Find the base file path of Turba. -- 2.11.0