MDL-27649 Convert the calculated question types to use the new variants mechanism.
[moodle.git] / portfolio / file.php
blobb9dbd5e93c7ec0ba0c092bb23643715b9ac49701
1 <?php
2 /**
3 * Moodle - Modular Object-Oriented Dynamic Learning Environment
4 * http://moodle.org
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/>.
20 * @package moodle
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 . '/portfolio/exporter.php');
38 require_once($CFG->libdir . '/filelib.php');
40 // exporter id
41 $id = required_param('id', PARAM_INT);
43 require_login();
44 $PAGE->set_url('/portfolio/add.php', array('id' => $id));
46 $exporter = portfolio_exporter::rewaken_object($id);
47 $exporter->verify_rewaken();
49 // push plugins don't need to access this script.
50 if ($exporter->get('instance')->is_push()) {
51 throw new portfolio_export_exception($exporter, 'filedenied', 'portfolio');
54 // it's up to the plugin to verify the request parameters, like a token or whatever
55 if (!$exporter->get('instance')->verify_file_request_params(array_merge($_GET, $_POST))) {
56 throw new portfolio_export_exception($exporter, 'filedenied', 'portfolio');
59 // ok, we're good, send the file and finish the export.
60 $exporter->get('instance')->send_file();
61 $exporter->process_stage_cleanup(true);
62 exit;