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('sl_config.php');
  35. /** Sloodle API. */
  36. require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  37.  
  38. // Process the request
  39. sloodle_debug('Processing request...<br/>');
  40. $sloodle new SloodleSession();
  41.  
  42. // Check the installed Sloodle version
  43. sloodle_debug('Checking for installed Sloodle version...<br/>');
  44. $moduleinfo get_record('modules''name''sloodle');
  45. if (!$moduleinfo{
  46.  sloodle_debug('ERROR: Sloodle not installed<br/>');
  47.  $sloodle->response->quick_output(-106'SYSTEM''The Sloodle module is not installed on this Moodle site.'false);
  48.  exit();
  49. }
  50.  
  51. // Extract the module version number
  52. $moduleversion = (string)$moduleinfo->version;
  53. sloodle_debug('Sloodle version: '.(string)SLOODLE_VERSION.'<br/>');
  54. sloodle_debug("Module version: $moduleversion<br/>");
  55.  
  56. // Construct and render the response
  57. sloodle_debug('Rendering response...<br/>');
  58. $sloodle->response->set_status_code(1);
  59. $sloodle->response->set_status_descriptor('OK');
  60. $sloodle->response->add_data_line(array((string)SLOODLE_VERSION$moduleversion));
  61. sloodle_debug('<br/><pre>');
  62. $sloodle->response->render_to_output();
  63. sloodle_debug('</pre>');
  64.  
  65. exit();
  66.  
  67. ?>

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