Prevent copy of trees that does not exist.
parent
a41a8f82f9
commit
7a3888a367
|
@ -1109,7 +1109,9 @@ Class H5PExport {
|
||||||
@mkdir($tempPath);
|
@mkdir($tempPath);
|
||||||
$exportData = $this->h5pF->getExportData($contentId);
|
$exportData = $this->h5pF->getExportData($contentId);
|
||||||
// Create content folder
|
// Create content folder
|
||||||
$this->h5pC->copyTree($h5pDir . 'content' . DIRECTORY_SEPARATOR . $contentId, $tempPath . DIRECTORY_SEPARATOR . 'content');
|
if ($this->h5pC->copyTree($h5pDir . 'content' . DIRECTORY_SEPARATOR . $contentId, $tempPath . DIRECTORY_SEPARATOR . 'content') === FALSE) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
file_put_contents($tempPath . DIRECTORY_SEPARATOR . 'content' . DIRECTORY_SEPARATOR . 'content.json', $exportData['jsonContent']);
|
file_put_contents($tempPath . DIRECTORY_SEPARATOR . 'content' . DIRECTORY_SEPARATOR . 'content.json', $exportData['jsonContent']);
|
||||||
|
|
||||||
// Make embedTypes into an array
|
// Make embedTypes into an array
|
||||||
|
@ -1307,6 +1309,12 @@ class H5PCore {
|
||||||
*/
|
*/
|
||||||
public function copyTree($source, $destination) {
|
public function copyTree($source, $destination) {
|
||||||
$dir = opendir($source);
|
$dir = opendir($source);
|
||||||
|
|
||||||
|
if ($dir === FALSE) {
|
||||||
|
$this->h5pF->setErrorMessage($this->h5pF->t('Unable to copy tree, no such directory: @dir', array('@dir' => $source)));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
@mkdir($destination);
|
@mkdir($destination);
|
||||||
while (false !== ($file = readdir($dir))) {
|
while (false !== ($file = readdir($dir))) {
|
||||||
if (($file != '.') && ($file != '..')) {
|
if (($file != '.') && ($file != '..')) {
|
||||||
|
|
Loading…
Reference in New Issue