Source for file async.php
Documentation is available at async.php
* This is the handler for asynchronous 'AJAX' calls.
* This file is part of Quam Plures - {@link http://quamplures.net/}
* See also {@link https://launchpad.net/quam-plures}.
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
* @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
* {@internal License choice
* - If you have received this file as part of a package, please find the license.txt file in
* the same folder or the closest folder above for complete license terms.
* - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
* then you must choose one of the following licenses before using the file:
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
* {@internal Open Source relicensing agreement:
* Do the MAIN initializations:
require_once dirname(__FILE__ ). '/../qp_config/_config.php';
* TODO (legacy) dh> refactor _main.inc.php to be able to include small parts
* (e.g. $current_User, charset init, ...) only..
* It worked already for $DB (_connect_db.inc.php).
* fp> I think I'll try _core_main.inc , _evo_main.inc , _blog_main.inc ; this file would only need _core_main.inc
require_once $inc_path. '_main.inc.php';
param( 'action', 'string', '' );
// Check global permission:
if( empty($current_User) || ! $current_User->check_perm( 'admin', 'any' ) )
{ // No permission to access admin...
require $admintemplates_path. '_access_denied.main.php';
// fp> Does the following have an HTTP fallback when Javascript/AJ is not available?
// dh> yes, but not through this file..
// dh> IMHO it does not make sense to let the "normal controller" handle the AJAX call
// if there's something lightweight like calling "$UserSettings->param_Request()"!
// Hmm.. bad example (but valid). Better example: something like the actions below, which
// output only a small part of what the "real controller" does..
case 'add_plugin_sett_set':
// Add a Plugin(User)Settings set (for "array" type settings):
param( 'plugin_ID', 'integer', true );
$admin_Plugins = & get_Cache('Plugins_admin'); // use Plugins_admin, because a plugin might be disabled
$Plugin = & $admin_Plugins->get_by_ID($plugin_ID);
param( 'set_type', 'string', '' ); // "Settings" or "UserSettings"
if( $set_type != 'Settings' /* && $set_type != 'UserSettings' */ )
param( 'set_path', '/^\w+(?:\[\w+\])+$/', '' );
// Init the new setting set:
$Form = new Form(); // fake Form
case 'del_plugin_sett_set':
// TODO: may use validation here..
case 'admin_blogperms_set_layout':
// Save blog permission tab layout into user settings. This gets called on JS-toggling.
$UserSettings->param_Request( 'layout', 'blogperms_layout', 'string', $debug ? 'all' : 'default' ); // table layout mode
* Call the handler/dispatcher (it is a common handler for asynchronous calls -- both AJax calls and HTTP GET fallbacks)
require_once $inc_path. '_async.inc.php';
echo '-collapse='. $collapse;
|