linker.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * This file is part of SLOODLE Tracker.
  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 Tracker 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. * Peter R. Bloomfield
  21. * Julio Lopez (SL: Julio Solo)
  22. * Michael Callaghan (SL: HarmonyHill Allen)
  23. * Kerri McCusker (SL: Kerri Macchi)
  24. *
  25. * A project developed by the Serious Games and Virtual Worlds Group.
  26. * Intelligent Systems Research Centre.
  27. * University of Ulster, Magee
  28. */
  29. /**
  30. * Allows an activity tool in SecondLife to send the activity tracker to MOODLE
  31. * (Creates a new entry in the 'sloodle_activity_tracker' DB table.)
  32. *
  33. */
  34. // This script should be called with the following parameters:
  35. // sloodlemoduleid = ID of a SecondLife Tracker in MOODLE
  36. // sloodleobjuuid = UUID of the object
  37. // sloodleavuuid = UUID of the avatar
  38. //
  39. /** Lets Sloodle know we are in a linker script. */
  40. define('SLOODLE_LINKER_SCRIPT', true);
  41. /** Grab the Sloodle/Moodle configuration. */
  42. require_once('../../init.php');
  43. /** Include the Sloodle PHP API. */
  44. require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  45. // Authenticate the request, and load a tracker module
  46. $sloodle = new SloodleSession();
  47. $sloodle->authenticate_request();
  48. $sloodle->load_module(SLOODLE_TYPE_TRACKER, true);
  49. $tracker = $sloodle->module;
  50. // Authenticate the user
  51. $sloodle->validate_user(true);
  52. // Get the parameters
  53. $sloodletrackerid = $sloodle->request->required_param('sloodlemoduleid');
  54. $sloodleobjuuid = $sloodle->request->required_param('sloodleobjuuid');
  55. $sloodleavuuid = $sloodle->request->required_param('sloodleuuid');
  56. // Attempt to add this action to the database
  57. $authid = $tracker->record_action($sloodletrackerid,$sloodleobjuuid,$sloodleavuuid);
  58. // Was it successful?
  59. if ($authid) {
  60. $sloodle->response->set_status_code(1);
  61. $sloodle->response->set_status_descriptor('OK');
  62. $sloodle->response->add_data_line($authid);
  63. } else {
  64. $sloodle->response->set_status_code(-201);
  65. $sloodle->response->set_status_descriptor('OBJECT_AUTH');
  66. $sloodle->response->add_data_line('Failed to register the action.');
  67. }
  68. // Render the output
  69. $sloodle->response->render_to_output();
  70. ?>