MDL-16463 "Long group names can make drop down box too wide" added an if condition...
[moodle.git] / portfolio / type / download / lib.php
CommitLineData
67a87e7d 1<?php
2
3require_once($CFG->libdir . '/portfoliolib.php');
d96a1acc 4require_once($CFG->libdir . '/packer/zip_packer.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
67a87e7d 14 public static function allows_multiple() {
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));
28 return true;
29 }
30
d96a1acc 31 $zipper = new zip_packer();
67a87e7d 32
d96a1acc 33 $filename = 'portfolio-export.zip';
0a154154 34 list ($contextid, $filearea, $itemid) = array_values($this->get('exporter')->get_base_filearea());
87fcac8d 35 if ($newfile = $zipper->archive_to_storage($files, $contextid, $filearea, $itemid, '/final/', $filename, $this->user->id)) {
d96a1acc 36 $this->set('file', $newfile);
37 return true;
38 }
39 return false;
67a87e7d 40 }
41
354c9a50 42 public function get_extra_finish_options() {
43 global $CFG;
44 return array($this->get_base_file_url() => get_string('downloadfile', 'portfolio_download'));
45 }
46
67a87e7d 47 public function send_package() {
48 return true;
49 }
50
d96a1acc 51 public function verify_file_request_params($params) {
52 // for download plugin the only thing we need to verify is that
53 // the logged in user is the same as the exporting user
54 global $USER;
55 if ($USER->id != $this->user->id) {
56 return false;
57 }
58 return true;
67a87e7d 59 }
d67bfc32 60
d96a1acc 61 public function get_continue_url() {
62 return false;
d67bfc32 63 }
67a87e7d 64}
65
66?>