MDL-15666 - change all the portfolio plugins and callers to use exceptions
[moodle.git] / portfolio / type / mahara / preconfig.php
CommitLineData
254f2d05 1<?php
2require_once(dirname(dirname(dirname(dirname(__FILE__)))). '/config.php');
3require_once($CFG->libdir . '/portfoliolib.php');
4require_once($CFG->dirroot . '/mnet/lib.php');
5
6if (!$landed = optional_param('landed', false, PARAM_BOOL)) {
7 $id = required_param('id', PARAM_INT);
8 $exporter = portfolio_exporter::rewaken_object($id);
9 $exporter->verify_rewaken();
10
11 $mnetauth = get_auth_plugin('mnet');
12 if (!$url = $mnetauth->start_jump_session($exporter->get('instance')->get_config('mnethostid'), '/portfolio/type/mahara/preconfig.php?landed=1', true)) {
13 throw new porfolio_exception('failedtojump', 'portfolio_mahara');
14 }
15 redirect($url);
16} else {
17 // now we have the sso session set up, start sending intent stuff and then redirect back to portfolio/add.php when we're done
18 $exporter = portfolio_exporter::rewaken_object($SESSION->portfolioexport);
19 $exporter->verify_rewaken();
20
21 $exporter->get('instance')->send_intent();
22 redirect($CFG->wwwroot . '/portfolio/add.php?postcontrol=1&id=' . $exporter->get('id'));
23}
24?>