MDL-16232 - fix bad link in portfolio breadcrumbs
[moodle.git] / portfolio / type / download / lib.php
CommitLineData
67a87e7d 1<?php
2
3require_once($CFG->libdir . '/portfoliolib.php');
d96a1acc 4require_once($CFG->libdir . '/packer/zip_packer.php');
67a87e7d 5
d96a1acc 6class portfolio_plugin_download extends portfolio_plugin_pull_base {
67a87e7d 7
67a87e7d 8 protected $exportconfig;
9
67a87e7d 10 public static function allows_multiple() {
11 return false;
12 }
13
14 public function expected_time($callertime) {
15 return PORTFOLIO_TIME_LOW;
16 }
17
d67bfc32 18 public function prepare_package() {
67a87e7d 19
d96a1acc 20 $files = $this->exporter->get_tempfiles();
21 $zipper = new zip_packer();
67a87e7d 22
d96a1acc 23 $filename = 'portfolio-export.zip';
24 if ($newfile = $zipper->archive_to_storage($files, SYSCONTEXTID, 'portfolio_exporter', $this->exporter->get('id'), '/final/', $filename, $this->user->id)) {
25 $this->set('file', $newfile);
26 return true;
27 }
28 return false;
67a87e7d 29 }
30
31 public function send_package() {
32 return true;
33 }
34
35 public function get_extra_finish_options() {
36 global $CFG;
d96a1acc 37 return array($CFG->wwwroot . '/portfolio/file.php?id=' . $this->exporter->get('id') => get_string('downloadfile', 'portfolio_download'));
67a87e7d 38 }
39
d96a1acc 40 public function verify_file_request_params($params) {
41 // for download plugin the only thing we need to verify is that
42 // the logged in user is the same as the exporting user
43 global $USER;
44 if ($USER->id != $this->user->id) {
45 return false;
46 }
47 return true;
67a87e7d 48 }
d67bfc32 49
d96a1acc 50 public function get_continue_url() {
51 return false;
d67bfc32 52 }
67a87e7d 53}
54
55?>