|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 require_once($CFG->libdir . '/portfoliolib.php'); 00004 00005 class portfolio_plugin_download extends portfolio_plugin_pull_base { 00006 00007 protected $exportconfig; 00008 00009 public static function get_name() { 00010 return get_string('pluginname', 'portfolio_download'); 00011 } 00012 00013 public static function allows_multiple_instances() { 00014 return false; 00015 } 00016 00017 public function expected_time($callertime) { 00018 return PORTFOLIO_TIME_LOW; 00019 } 00020 00021 public function prepare_package() { 00022 00023 $files = $this->exporter->get_tempfiles(); 00024 00025 if (count($files) == 1) { 00026 $this->set('file', array_shift($files)); 00027 } else { 00028 $this->set('file', $this->exporter->zip_tempfiles()); // this will throw a file_exception which the exporter catches separately. 00029 } 00030 } 00031 00032 public function steal_control($stage) { 00033 if ($stage == PORTFOLIO_STAGE_FINISHED) { 00034 global $CFG; 00035 return $CFG->wwwroot . '/portfolio/download/file.php?id=' . $this->get('exporter')->get('id'); 00036 } 00037 } 00038 00039 public function send_package() {} 00040 00041 public function verify_file_request_params($params) { 00042 // for download plugin the only thing we need to verify is that 00043 // the logged in user is the same as the exporting user 00044 global $USER; 00045 if ($USER->id != $this->user->id) { 00046 return false; 00047 } 00048 return true; 00049 } 00050 00051 public function get_interactive_continue_url() { 00052 return false; 00053 } 00054 } 00055