$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.');
abstract class Horde_Ajax_Application_Base
{
/**
+ * The Horde application.
+ *
+ * @var string
+ */
+ protected $_app;
+
+ /**
* The action to perform.
*
* @var string
/**
* 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)) {
}
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.');
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;
+ }
+
}
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();