mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
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
This commit is contained in:
parent
8a45aa5a95
commit
e23ef951fa
@ -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 "<form name=\"theform\" method=\"post\" $onsubmit action=\"$form->destination\">\n";
|
||||
?>
|
||||
<input type="hidden" name="reference" value="<?php p($form->reference) ?>">
|
||||
<input type="hidden" name="datadir" value="<?php p(substr($tempdir,strlen($basedir)+strlen($scormdir))) ?>">
|
||||
<input type="hidden" name="datadir" value="<?php p(substr($tempdir,strlen($scormdir))) ?>">
|
||||
<input type="hidden" name="summary" value="<?php p($form->summary) ?>">
|
||||
<input type="hidden" name="auto" value="<?php p($form->auto) ?>">
|
||||
<input type="hidden" name="name" value="<?php p($form->name) ?>">
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user