Merge branch 'MDL-68565' of https://github.com/paulholden/moodle
[moodle.git] / portfolio / mahara / preconfig.php
CommitLineData
254f2d05 1<?php
de260e0f
PL
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
18/**
19 * This file is the landing point for returning to moodle after authenticating at mahara
20 *
5bcfd504 21 * @since Moodle 2.0
de260e0f
PL
22 * @package moodlecore
23 * @subpackage portfolio
24 * @copyright 2009 Penny Leach
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 */
1fcf0ca8 27require_once(__DIR__ . '/../../config.php');
add560f3 28
29if (empty($CFG->enableportfolios)) {
30 print_error('disabled', 'portfolio');
31}
32
254f2d05 33require_once($CFG->libdir . '/portfoliolib.php');
24ba58ee
PL
34require_once($CFG->libdir . '/portfolio/plugin.php');
35require_once($CFG->libdir . '/portfolio/exporter.php');
254f2d05 36require_once($CFG->dirroot . '/mnet/lib.php');
37
add560f3 38require_login();
39
557b2a3b
PL
40$id = required_param('id', PARAM_INT); // id of current export
41$landed = optional_param('landed', false, PARAM_BOOL); // this is the parameter we get back after we've jumped to mahara
42
43if (!$landed) {
254f2d05 44 $exporter = portfolio_exporter::rewaken_object($id);
45 $exporter->verify_rewaken();
46
47 $mnetauth = get_auth_plugin('mnet');
edf1fc35 48 if (!$url = $mnetauth->start_jump_session($exporter->get('instance')->get_config('mnethostid'), '/portfolio/mahara/preconfig.php?landed=1&id=' . $id, true)) {
254f2d05 49 throw new porfolio_exception('failedtojump', 'portfolio_mahara');
50 }
51 redirect($url);
52} else {
53 // now we have the sso session set up, start sending intent stuff and then redirect back to portfolio/add.php when we're done
557b2a3b 54 $exporter = portfolio_exporter::rewaken_object($id);
254f2d05 55 $exporter->verify_rewaken();
56
57 $exporter->get('instance')->send_intent();
89223416 58 redirect($CFG->wwwroot . '/portfolio/add.php?postcontrol=1&sesskey=' . sesskey() . '&id=' . $id);
254f2d05 59}
4317f92f 60