Move LogOut to Horde_Ajax_Application_Base so it can be overriden if needed
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 21 Jan 2010 17:58:07 +0000 (10:58 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 21 Jan 2010 18:05:22 +0000 (11:05 -0700)
framework/Ajax/lib/Horde/Ajax.php
framework/Ajax/lib/Horde/Ajax/Application/Base.php
horde/services/ajax.php

index 6c50d91..0bb7684 100644 (file)
@@ -27,7 +27,7 @@ class Horde_Ajax
         $class = $app . '_Ajax_Application';
 
         if (class_exists($class)) {
-            return new $class($action);
+            return new $class($app, $action);
         }
 
         throw new Horde_Ajax_Exception('Ajax configuration for ' . $app . ' not found.');
index bf7d022..6ed882d 100644 (file)
 abstract class Horde_Ajax_Application_Base
 {
     /**
+     * The Horde application.
+     *
+     * @var string
+     */
+    protected $_app;
+
+    /**
      * The action to perform.
      *
      * @var string
@@ -29,10 +36,13 @@ abstract class Horde_Ajax_Application_Base
     /**
      * Constructor.
      *
+     * @param string $app     The application name.
      * @param string $action  The AJAX action to perform.
      */
-    public function __construct($action = null)
+    public function __construct($app, $action = null)
     {
+        $this->_app = $app;
+
         if (!is_null($action)) {
             /* Close session if action is labeled as read-only. */
             if (in_array($action, $this->_readOnly)) {
@@ -56,7 +66,7 @@ abstract class Horde_Ajax_Application_Base
         }
 
         if (method_exists($this, $this->_action)) {
-        return call_user_func(array($this, $this->_action), Horde_Variables::getDefaultVariables());
+            return call_user_func(array($this, $this->_action), Horde_Variables::getDefaultVariables());
         }
 
         throw new Horde_Ajax_Exception('Handler for action "' . $this->_action . '" does not exist.');
@@ -73,4 +83,18 @@ abstract class Horde_Ajax_Application_Base
         return null;
     }
 
+    /**
+     * AJAX action: Logout.
+     *
+     * This needs to be done here (server), rather than on the browser,
+     * because the logout tokens might otherwise expire.
+     *
+     * @param Horde_Variables $vars  None used.
+     */
+    public function LogOut($vars)
+    {
+        Horde::redirect(str_replace('&amp;', '&', Horde::getServiceLink('logout', $this->_app)));
+        exit;
+    }
+
 }
index 7854f6a..571cc35 100644 (file)
@@ -48,13 +48,6 @@ try {
     Horde_Auth::authenticateFailure($app, $e);
 }
 
-// Handle logout requests. This needs to be done here, rather than on the
-// browser, because the logout tokens might otherwise expire.
-if ($action == 'LogOut') {
-    Horde::redirect(str_replace('&amp;', '&', Horde::getServiceLink('logout', $app)));
-    exit;
-}
-
 // Open an output buffer to ensure that we catch errors that might break JSON
 // encoding.
 ob_start();