67a87e7d |
1 | <?php |
2 | |
3 | require_once($CFG->libdir . '/portfoliolib.php'); |
4 | |
5 | class portfolio_plugin_download extends portfolio_plugin_base { |
6 | |
7 | protected $zipfile; |
8 | protected $exportconfig; |
9 | |
10 | public static function supported_formats() { |
11 | return array(PORTFOLIO_FORMAT_FILE, PORTFOLIO_FORMAT_HTML); |
12 | // @todo more later, like moodle backup for example |
13 | } |
14 | |
15 | public static function allows_multiple() { |
16 | return false; |
17 | } |
18 | |
19 | public function expected_time($callertime) { |
20 | return PORTFOLIO_TIME_LOW; |
21 | } |
22 | |
23 | public function prepare_package($tempdir) { |
24 | // just zip up whatever files the caller has created for us |
25 | // and move them to the user's temporary area. |
26 | $userdir = temp_portfolio_usertemp_directory($this->get('user')->id); |
27 | |
28 | $newfile = 'portfolio_export_' . time() . '.zip'; |
29 | $files = get_directory_list($tempdir); |
30 | foreach ($files as $key => $file) { |
31 | $files[$key] = $tempdir . '/' . $file; |
32 | } |
33 | |
34 | zip_files($files, $userdir . '/' . $newfile); |
35 | $this->set('zipfile', $newfile); |
36 | |
37 | return true; |
38 | } |
39 | |
40 | public function send_package() { |
41 | return true; |
42 | } |
43 | |
44 | public function get_extra_finish_options() { |
45 | global $CFG; |
46 | return array( |
47 | // @todo this will go through files api later, this is a (nonworking) hack for now. |
48 | $CFG->wwwroot . '/file.php?file=' . $this->zipfile => get_string('downloadfile', 'portfolio_download'), |
49 | ); |
50 | } |
51 | |
52 | public function get_continue_url() { |
53 | return false; |
54 | } |
55 | } |
56 | |
57 | ?> |