MDL-15777 more fixes for portfolio to use file api
[moodle.git] / portfolio / file.php
CommitLineData
d96a1acc 1<?php
2require_once(dirname(dirname(__FILE__)) . '/config.php');
3require_once($CFG->libdir . '/portfoliolib.php');
4require_once($CFG->libdir . '/file/stored_file.php');
5require_once($CFG->libdir . '/filelib.php');
6
7$id = required_param('id', PARAM_INT);
8
9$exporter = portfolio_exporter::rewaken_object($id);
10
11if ($exporter->get('instance')->is_push()) {
12 $exporter->raise_error('filedenied', 'portfolio');
13}
14
15if (!$exporter->get('instance')->verify_file_request_params(array_merge($_GET, $_POST))) {
16 $exporter->raise_error('filedenied', 'portfolio');
17}
18
19$file = $exporter->get('instance')->get('file');
20if (!($file instanceof stored_file)) {
21 $exporter->raise_error('filenotfound', 'portfolio');
22}
23
24send_stored_file($file, 0, 0, true, null, true);
25$exporter->process_stage_cleanup(true);
26
27?>