file.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. // this script is a slightly more user friendly way to 'send' the file to them
  3. // (using portfolio/file.php) but still give them the 'return to where you were' link
  4. // to go back to their assignment, or whatever
  5. require(__DIR__.'/../../config.php');
  6. if (empty($CFG->enableportfolios)) {
  7. print_error('disabled', 'portfolio');
  8. }
  9. require_once($CFG->libdir.'/portfoliolib.php');
  10. require_once($CFG->libdir.'/portfolio/exporter.php');
  11. $id = required_param('id', PARAM_INT);
  12. $PAGE->set_url('/portfolio/download/file.php', array('id' => $id));
  13. $exporter = portfolio_exporter::rewaken_object($id);
  14. portfolio_export_pagesetup($PAGE, $exporter->get('caller'));
  15. $exporter->verify_rewaken();
  16. $exporter->print_header(get_string('downloading', 'portfolio_download'), false);
  17. $returnurl = $exporter->get('caller')->get_return_url();
  18. echo $OUTPUT->notification('<a href="' . $returnurl . '">' . get_string('returntowhereyouwere', 'portfolio') . '</a><br />');
  19. $PAGE->requires->js('/portfolio/download/helper.js');
  20. $PAGE->requires->js_function_call('submit_download_form', null, true);
  21. // if they don't have javascript, they can submit the form here to get the file.
  22. // if they do, it does it nicely for them.
  23. echo '<div id="redirect">
  24. <form action="' . $exporter->get('instance')->get_base_file_url() . '" method="post" id="redirectform">
  25. <input type="submit" value="' . get_string('downloadfile', 'portfolio_download') . '" />
  26. </form>
  27. ';
  28. echo $OUTPUT->footer();