Source for file course_info_linker.php

Documentation is available at course_info_linker.php

  1. <?php
  2.     /**
  3.     * Course information linker.
  4.     * Allows objects in-world to query for information about a particular course.
  5.     *
  6.     * @package sloodleclassroom
  7.     * @copyright Copyright (c) 2008 Sloodle (various contributors)
  8.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  9.     *
  10.     * @contributor Peter R. Bloomfield
  11.     *
  12.     */
  13.     
  14.     // The following parameters are required:
  15.     //
  16.     //  sloodlecontrollerid = the ID of the controller through which the current object may access Sloodle
  17.     //  sloodlepwd = the prim password or object-specific session key to authenticate access
  18.     //
  19.     // If everything is OK, the script will return status code, with the following information on the data lines:
  20.     //  coursename_short|coursename_full
  21.     //  autoreg_enabled|autoenrol_enabled
  22.     //
  23.     // The information will relate to whatever course the accessed controller belongs to.
  24.     // (This is for security, to ensure course data cannot be retrieved unauthorised).
  25.     // The autoreg and autoenrol values will be 0 or 1, indicate whether each feature is disabled or enabled on the course.
  26.     
  27.     
  28.     /** Lets Sloodle know we are in a linker script. */
  29.     define('SLOODLE_LINKER_SCRIPT'true);
  30.     
  31.     /** Grab the Sloodle/Moodle configuration. */
  32.     require_once('../sl_config.php');
  33.     /** Include the Sloodle PHP API. */
  34.     require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  35.     
  36.     // Authenticate the request
  37.     $sloodle new SloodleSession();
  38.     $sloodle->authenticate_request();
  39.     
  40.     // Make sure Sloodle is actually installed
  41.     $moduleinfo get_record('modules''name''sloodle');
  42.     if (!$moduleinfo{
  43.         sloodle_debug('ERROR: Sloodle not installed<br/>');
  44.         $sloodle->response->quick_output(-106'SYSTEM''The Sloodle module is not installed on this Moodle site.'false);
  45.         exit();
  46.     }
  47.     
  48.     // Check out autoreg and autoenrol settings
  49.     $autoreg '0';
  50.     $autoenrol '0';
  51.     if ($sloodle->course->check_autoreg()) $autoreg '1';
  52.     if ($sloodle->course->check_autoenrol()) $autoenrol '1';
  53.     
  54.     // Prepare the output
  55.     $sloodle->response->set_status_code(1);
  56.     $sloodle->response->set_status_descriptor('OK');
  57.     $sloodle->response->add_data_line(array($sloodle->course->get_short_name()$sloodle->course->get_full_name()));
  58.     $sloodle->response->add_data_line(array($autoreg$autoenrol));
  59.  
  60.     // Render the output
  61.     $sloodle->response->render_to_output();
  62.     exit();
  63. ?>

Documentation generated on Mon, 07 Jul 2008 12:32:24 +0100 by phpDocumentor 1.4.0