MDL-30007 standardise module version files
[moodle.git] / portfolio / download / lib.php
CommitLineData
67a87e7d 1<?php
2
3require_once($CFG->libdir . '/portfoliolib.php');
4
d96a1acc 5class portfolio_plugin_download extends portfolio_plugin_pull_base {
67a87e7d 6
67a87e7d 7 protected $exportconfig;
8
0f71f48b 9 public static function get_name() {
10 return get_string('pluginname', 'portfolio_download');
11 }
12
384ba38a 13 public static function allows_multiple_instances() {
67a87e7d 14 return false;
15 }
16
17 public function expected_time($callertime) {
18 return PORTFOLIO_TIME_LOW;
19 }
20
d67bfc32 21 public function prepare_package() {
67a87e7d 22
d96a1acc 23 $files = $this->exporter->get_tempfiles();
3d7fe069 24
25 if (count($files) == 1) {
26 $this->set('file', array_shift($files));
37f03ea0 27 } else {
28 $this->set('file', $this->exporter->zip_tempfiles()); // this will throw a file_exception which the exporter catches separately.
3d7fe069 29 }
67a87e7d 30 }
31
abcd0fc5 32 public function steal_control($stage) {
33 if ($stage == PORTFOLIO_STAGE_FINISHED) {
34 global $CFG;
edf1fc35 35 return $CFG->wwwroot . '/portfolio/download/file.php?id=' . $this->get('exporter')->get('id');
abcd0fc5 36 }
37 }
38
37f03ea0 39 public function send_package() {}
67a87e7d 40
d96a1acc 41 public function verify_file_request_params($params) {
42 // for download plugin the only thing we need to verify is that
43 // the logged in user is the same as the exporting user
44 global $USER;
45 if ($USER->id != $this->user->id) {
46 return false;
47 }
48 return true;
67a87e7d 49 }
d67bfc32 50
5d0dbf13 51 public function get_interactive_continue_url() {
d96a1acc 52 return false;
d67bfc32 53 }
67a87e7d 54}
55