Merge branch 'MDL-67070-master' of git://github.com/andrewnicols/moodle
[moodle.git] / portfolio / download / lib.php
... / ...
CommitLineData
1<?php
2
3require_once($CFG->libdir . '/portfoliolib.php');
4require_once($CFG->libdir . '/portfolio/plugin.php');
5
6class portfolio_plugin_download extends portfolio_plugin_pull_base {
7
8 protected $exportconfig;
9
10 public static function get_name() {
11 return get_string('pluginname', 'portfolio_download');
12 }
13
14 public static function allows_multiple_instances() {
15 return false;
16 }
17
18 public function expected_time($callertime) {
19 return PORTFOLIO_TIME_LOW;
20 }
21
22 public function prepare_package() {
23
24 $files = $this->exporter->get_tempfiles();
25
26 if (count($files) == 1) {
27 $this->set('file', array_shift($files));
28 } else {
29 $this->set('file', $this->exporter->zip_tempfiles()); // this will throw a file_exception which the exporter catches separately.
30 }
31 }
32
33 public function steal_control($stage) {
34 if ($stage == PORTFOLIO_STAGE_FINISHED) {
35 global $CFG;
36 return $CFG->wwwroot . '/portfolio/download/file.php?id=' . $this->get('exporter')->get('id');
37 }
38 }
39
40 public function send_package() {}
41
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;
50 }
51
52 public function get_interactive_continue_url() {
53 return false;
54 }
55}
56