3 * Moodle - Modular Object-Oriented Dynamic Learning Environment
5 * Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * @subpackage portfolio
22 * @author Penny Leach <penny@catalyst.net.nz>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
24 * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
26 * For portfolio plugins that are 'pull' - ie, send the request and then wait
27 * for the remote system to request the file for moodle,
28 * this is the script that serves up the export file to them.
30 require_once(dirname(dirname(__FILE__)) . '/config.php');
32 if (empty($CFG->enableportfolios)) {
33 print_error('disabled', 'portfolio');
36 require_once($CFG->libdir . '/portfoliolib.php');
37 require_once($CFG->libdir . '/file/stored_file.php');
38 require_once($CFG->libdir . '/filelib.php');
41 $id = required_param('id', PARAM_INT);
45 $exporter = portfolio_exporter::rewaken_object($id);
46 $exporter->verify_rewaken();
48 // push plugins don't need to access this script.
49 if ($exporter->get('instance')->is_push()) {
50 throw new portfolio_export_exception($exporter, 'filedenied', 'portfolio');
53 // it's up to the plugin to verify the request parameters, like a token or whatever
54 if (!$exporter->get('instance')->verify_file_request_params(array_merge($_GET, $_POST))) {
55 throw new portfolio_export_exception($exporter, 'filedenied', 'portfolio');
58 // ok, we're good, send the file and finish the export.
59 $exporter->get('instance')->send_file();
60 $exporter->process_stage_cleanup(true);