From e23ef951fae0df4fc9a149733c901f4edeaade7b Mon Sep 17 00:00:00 2001 From: moodler Date: Sat, 22 May 2004 04:00:34 +0000 Subject: [PATCH] Fixes for the problem creating directories. It was just a missing $CFG, but I got rid of scorm_mkdirs to use the moodlelib equivalent instead --- mod/scorm/details.php | 41 +++++++++++++++++++++-------------------- mod/scorm/lib.php | 13 +++---------- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/mod/scorm/details.php b/mod/scorm/details.php index d9547d22e9..7eb7d64277 100755 --- a/mod/scorm/details.php +++ b/mod/scorm/details.php @@ -29,25 +29,26 @@ // // Create a temporary directory to unzip package and validate imsmanifest // - $basedir = $CFG->dataroot."/".$course->id; - $scormdir = "/moddata/scorm"; - if (scorm_mkdirs($basedir.$scormdir)) { - if ($tempdir = scorm_datadir($basedir.$scormdir, $form->datadir)) { - copy ($basedir."/".$form->reference, $tempdir."/".basename($form->reference)); - if (empty($CFG->unzip)) { // Use built-in php-based unzip function - include_once($CFG->dirroot.'/lib/pclzip/pclzip.lib.php'); - $archive = new PclZip($tempdir."/".basename($form->reference)); - if (!$list = $archive->extract($tempdir)) { - error($archive->errorInfo(true)); - } - } else { - $command = "cd $tempdir; $CFG->unzip -o ".basename($form->reference)." 2>&1"; - exec($command); - } - $result = scorm_validate($tempdir."/imsmanifest.xml"); - } else { - $result = "packagedir"; - } + + $coursedir = "$CFG->dataroot/$course->id"; + + if ($scormdir = make_upload_directory("$course->id/$CFG->moddata/scorm")) { + if ($tempdir = scorm_datadir($scormdir, $form->datadir)) { + copy ("$coursedir/$form->reference", $tempdir."/".basename($form->reference)); + if (empty($CFG->unzip)) { // Use built-in php-based unzip function + include_once($CFG->dirroot.'/lib/pclzip/pclzip.lib.php'); + $archive = new PclZip($tempdir."/".basename($form->reference)); + if (!$list = $archive->extract($tempdir)) { + error($archive->errorInfo(true)); + } + } else { + $command = "cd $tempdir; $CFG->unzip -o ".basename($form->reference)." 2>&1"; + exec($command); + } + $result = scorm_validate($tempdir."/imsmanifest.xml"); + } else { + $result = "packagedir"; + } } else { $result = "datadir"; } @@ -85,7 +86,7 @@ echo "
destination\">\n"; ?> - + diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 111d2a8a24..f54bda2768 100755 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -171,19 +171,11 @@ function scorm_randstring($len = "8") return $rstring; } -function scorm_mkdirs($strPath) -{ - global $CFG; - if (is_dir($strPath)) - return true; - $pStrPath = dirname($strPath); - if (!scorm_mkdirs($pStrPath)) - return false; - return mkdir($strPath, $CFG->directorypermissions); -} function scorm_datadir($strPath, $existingdir="", $prefix = "SCORM") { + global $CFG; + if (($existingdir!="") && (is_dir($strPath.$existingdir))) return $strPath.$existingdir; @@ -192,6 +184,7 @@ function scorm_datadir($strPath, $existingdir="", $prefix = "SCORM") $datadir="/".$prefix.scorm_randstring(); } while (file_exists($strPath.$datadir)); mkdir($strPath.$datadir, $CFG->directorypermissions); + @chmod($strPath.$datadir, $CFG->directorypermissions); // Just in case mkdir didn't do it return $strPath.$datadir; } else { return false; -- 2.39.5