Index: preset.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/preset.php,v retrieving revision 1.24.2.3 diff -u -r1.24.2.3 preset.php --- mod/data/preset.php 16 Apr 2008 03:23:09 -0000 1.24.2.3 +++ mod/data/preset.php 31 May 2008 11:52:32 -0000 @@ -187,18 +187,20 @@ if (!data_submitted() or !confirm_sesskey()) { error("Invalid request"); } - + $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)) { + error('Can\'t move preset ZIP file to download location'); + } echo '
'; - $file = data_presets_export($course, $cm, $data); - echo get_string('exportedtozip', 'data')."
"; - $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)) error("Can't move zip"); - echo "".get_string('download', 'data').""; + echo get_string('exportedtozip', 'data') . '
'; + echo "" . get_string('download', 'data') . ''; echo '
'; break;