]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16414 - make the download plugin just redirect to the file url
authormjollnir_ <mjollnir_>
Wed, 10 Sep 2008 13:07:16 +0000 (13:07 +0000)
committermjollnir_ <mjollnir_>
Wed, 10 Sep 2008 13:07:16 +0000 (13:07 +0000)
portfolio/type/download/lib.php

index 244aae85e3b5520d70b95c06fd8cd8af0a23a1be..babeb5a2fabe9dac331e9c1ea4bff1129d7e3364 100644 (file)
@@ -11,6 +11,13 @@ class portfolio_plugin_download extends portfolio_plugin_pull_base {
         return get_string('pluginname', 'portfolio_download');
     }
 
+    public function steal_control($stage) {
+        if ($stage == PORTFOLIO_STAGE_FINISHED) {
+            return $this->get_base_file_url();
+        }
+        return false;
+    }
+
     public static function allows_multiple() {
         return false;
     }
@@ -22,6 +29,12 @@ class portfolio_plugin_download extends portfolio_plugin_pull_base {
     public function prepare_package() {
 
         $files = $this->exporter->get_tempfiles();
+
+        if (count($files) == 1) {
+            $this->set('file', array_shift($files));
+            return true;
+        }
+
         $zipper = new zip_packer();
 
         $filename = 'portfolio-export.zip';
@@ -37,11 +50,6 @@ class portfolio_plugin_download extends portfolio_plugin_pull_base {
         return true;
     }
 
-    public function get_extra_finish_options() {
-        global $CFG;
-        return array($CFG->wwwroot . '/portfolio/file.php?id=' . $this->exporter->get('id') => get_string('downloadfile', 'portfolio_download'));
-    }
-
     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