Skip to content
Snippets Groups Projects
Commit f684be3f authored by Ron Lucke's avatar Ron Lucke Committed by Elmar Ludwig
Browse files

fix #2933

Closes #2933

Merge request studip/studip!2008
parent ef2407d5
No related branches found
No related tags found
No related merge requests found
...@@ -332,7 +332,13 @@ abstract class BlockType ...@@ -332,7 +332,13 @@ abstract class BlockType
{ {
static $file_map = []; static $file_map = [];
if ($this->block->container->structural_element->range_id === $rangeId) { $file_ref = \FileRef::find($fileId);
if (!$file_ref) {
return '';
}
if ($file_ref->getRangeCourseId() === $rangeId) {
return $fileId; return $fileId;
} }
...@@ -341,16 +347,15 @@ abstract class BlockType ...@@ -341,16 +347,15 @@ abstract class BlockType
} }
$user = \User::findCurrent(); $user = \User::findCurrent();
if ($file_ref = \FileRef::find($fileId)) { $destinationFolder = $this->getDestinationFolder($user, $rangeId);
$copiedFile = \FileManager::copyFile( $copiedFile = \FileManager::copyFile(
$file_ref->getFiletype(), $file_ref->getFiletype(),
$this->getDestinationFolder($user, $rangeId), $destinationFolder,
$user $user
); );
if (is_object($copiedFile)) { if (is_object($copiedFile)) {
return $file_map[$fileId] = $copiedFile->id; return $file_map[$fileId] = $copiedFile->id;
}
} }
return ''; return '';
...@@ -368,7 +373,13 @@ abstract class BlockType ...@@ -368,7 +373,13 @@ abstract class BlockType
{ {
static $folder_map = []; static $folder_map = [];
if ($this->block->container->structural_element->range_id === $rangeId) { $sourceFolder = \Folder::find($folderId);
if (!$sourceFolder) {
return '';
}
if ($sourceFolder->getRangeCourseId() === $rangeId) {
return $folderId; return $folderId;
} }
...@@ -378,16 +389,14 @@ abstract class BlockType ...@@ -378,16 +389,14 @@ abstract class BlockType
$user = \User::findCurrent(); $user = \User::findCurrent();
$destinationFolder = $this->getDestinationFolder($user, $rangeId); $destinationFolder = $this->getDestinationFolder($user, $rangeId);
if ($sourceFolder = \Folder::find($folderId)) { $copiedFolder = \FileManager::copyFolder(
$copiedFolder = \FileManager::copyFolder( $sourceFolder->getTypedFolder(),
$sourceFolder->getTypedFolder(), $destinationFolder,
$destinationFolder, $user
$user );
);
if (is_object($copiedFolder)) { if (is_object($copiedFolder)) {
return $folder_map[$folderId] = $copiedFolder->id; return $folder_map[$folderId] = $copiedFolder->id;
}
} }
return ''; return '';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment