"MDL-23690, fixed set_context error, credits to Penny"
[moodle.git] / portfolio / download / file.php
blob2a82df382b18461e6fbd817f36eb7f02aa111d0d
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 $PAGE->requires->yui2_lib('dom');
17 $id = required_param('id', PARAM_INT);
19 $PAGE->set_url('/portfolio/download/file.php', array('id' => $id));
21 $exporter = portfolio_exporter::rewaken_object($id);
22 portfolio_export_pagesetup($PAGE, $exporter->get('caller'));
23 $exporter->verify_rewaken();
25 $exporter->print_header(get_string('downloading', 'portfolio_download'), false);
26 $returnurl = $exporter->get('caller')->get_return_url();
27 echo $OUTPUT->notification('<a href="' . $returnurl . '">' . get_string('returntowhereyouwere', 'portfolio') . '</a><br />');
29 $PAGE->requires->js('/portfolio/download/helper.js');
30 $PAGE->requires->js_function_call('submit_download_form', null, true);
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.
34 echo '<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>
39 echo $OUTPUT->footer();