Merge branch 'MDL-79186-401' of https://github.com/paulholden/moodle into MOODLE_401_...
[moodle.git] / portfolio / download / lib.php
blob081db48aa5d4dcafab2684c1ad45ed95e488ad27
1 <?php
3 require_once($CFG->libdir . '/portfoliolib.php');
4 require_once($CFG->libdir . '/portfolio/plugin.php');
6 class portfolio_plugin_download extends portfolio_plugin_pull_base {
8 protected $exportconfig;
10 public static function get_name() {
11 return get_string('pluginname', 'portfolio_download');
14 public static function allows_multiple_instances() {
15 return false;
18 public function expected_time($callertime) {
19 return PORTFOLIO_TIME_LOW;
22 public function prepare_package() {
24 $files = $this->exporter->get_tempfiles();
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.
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');
40 public function send_package() {}
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;
49 return true;
52 public function get_interactive_continue_url() {
53 return false;