linker.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * This file is part of SLOODLE Interaction Objects.
  4. * Copyright (c) 2009 Sloodle
  5. *
  6. * SLOODLE Tracker is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * SLOODLE is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License.
  17. * If not, see <http://www.gnu.org/licenses/>
  18. *
  19. * Contributors:
  20. * Edmund Edgar
  21. * Peter R. Bloomfield
  22. * Paul Preibisch
  23. *
  24. /**
  25. *
  26. *
  27. */
  28. // This script should be called with the following parameters:
  29. // sloodlemoduleid = ID of a SecondLife Tracker in MOODLE
  30. // sloodleobjuuid = UUID of the object
  31. // sloodleavuuid = UUID of the avatar
  32. //
  33. /** Lets Sloodle know we are in a linker script. */
  34. define('SLOODLE_LINKER_SCRIPT', true);
  35. /** Grab the Sloodle/Moodle configuration. */
  36. require_once('../../init.php');
  37. /** Include the Sloodle PHP API. */
  38. require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  39. // Authenticate the request, and load a tracker module
  40. $sloodle_session = new SloodleSession();
  41. $sloodle_session->authenticate_request();
  42. // Authenticate the user
  43. $sloodle_session->validate_user(true);
  44. $sloodle_session->user->login();
  45. $task = optional_param('task', 'default', PARAM_TEXT);
  46. // If the config for this object specifies something that we haven't done, this will return an error to the calling LSL script and exit.
  47. $sloodle_session->validate_requirements($task,1);
  48. $ok = $sloodle_session->process_interaction($task, 1);
  49. // Was it successful?
  50. if ($ok) {
  51. $sloodle_session->response->set_status_code(1);
  52. $sloodle_session->response->set_status_descriptor('OK');
  53. $sloodle_session->response->add_data_line($task);
  54. } else {
  55. $sloodle_session->response->set_status_code(-201);
  56. $sloodle_session->response->set_status_descriptor('OBJECT_AUTH');
  57. $sloodle_session->response->add_data_line('Failed to register the action.');
  58. }
  59. // Render the output
  60. $sloodle_session->response->render_to_output();
  61. ?>