Source for file version_linker.php

Documentation is available at version_linker.php

  1. <?php
  2. // This file is part of the Sloodle project (www.sloodle.org)
  3.  
  4. /**
  5. * Version linker script, to allow in-world tools to check the Sloodle version information
  6. *
  7. @package sloodle
  8. @copyright Copyright (c) 2007-8 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. // If called without any parameters, this script will return version info.
  16. // If successful in checking version information, this script will return
  17. //  with status code 1, and the data line will contain 2 fields.
  18. // The first data field will be the Sloodle version (e.g. 0.2), and the
  19. //  second will be the module verison (e.g. 2008020501).
  20. // For example:
  21. //
  22. //  1
  23. //  0.2|2008013101
  24.  
  25. // If an error occurs, then an appropriate standard status code will be given
  26. //  and a message should be given in the status line.
  27.  
  28. // FUTURE WORK: the ability to query compatibility with a particular tool
  29. //  version may implemented at some point. This will require a request
  30. //  parameter, and will likely return "true" or "false" on the data line.
  31.  
  32.  
  33. /** Sloodle/Moodle configuration information. */
  34. require_once('config.php');
  35. /** Sloodle debugging. */
  36. require_once(SLOODLE_DIRROOT.'/sl_debug.php');
  37. /** Sloodle LSL handling library. */
  38. require_once(SLOODLE_DIRROOT.'/lib/sl_lsllib.php');
  39.  
  40. // Process the request
  41. sloodle_debug_output('Processing request...<br/>');
  42. $lsl new SloodleLSLHandler();
  43. $lsl->request->process_request_data();
  44.  
  45. // Check the installed Sloodle version
  46. sloodle_debug_output('Checking for installed Sloodle version...<br/>');
  47. $moduleinfo get_record('modules''name''sloodle');
  48. if (!$moduleinfo{
  49.  sloodle_debug_output('ERROR: Sloodle not installed<br/>');
  50.  $lsl->response->set_status_code(-106);
  51.  $lsl->response->set_status_descriptor('SYSTEM');
  52.  $lsl->response->add_data_line('The Sloodle module is not installed on this Moodle site.');
  53.  $lsl->response->render_to_output();
  54.  exit();
  55. }
  56.  
  57. // Extract the module version number
  58. $moduleversion = (string)$moduleinfo->version;
  59. sloodle_debug_output('Sloodle version: '.(string)SLOODLE_VERSION.'<br/>');
  60. sloodle_debug_output("Module version: $moduleversion<br/>");
  61.  
  62. // Construct and render the response
  63. sloodle_debug_output('Rendering response...<br/>');
  64. $lsl->response->set_status_code(1);
  65. $lsl->response->set_status_descriptor('OK');
  66. $lsl->response->add_data_line(array((string)SLOODLE_VERSION$moduleversion));
  67. sloodle_debug_output('<br/><pre>');
  68. $lsl->response->render_to_output();
  69.  
  70. exit();
  71.  
  72. ?>

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