MDL-16232 - fix bad link in portfolio breadcrumbs
[moodle.git] / portfolio / type / download / lib.php
... / ...
CommitLineData
1<?php
2
3require_once($CFG->libdir . '/portfoliolib.php');
4require_once($CFG->libdir . '/packer/zip_packer.php');
5
6class portfolio_plugin_download extends portfolio_plugin_pull_base {
7
8 protected $exportconfig;
9
10 public static function allows_multiple() {
11 return false;
12 }
13
14 public function expected_time($callertime) {
15 return PORTFOLIO_TIME_LOW;
16 }
17
18 public function prepare_package() {
19
20 $files = $this->exporter->get_tempfiles();
21 $zipper = new zip_packer();
22
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;
29 }
30
31 public function send_package() {
32 return true;
33 }
34
35 public function get_extra_finish_options() {
36 global $CFG;
37 return array($CFG->wwwroot . '/portfolio/file.php?id=' . $this->exporter->get('id') => get_string('downloadfile', 'portfolio_download'));
38 }
39
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;
48 }
49
50 public function get_continue_url() {
51 return false;
52 }
53}
54
55?>