preconfig.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * This file is the landing point for returning to moodle after authenticating at mahara
  18. *
  19. * @since Moodle 2.0
  20. * @package moodlecore
  21. * @subpackage portfolio
  22. * @copyright 2009 Penny Leach
  23. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24. */
  25. require_once(__DIR__ . '/../../config.php');
  26. if (empty($CFG->enableportfolios)) {
  27. print_error('disabled', 'portfolio');
  28. }
  29. require_once($CFG->libdir . '/portfoliolib.php');
  30. require_once($CFG->libdir . '/portfolio/plugin.php');
  31. require_once($CFG->libdir . '/portfolio/exporter.php');
  32. require_once($CFG->dirroot . '/mnet/lib.php');
  33. require_login();
  34. $id = required_param('id', PARAM_INT); // id of current export
  35. $landed = optional_param('landed', false, PARAM_BOOL); // this is the parameter we get back after we've jumped to mahara
  36. if (!$landed) {
  37. $exporter = portfolio_exporter::rewaken_object($id);
  38. $exporter->verify_rewaken();
  39. $mnetauth = get_auth_plugin('mnet');
  40. if (!$url = $mnetauth->start_jump_session($exporter->get('instance')->get_config('mnethostid'), '/portfolio/mahara/preconfig.php?landed=1&id=' . $id, true)) {
  41. throw new porfolio_exception('failedtojump', 'portfolio_mahara');
  42. }
  43. redirect($url);
  44. } else {
  45. // now we have the sso session set up, start sending intent stuff and then redirect back to portfolio/add.php when we're done
  46. $exporter = portfolio_exporter::rewaken_object($id);
  47. $exporter->verify_rewaken();
  48. $exporter->get('instance')->send_intent();
  49. redirect($CFG->wwwroot . '/portfolio/add.php?postcontrol=1&sesskey=' . sesskey() . '&id=' . $id);
  50. }