aboutsummaryrefslogtreecommitdiff
path: root/lib/models/Courseware/StructuralElement.php
diff options
context:
space:
mode:
authorRon Lucke <lucke@elan-ev.de>2022-04-22 05:59:00 +0000
committerMarcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de>2022-04-22 05:59:00 +0000
commit6ad7722061da547b7c02b7be84f9d142ab0d0464 (patch)
tree7963f53c48ee5f375fd8ec843a12ebede22f607f /lib/models/Courseware/StructuralElement.php
parentc1d22a7b831b9322b0e3411f130a012c1e0ea005 (diff)
fix #712
Closes #712
Diffstat (limited to 'lib/models/Courseware/StructuralElement.php')
-rwxr-xr-xlib/models/Courseware/StructuralElement.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/models/Courseware/StructuralElement.php b/lib/models/Courseware/StructuralElement.php
index ba1563e..b135e4a 100755
--- a/lib/models/Courseware/StructuralElement.php
+++ b/lib/models/Courseware/StructuralElement.php
@@ -715,7 +715,7 @@ SQL;
}
}
- public function pdfExport($user)
+ public function pdfExport($user, bool $with_children = false)
{
$doc = new \ExportPDF('P', 'mm', 'A4', true, 'UTF-8', false);
$doc->setHeaderTitle(_('Courseware'));
@@ -734,31 +734,34 @@ SQL;
return $doc;
}
- $doc->writeHTML($this->getElementPdfExport());
+ $doc->writeHTML($this->getElementPdfExport('', $with_children, $user));
return $doc;
}
- private function getElementPdfExport(string $parent_name = '', bool $with_children = false)
+ private function getElementPdfExport(string $parent_name = '', bool $with_children, $user)
{
+ if (!$this->canRead($user)) {
+ return '';
+ }
if ($parent_name !== '') {
$parent_name .= ' / ';
}
$html = '<h1>' . $parent_name . $this->title . '</h1>';
$html .= $this->getContainerPdfExport();
if ($with_children) {
- $html .= $this->getChildrenPdfExport($parent_name);
+ $html .= $this->getChildrenPdfExport($parent_name, $with_children, $user);
}
return $html;
}
- private function getChildrenPdfExport(string $parent_name)
+ private function getChildrenPdfExport(string $parent_name, bool $with_children, $user)
{
$children = self::findBySQL('parent_id = ?', [$this->id]);
$html = '';
foreach ($children as $child) {
- $html .= $child->getElementPdfExport($parent_name . $this->title);
+ $html .= $child->getElementPdfExport($parent_name . $this->title, $with_children, $user);
}
return $html;