mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02: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
2 changed files with 24 additions and 30 deletions
|
@ -29,11 +29,12 @@
|
||||||
//
|
//
|
||||||
// Create a temporary directory to unzip package and validate imsmanifest
|
// Create a temporary directory to unzip package and validate imsmanifest
|
||||||
//
|
//
|
||||||
$basedir = $CFG->dataroot."/".$course->id;
|
|
||||||
$scormdir = "/moddata/scorm";
|
$coursedir = "$CFG->dataroot/$course->id";
|
||||||
if (scorm_mkdirs($basedir.$scormdir)) {
|
|
||||||
if ($tempdir = scorm_datadir($basedir.$scormdir, $form->datadir)) {
|
if ($scormdir = make_upload_directory("$course->id/$CFG->moddata/scorm")) {
|
||||||
copy ($basedir."/".$form->reference, $tempdir."/".basename($form->reference));
|
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
|
if (empty($CFG->unzip)) { // Use built-in php-based unzip function
|
||||||
include_once($CFG->dirroot.'/lib/pclzip/pclzip.lib.php');
|
include_once($CFG->dirroot.'/lib/pclzip/pclzip.lib.php');
|
||||||
$archive = new PclZip($tempdir."/".basename($form->reference));
|
$archive = new PclZip($tempdir."/".basename($form->reference));
|
||||||
|
@ -85,7 +86,7 @@
|
||||||
echo "<form name=\"theform\" method=\"post\" $onsubmit action=\"$form->destination\">\n";
|
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="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="summary" value="<?php p($form->summary) ?>">
|
||||||
<input type="hidden" name="auto" value="<?php p($form->auto) ?>">
|
<input type="hidden" name="auto" value="<?php p($form->auto) ?>">
|
||||||
<input type="hidden" name="name" value="<?php p($form->name) ?>">
|
<input type="hidden" name="name" value="<?php p($form->name) ?>">
|
||||||
|
|
|
@ -171,19 +171,11 @@ function scorm_randstring($len = "8")
|
||||||
return $rstring;
|
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")
|
function scorm_datadir($strPath, $existingdir="", $prefix = "SCORM")
|
||||||
{
|
{
|
||||||
|
global $CFG;
|
||||||
|
|
||||||
if (($existingdir!="") && (is_dir($strPath.$existingdir)))
|
if (($existingdir!="") && (is_dir($strPath.$existingdir)))
|
||||||
return $strPath.$existingdir;
|
return $strPath.$existingdir;
|
||||||
|
|
||||||
|
@ -192,6 +184,7 @@ function scorm_datadir($strPath, $existingdir="", $prefix = "SCORM")
|
||||||
$datadir="/".$prefix.scorm_randstring();
|
$datadir="/".$prefix.scorm_randstring();
|
||||||
} while (file_exists($strPath.$datadir));
|
} while (file_exists($strPath.$datadir));
|
||||||
mkdir($strPath.$datadir, $CFG->directorypermissions);
|
mkdir($strPath.$datadir, $CFG->directorypermissions);
|
||||||
|
@chmod($strPath.$datadir, $CFG->directorypermissions); // Just in case mkdir didn't do it
|
||||||
return $strPath.$datadir;
|
return $strPath.$datadir;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue