Clean up logintasks handling
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 22 Jul 2009 00:23:46 +0000 (18:23 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 22 Jul 2009 04:17:21 +0000 (22:17 -0600)
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
kronolith/lib/Kronolith.php
kronolith/lib/base.php
turba/lib/base.php
turba/lib/tests/KolabTestBase.php

index 2c35253..4d03cf0 100644 (file)
@@ -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);
     }
 
     /**
index 1a5846b..768656e 100644 (file)
@@ -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)
index 80bb034..65e5750 100644 (file)
@@ -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);
-}
index 9135f8b..1d991e0 100644 (file)
@@ -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)) {
index b528018..44d17aa 100644 (file)
@@ -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.