phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Source for file async.php

Documentation is available at async.php

  1. <?php
  2. /**
  3.  * This is the handler for asynchronous 'AJAX' calls.
  4.  *
  5.  * This file is part of Quam Plures - {@link http://quamplures.net/}
  6.  * See also {@link https://launchpad.net/quam-plures}.
  7.  *
  8.  * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
  9.  * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
  10.  *
  11.  *  {@internal License choice
  12.  *  - If you have received this file as part of a package, please find the license.txt file in
  13.  *    the same folder or the closest folder above for complete license terms.
  14.  *  - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15.  *    then you must choose one of the following licenses before using the file:
  16.  *    - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17.  *    - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18.  *  }}}
  19.  *
  20.  *  {@internal Open Source relicensing agreement:
  21.  *  }}}
  22.  *
  23.  * @package pond
  24.  */
  25.  
  26.  
  27. /**
  28.  * Do the MAIN initializations:
  29.  */
  30. require_once dirname(__FILE__).'/../qp_config/_config.php';
  31.  
  32. /**
  33.  * HEAVY :(
  34.  *
  35.  * TODO (legacy) dh> refactor _main.inc.php to be able to include small parts
  36.  *           (e.g. $current_User, charset init, ...) only..
  37.  *           It worked already for $DB (_connect_db.inc.php).
  38.  * fp> I think I'll try _core_main.inc , _evo_main.inc , _blog_main.inc ; this file would only need _core_main.inc
  39.  */
  40. require_once $inc_path.'_main.inc.php';
  41.  
  42. param'action''string''' );
  43.  
  44. // Check global permission:
  45. ifempty($current_User|| $current_User->check_perm'admin''any' ) )
  46. {    // No permission to access admin...
  47.     require $admintemplates_path.'_access_denied.main.php';
  48. }
  49.  
  50.  
  51.  
  52.  
  53. // fp> Does the following have an HTTP fallback when Javascript/AJ is not available?
  54. // dh> yes, but not through this file..
  55. // dh> IMHO it does not make sense to let the "normal controller" handle the AJAX call
  56. //     if there's something lightweight like calling "$UserSettings->param_Request()"!
  57. //     Hmm.. bad example (but valid). Better example: something like the actions below, which
  58. //     output only a small part of what the "real controller" does..
  59. switch$action )
  60. {
  61.     case 'add_plugin_sett_set':
  62.         // Add a Plugin(User)Settings set (for "array" type settings):
  63.         header_content_type'text/html' )// sets charset
  64.  
  65.         param'plugin_ID''integer'true );
  66.  
  67.         $admin_Plugins get_Cache('Plugins_admin')// use Plugins_admin, because a plugin might be disabled
  68.         $Plugin $admin_Plugins->get_by_ID($plugin_ID);
  69.         if$Plugin )
  70.         {
  71.             bad_request_die('Invalid Plugin.');
  72.         }
  73.         param'set_type''string''' )// "Settings" or "UserSettings"
  74.         if$set_type != 'Settings' /* && $set_type != 'UserSettings' */ )
  75.         {
  76.             bad_request_die('Invalid set_type param!');
  77.         }
  78.         param'set_path''/^\w+(?:\[\w+\])+$/''' );
  79.  
  80.         load_funcs('plugins/_plugin.funcs.php');
  81.  
  82.         // Init the new setting set:
  83.         _set_setting_by_path$Plugin$set_type$set_patharray() );
  84.  
  85.         $r get_plugin_settings_node_by_path$Plugin$set_type$set_path/* create: */ false );
  86.  
  87.         $Form new Form()// fake Form
  88.         autoform_display_field$set_path$r['set_meta']$Form$set_type$PluginNULL$r['set_node');
  89.         exit(0);
  90.  
  91.     case 'del_plugin_sett_set':
  92.         // TODO: may use validation here..
  93.         echo 'OK';
  94.         exit(0);
  95.  
  96.     case 'admin_blogperms_set_layout':
  97.         // Save blog permission tab layout into user settings. This gets called on JS-toggling.
  98.         $UserSettings->param_Request'layout''blogperms_layout''string'$debug 'all' 'default' );  // table layout mode
  99.         exit(0);
  100.  
  101. }
  102.  
  103.  
  104.  
  105. /**
  106.  * Call the handler/dispatcher (it is a common handler for asynchronous calls -- both AJax calls and HTTP GET fallbacks)
  107.  */
  108. require_once $inc_path.'_async.inc.php';
  109.  
  110.  
  111. // Debug info:
  112. echo '-expand='.$expand;
  113. echo '-collapse='.$collapse;
  114.  
  115. ?>