From 3aabd3fe4d60e01901c1fdaf758b79fc75071375 Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Fri, 1 Aug 2008 12:12:57 +0000 Subject: [PATCH] MDL-15911: support in odslib to write the file out rather than just send it --- lib/odslib.class.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/odslib.class.php b/lib/odslib.class.php index 4d70c1b8d1..59832780fb 100644 --- a/lib/odslib.class.php +++ b/lib/odslib.class.php @@ -36,9 +36,11 @@ class MoodleODSWorkbook { var $worksheets = array(); var $filename; + var $send; - function MoodleODSWorkbook($filename) { + function MoodleODSWorkbook($filename, $send=true) { $this->filename = $filename; + $this->send = $send; } /* Create one Moodle Worksheet @@ -95,15 +97,22 @@ class MoodleODSWorkbook { $files[] = "$dir/META-INF"; $filename = "$dir/result.ods"; + if (!$this->send) { + $filename = $this->filename; + } zip_files($files, $filename); - $handle = fopen($filename, 'rb'); - $contents = fread($handle, filesize($filename)); - fclose($handle); + if ($this->send) { + $handle = fopen($filename, 'rb'); + $contents = fread($handle, filesize($filename)); + fclose($handle); - remove_dir($dir); // cleanup the temp directory + remove_dir($dir); // cleanup the temp directory - send_file($contents, $this->filename, 0, 0, true, true, 'application/vnd.oasis.opendocument.spreadsheet'); + send_file($contents, $this->filename, 0, 0, true, true, 'application/vnd.oasis.opendocument.spreadsheet'); + return; + } + return $this->filename; } /* Not required to use -- 2.39.5