From 664ae635d5d12cd6e8cf46206170a94d6b1b4b0a Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 17 Oct 2004 22:49:51 +0000 Subject: [PATCH] Now Scorm's FileManager is using central zip and unzip functions. Merged from MOODLE_14_STABLE --- mod/scorm/coursefiles.php | 68 +++++++-------------------------------- 1 file changed, 11 insertions(+), 57 deletions(-) diff --git a/mod/scorm/coursefiles.php b/mod/scorm/coursefiles.php index 68130aca54..7ca83be6b6 100755 --- a/mod/scorm/coursefiles.php +++ b/mod/scorm/coursefiles.php @@ -350,25 +350,16 @@ if (!empty($name)) { html_header($course, $wdir); $name = clean_filename($name); - if (empty($CFG->zip)) { // Use built-in php-based zip function - $files = array(); - foreach ($USER->filelist as $file) { - $files[] = "$basedir/$file"; - } - include_once($CFG->libdir.'/pclzip/pclzip.lib.php'); - $archive = new PclZip("$basedir/$wdir/$name"); - if (($list = $archive->create($files,'',"$basedir/$wdir/")) == 0) { - error($archive->errorInfo(true)); - } - } else { // Use external zip program - $files = ""; - foreach ($USER->filelist as $file) { - $files .= basename($file); - $files .= " "; - } - $command = "cd $basedir/$wdir ; $CFG->zip -r $name $files"; - Exec($command); + + $files = array(); + foreach ($USER->filelist as $file) { + $files[] = "$basedir/$file"; + } + + if (!zip_files($files,"$basedir/$wdir/$name")) { + error(get_string("zipfileserror","error")); } + clearfilelist(); displaydir($wdir); @@ -409,10 +400,6 @@ case "unzip": html_header($course, $wdir); if (!empty($file)) { - $strname = get_string("name"); - $strsize = get_string("size"); - $strmodified = get_string("modified"); - $strstatus = get_string("status"); $strok = get_string("ok"); $strunpacking = get_string("unpacking", "", $file); @@ -420,41 +407,8 @@ $file = basename($file); - if (empty($CFG->unzip)) { // Use built-in php-based unzip function - include_once($CFG->libdir.'/pclzip/pclzip.lib.php'); - $archive = new PclZip("$basedir/$wdir/$file"); - if (!$list = $archive->extract("$basedir/$wdir")) { - error($archive->errorInfo(true)); - } else { // print some output - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - foreach ($list as $item) { - echo ""; - $item['filename'] = str_replace("$basedir/$wdir/", "", $item['filename']); - print_cell("left", $item['filename']); - if (! $item['folder']) { - print_cell("right", display_size($item['size'])); - } else { - echo ""; - } - $filedate = userdate($item['mtime'], get_string("strftimedatetime")); - print_cell("right", $filedate); - print_cell("right", $item['status']); - echo ""; - } - echo "
$strname$strsize$strmodified$strstatus
 
"; - } - - } else { // Use external unzip program - print_simple_box_start("center"); - echo "
";
-                    $command = "cd $basedir/$wdir ; $CFG->unzip -o $file 2>&1";
-                    passthru($command);
-                    echo "
"; - print_simple_box_end(); + if (!unzip_file("$basedir/$wdir/$file")) { + error(get_string("unzipfileserror","error")); } echo "
"; -- 2.39.5