Merge branch 'wip-mdl-48190-m27' of https://github.com/rajeshtaneja/moodle into MOODL...
[moodle.git] / portfolio / download / file.php
blobedd62bc5d124c73cfa77bc3af9f72e960974ea86
1 <?php
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
7 require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
9 if (empty($CFG->enableportfolios)) {
10 print_error('disabled', 'portfolio');
13 require_once($CFG->libdir.'/portfoliolib.php');
14 require_once($CFG->libdir.'/portfolio/exporter.php');
16 $id = required_param('id', PARAM_INT);
18 $PAGE->set_url('/portfolio/download/file.php', array('id' => $id));
20 $exporter = portfolio_exporter::rewaken_object($id);
21 portfolio_export_pagesetup($PAGE, $exporter->get('caller'));
22 $exporter->verify_rewaken();
24 $exporter->print_header(get_string('downloading', 'portfolio_download'), false);
25 $returnurl = $exporter->get('caller')->get_return_url();
26 echo $OUTPUT->notification('<a href="' . $returnurl . '">' . get_string('returntowhereyouwere', 'portfolio') . '</a><br />');
28 $PAGE->requires->js('/portfolio/download/helper.js');
29 $PAGE->requires->js_function_call('submit_download_form', null, true);
31 // if they don't have javascript, they can submit the form here to get the file.
32 // if they do, it does it nicely for them.
33 echo '<div id="redirect">
34 <form action="' . $exporter->get('instance')->get_base_file_url() . '" method="post" id="redirectform">
35 <input type="submit" value="' . get_string('downloadfile', 'portfolio_download') . '" />
36 </form>
38 echo $OUTPUT->footer();