2008-07-25 08:14:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once($CFG->libdir . '/portfoliolib.php');
|
|
|
|
|
2008-08-12 13:17:34 +00:00
|
|
|
class portfolio_plugin_download extends portfolio_plugin_pull_base {
|
2008-07-25 08:14:11 +00:00
|
|
|
|
|
|
|
protected $exportconfig;
|
|
|
|
|
2008-09-02 16:21:14 +00:00
|
|
|
public static function get_name() {
|
|
|
|
return get_string('pluginname', 'portfolio_download');
|
|
|
|
}
|
|
|
|
|
2009-11-16 12:57:59 +00:00
|
|
|
public static function allows_multiple_instances() {
|
2008-07-25 08:14:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function expected_time($callertime) {
|
|
|
|
return PORTFOLIO_TIME_LOW;
|
|
|
|
}
|
|
|
|
|
2008-08-09 14:24:58 +00:00
|
|
|
public function prepare_package() {
|
2008-07-25 08:14:11 +00:00
|
|
|
|
2008-08-12 13:17:34 +00:00
|
|
|
$files = $this->exporter->get_tempfiles();
|
2008-09-10 13:07:16 +00:00
|
|
|
|
|
|
|
if (count($files) == 1) {
|
|
|
|
$this->set('file', array_shift($files));
|
2008-09-12 11:22:15 +00:00
|
|
|
} else {
|
|
|
|
$this->set('file', $this->exporter->zip_tempfiles()); // this will throw a file_exception which the exporter catches separately.
|
2008-09-10 13:07:16 +00:00
|
|
|
}
|
2008-07-25 08:14:11 +00:00
|
|
|
}
|
|
|
|
|
2008-09-16 14:23:41 +00:00
|
|
|
public function steal_control($stage) {
|
|
|
|
if ($stage == PORTFOLIO_STAGE_FINISHED) {
|
|
|
|
global $CFG;
|
2009-11-18 13:27:38 +00:00
|
|
|
return $CFG->wwwroot . '/portfolio/download/file.php?id=' . $this->get('exporter')->get('id');
|
2008-09-16 14:23:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-12 11:22:15 +00:00
|
|
|
public function send_package() {}
|
2008-07-25 08:14:11 +00:00
|
|
|
|
2008-08-12 13:17:34 +00:00
|
|
|
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;
|
2008-07-25 08:14:11 +00:00
|
|
|
}
|
2008-08-09 14:24:58 +00:00
|
|
|
|
2009-11-18 12:27:15 +00:00
|
|
|
public function get_interactive_continue_url() {
|
2008-08-12 13:17:34 +00:00
|
|
|
return false;
|
2008-08-09 14:24:58 +00:00
|
|
|
}
|
2008-07-25 08:14:11 +00:00
|
|
|
}
|
|
|
|
|