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

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