b2evolution PHP Cross Reference Blogging Systems

Source: /htsrv/call_plugin.php - 93 lines - 3014 bytes - Text - Print

Description: This file gets used to access {@link Plugin} methods that are marked to be accessible this way. See {@link Plugin::GetHtsrvMethods()}. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file gets used to access {@link Plugin} methods that are marked to be accessible this
   4   * way. See {@link Plugin::GetHtsrvMethods()}.
   5   *
   6   * This file is part of the evoCore framework - {@link http://evocore.net/}
   7   * See also {@link http://sourceforge.net/projects/evocms/}.
   8   *
   9   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
  10   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  11   *
  12   * {@internal License choice
  13   * - If you have received this file as part of a package, please find the license.txt file in
  14   *   the same folder or the closest folder above for complete license terms.
  15   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  16   *   then you must choose one of the following licenses before using the file:
  17   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  18   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  19   * }}
  20   *
  21   * {@internal Open Source relicensing agreement:
  22   * Daniel HAHLER grants Francois PLANQUE the right to license
  23   * Daniel HAHLER's contributions to this file and the b2evolution project
  24   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  25   * }}
  26   *
  27   * @package htsrv
  28   *
  29   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  30   * @author fplanque: Francois PLANQUE
  31   * @author blueyed: Daniel HAHLER
  32   *
  33   * @version $Id: call_plugin.php 6136 2014-03-08 07:59:48Z manuel $
  34   */
  35  
  36  
  37  /**
  38   * Initialize:
  39   * TODO: Don't do a full init!
  40   */
  41  require_once dirname(__FILE__).'/../conf/_config.php';
  42  require_once $inc_path.'_main.inc.php';
  43  
  44  
  45  param( 'plugin_ID', 'integer', true );
  46  // fp> it is probably unnecessary complexity to handle a method here
  47  // instead of calling handle_htsrv_action() all the time
  48  // and letting the plugin deal with its methods internally.
  49  param( 'method', 'string', '' );
  50  param( 'params', 'string', null ); // serialized
  51  
  52  if( is_null($params) )
  53  { // Default:
  54      $params = array();
  55  }
  56  else
  57  { // params given. This may result in "false", but this means that unserializing failed.
  58      $params = @unserialize($params);
  59  }
  60  
  61  
  62  if( $plugin_ID )
  63  {
  64      $Plugin = & $Plugins->get_by_ID( $plugin_ID );
  65  
  66      if( ! $Plugin )
  67      {
  68          bad_request_die( 'Invalid Plugin! (maybe not enabled?)' );
  69      }
  70  
  71  
  72      if( method_exists( $Plugin, 'get_htsrv_methods' ) )
  73      { // TODO: get_htsrv_methods is deprecated, but should stay here for transformation! (blueyed, 2006-04-27)
  74          if( ! in_array( $method, $Plugin->get_htsrv_methods() ) )
  75          {
  76              bad_request_die( 'Call to non-htsrv Plugin method!' );
  77          }
  78      }
  79      else
  80      if( ! in_array( $method, $Plugin->GetHtsrvMethods() ) )
  81      {
  82          bad_request_die( 'Call to non-htsrv Plugin method!' );
  83      }
  84      elseif( ! method_exists( $Plugin, 'htsrv_'.$method ) )
  85      {
  86          bad_request_die( 'htsrv method does not exist!' );
  87      }
  88  
  89      // Call the method:
  90      $Plugins->call_method( $Plugin->ID, 'htsrv_'.$method, $params );
  91  }
  92  
  93  ?>

title

Description

title

Description

title

Description

title

title

Body