Source for file sl_distrib_channel_linker.php

Documentation is available at sl_distrib_channel_linker.php

  1. <?php
  2.     
  3.     /**
  4.     * Sloodle object distribution channel linker.
  5.     *
  6.     * Allows an in-world Sloodle Object Distributor object to send object distribution information to the Moodle database (including inventory list).
  7.     *
  8.     * @package sloodledistrib
  9.     * @copyright Copyright (c) 2006-8 Sloodle (various contributors)
  10.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  11.     *
  12.     * @contributor Edmund Edgar
  13.     * @contributor Peter R. Bloomfield
  14.     *
  15.     */
  16.     
  17.     // Expected to be called from in-world by an LSL script.
  18.     // The following parameters are required:
  19.     //
  20.     //   sloodlepwd = the prim password used to authenticate the request
  21.     //   sloodlechannel = specifies the UUID of the XMLRPC channel on which the object is listening
  22.     //   sloodlecontents = a pipe-delimited list of inventory items
  23.     //
  24.     
  25.     // On successful storage of channel, status code 1 is returned.
  26.     // On failure to set channel, status code error code -101 is returned.
  27.     // If a required parameter was not specified, error code -811 is returned.
  28.  
  29.     require_once('../config.php');
  30.     require_once(SLOODLE_DIRROOT.'/sl_debug.php');
  31.     require_once(SLOODLE_DIRROOT.'/lib/sl_lsllib.php');
  32.     
  33.     // Create an LSL handler and process the basic request data
  34.     sloodle_debug_output('Creating LSL handler...<br/>');
  35.     $lsl new SloodleLSLHandler();
  36.     sloodle_debug_output('Processing basic request data...<br/>');
  37.     $lsl->request->process_request_data();
  38.     
  39.     // Ensure the request is authenticated
  40.     sloodle_debug_output('Authenticating request...<br/>');
  41.     $lsl->request->authenticate_request();
  42.     
  43.     // Obtain our additional parameters
  44.     sloodle_debug_output('Obtaining additional parameters...<br/>');
  45.     $sloodlechannel $lsl->request->required_param('sloodlechannel'PARAM_RAW);
  46.     $sloodlecontents $lsl->request->required_param('sloodlecontents'PARAM_RAW);
  47.     
  48.     $result TRUE;
  49.     
  50.     // Attempt to set the channel in the configuration settings
  51.     sloodle_debug_output('Storing distribution channel...<br/>');
  52.     if (sloodle_set_config('sloodle_distrib_channel'$sloodlechannel)) {
  53.         // Success
  54.         sloodle_debug_output('-&gt; Success.<br/>');
  55.     else {
  56.         // Failed
  57.         sloodle_debug_output('-&gt; Failed.<br/>');
  58.         $lsl->response->set_add_data_line('Failed to store object distribution XMLRPC channel in Moodle configuration table.');
  59.         $result FALSE;
  60.     }
  61.     
  62.     // Attempt to store the contents in the configuration settings
  63.     sloodle_debug_output('Storing distribution contents...<br/>');
  64.     if (sloodle_set_config('sloodle_distrib_objects'$sloodlecontents)) {
  65.         // Success
  66.         sloodle_debug_output('-&gt; Success.<br/>');
  67.     else {
  68.         // Failed
  69.         sloodle_debug_output('-&gt; Failed.<br/>');
  70.         $lsl->response->set_add_data_line('Failed to store object distribution XMLRPC channel in Moodle configuration table.');
  71.         $result FALSE;
  72.     }
  73.     
  74.     // Construct the rest of the response
  75.     if ($result{
  76.         $lsl->response->set_status_code(1);
  77.         $lsl->response->set_status_descriptor('OK');
  78.     else {
  79.         $lsl->response->set_status_code(-101);
  80.         $lsl->response->set_status_descriptor('SYSTEM');
  81.     }
  82.     
  83.     // Render the output
  84.     sloodle_debug_output('Outputting response...<br/>');
  85.     sloodle_debug_output('<pre>');
  86.     $lsl->response->render_to_output();
  87.     sloodle_debug_output('</pre>');
  88.     
  89.     exit();
  90.  
  91. ?>

Documentation generated on Tue, 04 Mar 2008 15:08:39 +0000 by phpDocumentor 1.4.0