aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Lucke <lucke@elan-ev.de>2023-01-23 07:29:48 +0000
committerRon Lucke <lucke@elan-ev.de>2023-01-23 07:29:48 +0000
commit61cff0278cb6e8a21feedbcef10094d0d43119a6 (patch)
tree08ec0e3450c446c22c2e5ae0ba5c05a9ebf29813
parentd26ad6c109b3f40038fa57495b49d6be56435474 (diff)
BIEST #2049
Closes #2049 Merge request studip/studip!1328
-rw-r--r--lib/models/Courseware/StructuralElement.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/models/Courseware/StructuralElement.php b/lib/models/Courseware/StructuralElement.php
index 9aa4f90..dbe2e62 100644
--- a/lib/models/Courseware/StructuralElement.php
+++ b/lib/models/Courseware/StructuralElement.php
@@ -817,6 +817,12 @@ SQL;
*/
public function copy(User $user, StructuralElement $parent, string $purpose = ''): StructuralElement
{
+ $ancestorIds = array_column($parent->findAncestors(), 'id');
+ $ancestorIds[] = $parent->id;
+ if (in_array($this->id, $ancestorIds)) {
+ throw new \InvalidArgumentException('Cannot copy into descendants.');
+ }
+
$file_ref_id = $this->copyImage($user, $parent);
$element = self::build([