MDL-14591 - better handling of variable headers in portfolio export
[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
0f71f48b 10 public static function get_name() {
11 return get_string('pluginname', 'portfolio_download');
12 }
13
67a87e7d 14 public static function allows_multiple() {
15 return false;
16 }
17
18 public function expected_time($callertime) {
19 return PORTFOLIO_TIME_LOW;
20 }
21
d67bfc32 22 public function prepare_package() {
67a87e7d 23
d96a1acc 24 $files = $this->exporter->get_tempfiles();
3d7fe069 25
26 if (count($files) == 1) {
27 $this->set('file', array_shift($files));
37f03ea0 28 } else {
29 $this->set('file', $this->exporter->zip_tempfiles()); // this will throw a file_exception which the exporter catches separately.
3d7fe069 30 }
67a87e7d 31 }
32
354c9a50 33 public function get_extra_finish_options() {
34 global $CFG;
35 return array($this->get_base_file_url() => get_string('downloadfile', 'portfolio_download'));
36 }
37
37f03ea0 38 public function send_package() {}
67a87e7d 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