allow modules to react on AJAX requests

This commit is contained in:
Roland Gruber 2012-02-25 18:39:52 +00:00
parent cbcff51b98
commit 77f9862ec4
3 changed files with 24 additions and 2 deletions

View File

@ -7,6 +7,7 @@
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"><title>Upgrade notes</title>
@ -32,10 +33,12 @@ This is a list of API changes for all LAM releases.
new function supportsForcePasswordChange() and changed function
passwordChangeRequested() to support password change at next login <br>
</li>
<li><span style="font-weight: bold;">getSelfServiceOptions()/checkSelfServiceOptions():</span> added parameter to specify if only password changes are allowed<br>
<li><span style="font-weight: bold;">getSelfServiceOptions()/checkSelfServiceOptions():</span> added parameter to specify if only password changes are allowed</li>
<li><span style="font-weight: bold;">handleAjaxRequest():</span> This new function allows AJAX requests to be answered by modules<br>
</li>
</ul>
<br>

View File

@ -1400,6 +1400,14 @@ abstract class baseModule {
return null;
}
/**
* Manages AJAX requests.
* This function may be called with or without an account container.
*/
public function handleAjaxRequest() {
// modules that use AJAX need to implement this function
}
// helper functions

View File

@ -3,7 +3,7 @@
$Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2011 Roland Gruber
Copyright (C) 2011 - 2012 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -47,6 +47,17 @@ class lamAjax {
* Manages an AJAX request.
*/
public static function handleRequest() {
if (isset($_GET['module']) && isset($_GET['scope']) && in_array($_GET['module'], getAvailableModules($_GET['scope']))) {
if (isset($_GET['useContainer']) && ($_GET['useContainer'] == '1')) {
if (!isset($_SESSION['account'])) die();
$module = $_SESSION['account']->getAccountModule($_GET['module']);
$module->handleAjaxRequest();
}
else {
$module = new $_GET['module']($_GET['scope']);
$module->handleAjaxRequest();
}
}
if (!isset($_GET['function'])) {
die();
}