Merge branch 'MDL-68954-master' of git://github.com/mihailges/moodle
[moodle.git] / portfolio / download / lib.php
CommitLineData
67a87e7d 1<?php
2
3require_once($CFG->libdir . '/portfoliolib.php');
b96c9a1a 4require_once($CFG->libdir . '/portfolio/plugin.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
384ba38a 14 public static function allows_multiple_instances() {
67a87e7d 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
abcd0fc5 33 public function steal_control($stage) {
34 if ($stage == PORTFOLIO_STAGE_FINISHED) {
35 global $CFG;
edf1fc35 36 return $CFG->wwwroot . '/portfolio/download/file.php?id=' . $this->get('exporter')->get('id');
abcd0fc5 37 }
38 }
39
37f03ea0 40 public function send_package() {}
67a87e7d 41
d96a1acc 42 public function verify_file_request_params($params) {
43 // for download plugin the only thing we need to verify is that
44 // the logged in user is the same as the exporting user
45 global $USER;
46 if ($USER->id != $this->user->id) {
47 return false;
48 }
49 return true;
67a87e7d 50 }
d67bfc32 51
5d0dbf13 52 public function get_interactive_continue_url() {
d96a1acc 53 return false;
d67bfc32 54 }
67a87e7d 55}
56