forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.php
56 lines (42 loc) · 1.51 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
require_once($CFG->libdir . '/portfoliolib.php');
require_once($CFG->libdir . '/portfolio/plugin.php');
class portfolio_plugin_download extends portfolio_plugin_pull_base {
protected $exportconfig;
public static function get_name() {
return get_string('pluginname', 'portfolio_download');
}
public static function allows_multiple_instances() {
return false;
}
public function expected_time($callertime) {
return PORTFOLIO_TIME_LOW;
}
public function prepare_package() {
$files = $this->exporter->get_tempfiles();
if (count($files) == 1) {
$this->set('file', array_shift($files));
} else {
$this->set('file', $this->exporter->zip_tempfiles()); // this will throw a file_exception which the exporter catches separately.
}
}
public function steal_control($stage) {
if ($stage == PORTFOLIO_STAGE_FINISHED) {
global $CFG;
return $CFG->wwwroot . '/portfolio/download/file.php?id=' . $this->get('exporter')->get('id');
}
}
public function send_package() {}
public function verify_file_request_params($params) {
// for download plugin the only thing we need to verify is that
// the logged in user is the same as the exporting user
global $USER;
if ($USER->id != $this->user->id) {
return false;
}
return true;
}
public function get_interactive_continue_url() {
return false;
}
}