Source for file linker.php

Documentation is available at linker.php

  1. <?php
  2.     /**
  3.     * Sloodle distributor linker (for Sloodle 0.3).
  4.     * Allows a Sloodle Vending Machine to update its inventory and XMLRPC channel details.
  5.     *
  6.     * @package sloodledistributor
  7.     * @copyright Copyright (c) 2007-8 Sloodle (various contributors)
  8.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  9.     *
  10.     * @contributor Edmund Edgar
  11.     * @contributor Peter R. Bloomfield
  12.     */
  13.     
  14.     // This script should be called with the following parameters:
  15.     //  sloodlecontrollerid = ID of a Sloodle Controller through which to access Moodle
  16.     //  sloodlepwd = the prim password or object-specific session key to authenticate the request
  17.     //  sloodlemoduleid = ID of a chatroom
  18.     //  sloodleinventory = a pipe-separated list of names of items in the obect's inventory
  19.     //  sloodlechannel = the UUID of an XMLRPC channel which can be used to request object distribution
  20.     //
  21.     // The following parameter is optional:
  22.     //  sloodledebug = if 'true', then Sloodle debugging mode is activated    
  23.     
  24.  
  25.     /** Lets Sloodle know we are in a linker script. */
  26.     define('SLOODLE_LINKER_SCRIPT'true);
  27.     
  28.     /** Grab the Sloodle/Moodle configuration. */
  29.     require_once('../../sl_config.php');
  30.     /** Include the Sloodle PHP API. */
  31.     require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  32.     
  33.     // Authenticate the request, and load a chat module
  34.     $sloodle new SloodleSession();
  35.     $sloodle->authenticate_request();
  36.     $sloodle->load_module('distributor'true);
  37.     
  38.     // Fetch the required additional parameters
  39.     $sloodleinventory $sloodle->request->required_param('sloodleinventory');
  40.     $sloodlechannel $sloodle->request->required_param('sloodlechannel');
  41.     
  42.     // Attempt to update the inventory
  43.     $objects explode('|'$sloodleinventory);
  44.     if (!$sloodle->module->set_objects($objects)) {
  45.         // Update failed
  46.         $sloodle->response->quick_output(-101'SYSTEM''Failed to update list of objects'false);
  47.         exit();
  48.     }
  49.     
  50.     // Attempt to update the channel
  51.     if (!$sloodle->module->set_channel($sloodlechannel)) {
  52.         // Update failed
  53.         $sloodle->response->quick_output(-101'SYSTEM''Failed to update XMLRPC channel UUID'false);
  54.         exit();
  55.     }
  56.     
  57.     // Everything seems fine
  58.     $sloodle->response->set_status_code(1);
  59.     $sloodle->response->set_status_descriptor('OK');
  60.     
  61.     // Output our response
  62.     $sloodle->response->render_to_output();
  63.     
  64. ?>

Documentation generated on Fri, 17 Jul 2009 11:01:39 +0100 by phpDocumentor 1.4.0