6c1a4b8690395f4d005891f80995774d0f7fb034
[moodle.git] / portfolio / download / file.php
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');
11 }
13 require_once($CFG->libdir.'/portfoliolib.php');
14 $PAGE->requires->yui_lib('dom');
15 $id = required_param('id', PARAM_INT);
17 require_login();
18 $PAGE->set_url('/portfolio/download/file.php', array('id' => $id));
20 $exporter = portfolio_exporter::rewaken_object($id);
21 $exporter->verify_rewaken();
23 $exporter->print_header(get_string('downloading', 'portfolio_download'), false);
24 $returnurl = $exporter->get('caller')->get_return_url();
25 echo $OUTPUT->notification('<a href="' . $returnurl . '">' . get_string('returntowhereyouwere', 'portfolio') . '</a><br />');
27 $PAGE->requires->js('/portfolio/download/helper.js');
28 $PAGE->requires->js_function_call('submit_download_form')->on_dom_ready();
30 // if they don't have javascript, they can submit the form here to get the file.
31 // if they do, it does it nicely for them.
32 echo '<div id="redirect">
33     <form action="' . $exporter->get('instance')->get_base_file_url() . '" method="post" id="redirectform">
34       <input type="submit" value="' . get_string('downloadfile', 'portfolio_download') . '" />
35     </form>
36 ';
37 echo $OUTPUT->footer();