]> git.mjollnir.org Git - moodle.git/commitdiff
[MDL-15069] Change filename of exported preset to ensure downloading the latest versi...
authorrobertall <robertall>
Sun, 15 Jun 2008 15:35:27 +0000 (15:35 +0000)
committerrobertall <robertall>
Sun, 15 Jun 2008 15:35:27 +0000 (15:35 +0000)
mod/data/preset.php

index 29fe961ab176c749bd0472bcb544039cd7d8e839..66f0e0e01843ff409c27b08edb88cc63f66085ea 100644 (file)
@@ -187,19 +187,20 @@ switch ($action) {
         if (!data_submitted() or !confirm_sesskey()) {
             print_error('invalidrequest');
         }
-
-        echo '<div style="text-align:center">';
-        $file = data_presets_export($course, $cm, $data);
-        echo get_string('exportedtozip', 'data')."<br />";
-        $perminantfile = $CFG->dataroot."/$course->id/moddata/data/$data->id/preset.zip";
-        @unlink($perminantfile);
-        /* is this created elsewhere? sometimes its not present... */
-        make_upload_directory("$course->id/moddata/data/$data->id");
-
-        /* now just move the zip into this folder to allow a nice download */
-        if (!rename($file, $perminantfile)) 
+        $exportfile = data_presets_export($course, $cm, $data);
+        $downloadsubdir = "$course->id/moddata/data/$data->id";
+        $filename = clean_filename($data->name . '-preset-' . gmdate("Ymd_Hi") . '.zip');
+        $downloadfile = "$CFG->dataroot/$downloadsubdir/$filename";
+        @unlink($downloadfile);
+
+        // Move the exported zip to the download folder
+        make_upload_directory($downloadsubdir);
+        if (! rename($exportfile, $downloadfile)) {
             print_error('cannotmovezip');
-        echo "<a href='$CFG->wwwroot/file.php/$course->id/moddata/data/$data->id/preset.zip'>".get_string('download', 'data')."</a>";
+        }
+        echo '<div style="text-align:center">';
+        echo get_string('exportedtozip', 'data') . '<br />';
+        echo "<a href='$CFG->wwwroot/file.php/$downloadsubdir/$filename'>" . get_string('download', 'data') . '</a>';
         echo '</div>';
         break;