Source for file object_config_linker.php

Documentation is available at object_config_linker.php

  1. <?php
  2.     /**
  3.     * Sloodle object configuration linker.
  4.     *
  5.     * Allows objects in-world to download their configuration settings.
  6.     *
  7.     * @package sloodleclassroom
  8.     * @copyright Copyright (c) 2008 Sloodle (various contributors)
  9.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  10.     *
  11.     * @contributor Peter R. Bloomfield
  12.     *
  13.     */
  14.     
  15.     // This script should be called with the following parameters:
  16.     //
  17.     //  sloodlepwd = password for authentication
  18.     //  sloodleauthid = the object whose configuration is being downloaded
  19.     //
  20.     // The controller is identified by the object's authorisation.
  21.     // If succesful, status code 1 is returned, and each data line contains a name/value pair, like so:
  22.     //
  23.     //  1|OK
  24.     //  name|value
  25.     //
  26.     // Returns status code -103 if the object was not found or has not been configured yet.
  27.     //
  28.     
  29.     /** Grab the Sloodle/Moodle configuration. */
  30.     require_once('../sl_config.php');
  31.     /** Include the Sloodle PHP API. */
  32.     require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  33.     
  34.     // Start a new Sloodle session
  35.     $sloodle new SloodleSession();
  36.     
  37.     // Get the object ID
  38.     $sloodleauthid = (int)$sloodle->request->required_param('sloodleauthid');
  39.     $auth_obj SloodleController::get_object($sloodleauthid);
  40.     if (!$auth_obj{
  41.         $sloodle->response->quick_output(-103'SYSTEM''Object not found'false);
  42.         exit();
  43.     }
  44.     // Is the object authorised?
  45.     if ($auth_obj->course->controller->is_loaded(== false{
  46.         $sloodle->response->quick_output(-103'SYSTEM''Object not authorised'false);
  47.         exit();
  48.     }
  49.     
  50.     // Authenticate the request
  51.     $sloodle->course $auth_obj->course// The object doesn't know it's controller yet, but the database does.
  52.     $_REQUEST['sloodlecontrollerid'$auth_obj->course->controller->get_id();
  53.     $sloodle->authenticate_request();
  54.     
  55.     // Add a note of the controller and course names to the outgoing data
  56.     $sloodle->response->add_data_line(array('sloodlecontrollerid'$auth_obj->course->controller->get_id()));
  57.     $sloodle->response->add_data_line(array('sloodlecoursename_short'$auth_obj->course->get_short_name()));
  58.     $sloodle->response->add_data_line(array('sloodlecoursename_full'$auth_obj->course->get_short_name()));//$auth_obj->course->get_full_name())); // Shortened... was causing memory errors!
  59.     
  60.     // Fetch all the configuration settings
  61.     $settings get_records('sloodle_object_config''object'$sloodleauthid);
  62.     if (!$settings{
  63.         // Error: no configuration settings... there should be at least one indicating the type
  64.         $sloodle->response->quick_output(-103'SYSTEM''Object not configured yet.'false);
  65.         exit();
  66.     }
  67.     
  68.     // Output each setting
  69.     foreach ($settings as $s{
  70.         $sloodle->response->add_data_line(array($s->name$s->value));
  71.     }
  72.     
  73.     $sloodle->response->set_status_code(1);
  74.     $sloodle->response->set_status_descriptor('OK');
  75.     $sloodle->response->render_to_output();
  76.  
  77.     exit();
  78. ?>

Documentation generated on Fri, 17 Jul 2009 11:02:19 +0100 by phpDocumentor 1.4.0