2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * For portfolio plugins that are 'pull' - ie, send the request and then wait
19 * for the remote system to request the file for moodle,
20 * this is the script that serves up the export file to them.
22 * @package core_portfolio
23 * @copyright 2008 Penny Leach <penny@catalyst.net.nz>,
24 * Martin Dougiamas <http://dougiamas.com>
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require_once(__DIR__
. '/../config.php');
29 if (empty($CFG->enableportfolios
)) {
30 print_error('disabled', 'portfolio');
33 require_once($CFG->libdir
. '/portfoliolib.php');
34 require_once($CFG->libdir
. '/portfolio/exporter.php');
35 require_once($CFG->libdir
. '/filelib.php');
38 $id = required_param('id', PARAM_INT
);
41 $PAGE->set_url('/portfolio/add.php', array('id' => $id));
43 $exporter = portfolio_exporter
::rewaken_object($id);
44 $exporter->verify_rewaken();
46 // push plugins don't need to access this script.
47 if ($exporter->get('instance')->is_push()) {
48 throw new portfolio_export_exception($exporter, 'filedenied', 'portfolio');
51 // it's up to the plugin to verify the request parameters, like a token or whatever
52 if (!$exporter->get('instance')->verify_file_request_params(array_merge($_GET, $_POST))) {
53 throw new portfolio_export_exception($exporter, 'filedenied', 'portfolio');
56 // ok, we're good, send the file and finish the export.
57 $exporter->get('instance')->send_file();
58 $exporter->process_stage_cleanup(true);