From b72c6d41a4678781abd1a9f0910d5cf7f785389b Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 21 Jan 2010 10:58:07 -0700 Subject: [PATCH] Move LogOut to Horde_Ajax_Application_Base so it can be overriden if needed --- framework/Ajax/lib/Horde/Ajax.php | 2 +- framework/Ajax/lib/Horde/Ajax/Application/Base.php | 28 ++++++++++++++++++++-- horde/services/ajax.php | 7 ------ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/framework/Ajax/lib/Horde/Ajax.php b/framework/Ajax/lib/Horde/Ajax.php index 6c50d91dc..0bb768440 100644 --- a/framework/Ajax/lib/Horde/Ajax.php +++ b/framework/Ajax/lib/Horde/Ajax.php @@ -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.'); diff --git a/framework/Ajax/lib/Horde/Ajax/Application/Base.php b/framework/Ajax/lib/Horde/Ajax/Application/Base.php index bf7d022ee..6ed882d84 100644 --- a/framework/Ajax/lib/Horde/Ajax/Application/Base.php +++ b/framework/Ajax/lib/Horde/Ajax/Application/Base.php @@ -13,6 +13,13 @@ 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('&', '&', Horde::getServiceLink('logout', $this->_app))); + exit; + } + } diff --git a/horde/services/ajax.php b/horde/services/ajax.php index 7854f6a96..571cc355f 100644 --- a/horde/services/ajax.php +++ b/horde/services/ajax.php @@ -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('&', '&', Horde::getServiceLink('logout', $app))); - exit; -} - // Open an output buffer to ensure that we catch errors that might break JSON // encoding. ob_start(); -- 2.11.0