diff options
| author | Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> | 2022-08-12 08:21:15 +0000 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2022-08-12 08:21:15 +0000 |
| commit | df0a0f6a23fe9f35296b6bb15ce65b41c0404530 (patch) | |
| tree | 812f42e3bafb05236a5a3f031ea0fbfa15f72f63 /lib/models/Courseware/StructuralElement.php | |
| parent | 0f5785a850d01420cc54b3a229c6f1cddfaa842c (diff) | |
fix order during copy, don't use self to access methods on $this, fixes #1361
Closes #1361
Merge request studip/studip!892
Diffstat (limited to 'lib/models/Courseware/StructuralElement.php')
| -rw-r--r-- | lib/models/Courseware/StructuralElement.php | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/models/Courseware/StructuralElement.php b/lib/models/Courseware/StructuralElement.php index 5b834e9..8edabad 100644 --- a/lib/models/Courseware/StructuralElement.php +++ b/lib/models/Courseware/StructuralElement.php @@ -678,7 +678,7 @@ SQL; */ public function copy(User $user, StructuralElement $parent, string $purpose = ''): StructuralElement { - $file_ref_id = self::copyImage($user, $parent); + $file_ref_id = $this->copyImage($user, $parent); $element = self::build([ 'parent_id' => $parent->id, @@ -696,9 +696,9 @@ SQL; $element->store(); - self::copyContainers($user, $element); + $this->copyContainers($user, $element); - self::copyChildren($user, $element, $purpose); + $this->copyChildren($user, $element, $purpose); return $element; } @@ -724,7 +724,7 @@ SQL; { // merge with target if (!$target->image_id) { - $target->image_id = self::copyImage($user, $target); + $target->image_id = $this->copyImage($user, $target); } if ($target->title === 'neue Seite' || $target->title === 'New page') { @@ -762,29 +762,24 @@ SQL; $target->store(); // add Containers to target - self::copyContainers($user, $target); + $this->copyContainers($user, $target); // copy Children - - self::copyChildren($user, $target); + $this->copyChildren($user, $target); return $this; } private function copyContainers(User $user, StructuralElement $newElement): void { - $containers = \Courseware\Container::findBySQL('structural_element_id = ?', [$this->id]); - - foreach ($containers as $container) { + foreach ($this->containers as $container) { $container->copy($user, $newElement); } } private function copyChildren(User $user, StructuralElement $newElement, string $purpose = ''): void { - $children = self::findBySQL('parent_id = ?', [$this->id]); - - foreach ($children as $child) { + foreach ($this->children as $child) { $child->copy($user, $newElement, $purpose); } } |
