auth_tool_linker.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. * Sloodle object authorization linker.
  31. * Allows authorised objects in SL to initiate the comunication
  32. * with a SLOODLE Second Life Tracker module.
  33. * (Creates a new entry in the 'sloodle_activity_tool' DB table.)
  34. */
  35. /** Lets Sloodle know we are in a linker script. */
  36. define('SLOODLE_LINKER_SCRIPT', true);
  37. /** Grab the Sloodle/Moodle configuration. */
  38. require_once('../../init.php');
  39. /** Include the Sloodle PHP API. */
  40. require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  41. // Attempt to authenticate the request (only require authentication if controller ID and/or password is set)
  42. // PRB: not sure why authentication is optional here -- should be required
  43. //$authrequired = (isset($_REQUEST['sloodlecontrollerid']) || isset($_REQUEST['sloodlepwd']));
  44. $sloodle = new SloodleSession();
  45. //$request_auth = $sloodle->authenticate_request($authrequired);
  46. $sloodle->authenticate_request();
  47. // Get the extra parameters
  48. $sloodleobjuuid = $sloodle->request->required_param('sloodleobjuuid');
  49. $sloodleobjname = $sloodle->request->required_param('sloodleobjname');
  50. $sloodleobjtype = $sloodle->request->required_param('sloodleobjtype', '');
  51. $sloodlemoduleid = $sloodle->request->required_param('sloodlemoduleid');
  52. $sloodledescription = $sloodle->request->required_param('sloodledescription');
  53. $sloodletaskname = $sloodle->request->required_param('sloodletaskname');
  54. // Create a SloodleModuleTracker instance and a new entry in the 'sloodle_activity_tool' DB table.
  55. $tracker = new SloodleModuleTracker($sloodle);
  56. $authid = $tracker->record_object($sloodleobjuuid,$sloodleobjname,$sloodleobjtype,$sloodlemoduleid,$sloodledescription,$sloodletaskname);
  57. if ($authid) {
  58. $sloodle->response->set_status_code(1);
  59. $sloodle->response->set_status_descriptor('OK');
  60. $sloodle->response->add_data_line($authid);
  61. } else {
  62. $sloodle->response->set_status_code(-201);
  63. $sloodle->response->set_status_descriptor('OBJECT_AUTH');
  64. $sloodle->response->add_data_line('Failed to register new active object.');
  65. }
  66. // Render the output
  67. $sloodle->response->render_to_output();
  68. ?>