Merge branch 'MDL-33294' of git://github.com/danpoltawski/moodle
[moodle.git] / portfolio / download / file.php
CommitLineData
abcd0fc5 1<?php
2
4c7a4ef9 3// this script is a slightly more user friendly way to 'send' the file to them
4// (using portfolio/file.php) but still give them the 'return to where you were' link
5// to go back to their assignment, or whatever
6
edf1fc35 7require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
add560f3 8
9if (empty($CFG->enableportfolios)) {
10 print_error('disabled', 'portfolio');
11}
12
214b1cf7 13require_once($CFG->libdir.'/portfoliolib.php');
24ba58ee
PL
14require_once($CFG->libdir.'/portfolio/exporter.php');
15
f44b10ed 16$PAGE->requires->yui2_lib('dom');
abcd0fc5 17$id = required_param('id', PARAM_INT);
18
edf1fc35 19$PAGE->set_url('/portfolio/download/file.php', array('id' => $id));
add560f3 20
abcd0fc5 21$exporter = portfolio_exporter::rewaken_object($id);
afba32dd 22portfolio_export_pagesetup($PAGE, $exporter->get('caller'));
abcd0fc5 23$exporter->verify_rewaken();
24
25$exporter->print_header(get_string('downloading', 'portfolio_download'), false);
26$returnurl = $exporter->get('caller')->get_return_url();
de2bd9df 27echo $OUTPUT->notification('<a href="' . $returnurl . '">' . get_string('returntowhereyouwere', 'portfolio') . '</a><br />');
abcd0fc5 28
edf1fc35 29$PAGE->requires->js('/portfolio/download/helper.js');
593f9b87 30$PAGE->requires->js_function_call('submit_download_form', null, true);
0503e887 31
4c7a4ef9 32// if they don't have javascript, they can submit the form here to get the file.
33// if they do, it does it nicely for them.
abcd0fc5 34echo '<div id="redirect">
35 <form action="' . $exporter->get('instance')->get_base_file_url() . '" method="post" id="redirectform">
36 <input type="submit" value="' . get_string('downloadfile', 'portfolio_download') . '" />
37 </form>
0503e887 38';
e6e565ab 39echo $OUTPUT->footer();
abcd0fc5 40
4317f92f 41